-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAStarBot.cpp
40 lines (39 loc) · 1.02 KB
/
AStarBot.cpp
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
#include "bots.hpp"
#include "stdlib.h"
// redefining the method
void cAStarBot::ChooseNextGridPosition()
{
// Manhattan distance:
if (gAStar.max_length > 0)
{
// moving the bot according to the coordinates stored in our path_coordinates array
SetNext(
gAStar.path_coordinates[gAStar.max_length - 1][0],
gAStar.path_coordinates[gAStar.max_length - 1][1],
gLevel
);
gAStar.max_length -= 1;
}
// Euclidean distance:
if (gAStar2.max_length > 0)
{
// moving the bot according to the coordinates stored in our path_coordinates array
SetNext(
gAStar2.path_coordinates[gAStar2.max_length - 1][0],
gAStar2.path_coordinates[gAStar2.max_length - 1][1],
gLevel
);
gAStar2.max_length -= 1;
}
// Diagonal distance:
if (gAStar3.max_length > 0)
{
// moving the bot according to the coordinates stored in our path_coordinates array
SetNext(
gAStar3.path_coordinates[gAStar3.max_length - 1][0],
gAStar3.path_coordinates[gAStar3.max_length - 1][1],
gLevel
);
gAStar3.max_length -= 1;
}
}