-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.cpp
56 lines (44 loc) · 1.02 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
45
46
47
48
49
50
51
52
53
54
55
56
#include <iostream>
#include "tak/board.hpp"
#include "tak/ptn.hpp"
#include "tak/tps.hpp"
int main() {
Board<3> b;
int depth;
std::cout << "Depth: " << std::flush;
std::cin >> depth;
std::vector<Move<3>> moves;
std::string input;
while(true) {
GameStatus s = b.status();
Move<3> move;
std::cout << "> " << std::flush;
std::cin >> input;
if(input == "exit") break;
else if(input == "undo") {
if(moves.size() > 0) {
b.undo(moves.back());
moves.pop_back();
} else {
std::cout << "No moves to undo!" << std::endl;
}
} else if(input == "status") {
s = b.status();
s.print();
std::cout << std::endl;
} else {
if(ptn::from_str(input, move)) {
b.execute(move);
moves.push_back(move);
s = b.status();
if(s.over) {
s.print();
return 0;
}
} else {
std::cout << "Invalid move!" << std::endl;
}
std::cout << tps::to_str(b) << std::endl;
}
}
}