-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathastartest_1d.cc
59 lines (39 loc) · 1.22 KB
/
astartest_1d.cc
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
#include <iomanip>
#include <iostream>
#include <string>
#include <vector>
#include <cstdlib>
#include <ctime>
#define BRDSIZ 20
bool SEEDED = false;
#include "Utilities.h"
int myrand(void) { // Random number generator: 0-BRDSIZ range.
if(!SEEDED) {
unsigned int iseed = (unsigned int)::time(NULL);
::srand(iseed);
SEEDED = true;
}
return ::rand() % BRDSIZ;
}
int main() {
std::vector<std::vector<int>> some_local;
std::vector<int> beginning;
beginning.push_back(myrand()); // x
// beginning.push_back(5); //x
std::vector<int> end;
end.push_back(myrand()); // x
// end.push_back(10); //x
some_local = AStar(beginning, end);
std::cout << "# Start node: ";
for(size_t i = 0; i < beginning.size(); ++i) std::cout << beginning[i] << " ";
std::cout << std::endl;
std::cout << "# Target node: ";
for(size_t i = 0; i < end.size(); ++i) std::cout << end[i] << " ";
std::cout << std::endl;
std::cout << "# Final path: (x)" << std::endl;
for(size_t j = 0; j < some_local.size(); ++j) {
for(size_t i = 0; i < some_local[j].size(); ++i) std::cout << some_local[j][i] << " ";
std::cout << std::endl;
}
return 0;
}