-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcli.cc
More file actions
59 lines (43 loc) · 1.41 KB
/
Copy pathcli.cc
File metadata and controls
59 lines (43 loc) · 1.41 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
47
48
49
50
51
52
53
54
55
56
57
58
59
#include <iostream>
#include <string>
#include "edgetpu.h"
#include "mcts.h"
void cli(std::string model_name, const int sims) {
std::shared_ptr<EdgeTpuModel> model =
std::make_shared<EdgeTpuModel>(model_name);
MCTS mcts(model);
mcts.use_exploration_noise(false);
mcts.use_forced_playouts(true);
Board b;
std::string line;
while (!b.game_ended()) {
uint32_t move;
std::cout << "> ";
if (!std::getline(std::cin, line))
break;
if (b.parse_san(line, move)) {
b.do_move(move);
const std::shared_ptr<Node> root = mcts.mcts(b, sims);
move = select_most_visited_move(root);
std::cout << std::endl;
std::cout << std::endl;
std::cout << " >> " << b.san(move) << " << " << std::endl;
b.do_move(move);
b.print();
} else if ("go" == line) {
const std::shared_ptr<Node> root = mcts.mcts(b, sims);
move = select_most_visited_move(root);
std::cout << std::endl;
std::cout << std::endl;
std::cout << " >> " << b.san(move) << " << " << std::endl;
b.do_move(move);
b.print();
} else if ("undo" == line) {
b.undo_move();
} else if ("d" == line) {
b.print();
} else {
std::cout << "???" << std::endl;
}
}
}