forked from LingJiJian/AStar
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathMain.cpp
More file actions
46 lines (39 loc) · 1 KB
/
Main.cpp
File metadata and controls
46 lines (39 loc) · 1 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
#include <time.h>
#include "AStar.h"
#include <iostream>
using namespace std;
int main()
{
char astar_map[1000][1000] =
{
{ 0, 1, 0, 0, 0, 1, 0, 0, 0, 0 },
{ 0, 0, 0, 1, 0, 1, 0, 1, 0, 1 },
{ 1, 1, 1, 1, 0, 1, 0, 1, 0, 1 },
{ 0, 0, 0, 1, 0, 0, 0, 1, 0, 1 },
{ 0, 1, 0, 1, 1, 1, 1, 1, 0, 1 },
{ 0, 1, 0, 0, 0, 0, 0, 0, 0, 1 },
{ 0, 1, 1, 1, 1, 1, 1, 1, 1, 1 },
{ 0, 0, 0, 0, 1, 0, 0, 0, 1, 0 },
{ 1, 1, 0, 0, 1, 0, 1, 0, 0, 0 },
{ 0, 0, 0, 0, 0, 0, 1, 0, 1, 0 },
};
auto CanReach = [&](const Point &grid)->bool
{
return astar_map[grid.row][grid.col] == 0;
};
AStarDef def;
def.row = 1000;
def.col = 1000;
def.can_reach = CanReach;
def.start_point = Point(0, 0);
def.end_point = Point(999, 999);
def.allow_corner = false;
clock_t start, end;
start = clock();
AStar astar;
auto path = astar.Search(def);
end = clock();
cout << "Run time: " << (double)(end - start) / CLOCKS_PER_SEC << "s" << endl;
system("pause");
return 0;
}