-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.cpp
45 lines (36 loc) · 1.21 KB
/
main.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
41
42
43
44
#include "Definitions.h"
int main(int argc, char **argv) {
if (argc!=4) {
std::cout<<"Usage: ./main [#searches] [#stacks] [#blocks]"<<std::endl;
return 1;
}
int numSearch = atoi(argv[1]);
int numStacks = atoi(argv[2]);
int numBlocks = atoi(argv[3]);
AStar aStar;
State startState;
State goalState;
// used to be in constructor-----------------
startState.nStacks = goalState.nStacks = numStacks;
startState.nBlocks = goalState.nBlocks = numBlocks;
for (int i=0; i<numStacks; i++) {
goalState.blockState.push_back({0});
startState.blockState.push_back({0});
goalState.blockState[i].clear();
startState.blockState[i].clear();
}
for (int i=0; i<numBlocks; i++) {
goalState.blockState[0].push_back(i);
// startState.blockState[0].push_back(i);
}
startState.scramble();
//-------------------------------------------
std::cout<<"Goal blockState:"<<std::endl;
goalState.printState();
std::cout<<"Start blockState:"<<std::endl;
std::cout<<"H(goal): "<<startState.H(goalState)<<std::endl;
startState.printState();
aStar.init(startState, goalState);
aStar.search(numSearch);
return 0;
}