-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbots.hpp
77 lines (63 loc) · 1.73 KB
/
bots.hpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
#pragma once
//======================================================================================
//Header file for bots: initially cBotRandom is defined here, but other bot classes
//can go here too
//
//(c) Patrick Dickinson, University of Lincoln, School of Computer Science, 2020
//======================================================================================
#include "botbase.hpp"
class cBotRandom : public cBotBase
{
virtual void ChooseNextGridPosition();
};
class cDijkstra
{
public:
bool closed[GRIDWIDTH][GRIDHEIGHT];
float cost[GRIDWIDTH][GRIDHEIGHT];
int linkX[GRIDWIDTH][GRIDHEIGHT];
int linkY[GRIDWIDTH][GRIDHEIGHT];
bool inPath[GRIDWIDTH][GRIDHEIGHT];
int path_coordinates[100][2];
bool completed;
// methods
virtual void Build(cBotBase& bot);
int TracePath(cBotBase& bot);
void UpdateNeighbors(int min_x, int min_y, float base_cost);
// constructor
cDijkstra();
};
// this class use manhattan by clicking on P
class cAStar : public cDijkstra
{
public:
virtual void Build(cBotBase& bot);
// initialising path length as 0
int max_length = 0;
};
// creating our bot from this class that inherit from cBot base so that it can move
class cAStarBot : public cBotBase
{
virtual void ChooseNextGridPosition();
};
// this class uses Euclidean distance by clicking on A
class cAStar2 : public cDijkstra
{
public:
virtual void Build(cBotBase& bot);
// initialising path length as 0
int max_length = 0;
};
// this class uses diagonal distance by clicking on B
class cAStar3 : public cDijkstra
{
public:
virtual void Build(cBotBase& bot);
// initialising path length as 0
int max_length = 0;
};
// extern references:
extern cDijkstra gDijkstra;
extern cAStar gAStar;
extern cAStar2 gAStar2;
extern cAStar3 gAStar3;