-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbots.h
More file actions
88 lines (70 loc) · 1.98 KB
/
bots.h
File metadata and controls
88 lines (70 loc) · 1.98 KB
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
77
78
79
80
81
82
83
84
85
86
87
88
#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.h"
#include <vector>
struct graphNode {
bool closed = false; // Whether or not location is closed.
float cost = 1000000.0f; // Cost value for each location.
int linkX = -1; // Link X coord for each location.
int linkY = -1; // Link Y coord for each location.
bool inPath = false; // Whether or not a location is in path.
float heuristic = 1000000.0f; // Heuristic cost value for each location.
void reset() {
closed = false;
cost = 1000000.0f;
linkX = -1;
linkY = -1;
inPath = false;
heuristic = 1000000.0f;
}
};
struct coordsStruct {
int x = 0;
int y = 0;
};
class cBotRandom : public cBotBase {
virtual void ChooseNextGridPosition();
};
class cBotSimple : public cBotBase {
public:
cBotSimple();
~cBotSimple();
virtual void ChooseNextGridPosition();
};
class cBotSimple2 : public cBotBase {
public:
cBotSimple2();
~cBotSimple2();
virtual void ChooseNextGridPosition();
};
class cDijkstra : public cBotBase {
public:
cDijkstra() { completed = false; };
~cDijkstra() {};
virtual void Build(cBotBase& bot);
virtual void ChooseNextGridPosition();
//void ShortestPath(cBotBase& bot);
bool completed;
bool getInPath(int x, int y) const;
bool getClosed(int x, int y) const;
protected:
graphNode graph[GRIDWIDTH][GRIDHEIGHT];
};
class cAStar: public cDijkstra {
public:
cAStar() { completed = false; };
~cAStar() {};
virtual void Build(cBotBase& bot);
//std::list<coordsStruct> getPath();
virtual void ChooseNextGridPosition();
int pathCounter = 0;
std::vector<coordsStruct> pathVec;
};
extern cDijkstra gDijkstra;
extern cAStar gAStar;
extern int gHeuristic;