Repository navigation
Expand file tree
/
Copy pathmain.cpp
More file actions
53 lines (47 loc) · 1.81 KB
/
Copy pathmain.cpp
File metadata and controls
53 lines (47 loc) · 1.81 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
#include <iostream>
#include <sstream>
#include "board.h"
#include "attacks.h"
#include "movegen.h"
#include "search.h"
#include "eval.h"
#include "uci.h"
#include "zobrist.h"
#include "transposition.h"
#include "nnue.h"
#include "datagen.h"
int main() {
// UCI talks over a pipe; unbuffered stdout keeps the GUI from waiting on us
std::cout << std::unitbuf;
init_magics();
init_zobrist();
tt_init();
nnue_init_random();
nnue_load("net.bin");
Board board{};
board.set_from_fen(START_FEN);
std::string line;
while (std::getline(std::cin, line)) {
std::istringstream ss(line);
std::string cmd;
ss >> cmd;
if (cmd == "uci") { std::cout << "id name FishBot\nid author Ashish Kumar Nanda\n"
<< "option name EvalFile type string default net.bin\nuciok\n"; }
else if (cmd == "setoption") { handle_setoption(ss); }
else if (cmd == "isready") { std::cout << "readyok\n"; }
else if (cmd == "ucinewgame") { board.set_from_fen(START_FEN); history_reset(board.hash); tt_clear();}
else if (cmd == "position") { handle_position(board, ss); }
else if (cmd == "go") { handle_go(board, ss); }
else if (cmd == "quit") { break; }
//non uci
else if (cmd == "perft") { handle_perft(board);}
else if (cmd == "bench") { int d; if (!(ss >> d)) d = 10; handle_bench(d); }
else if (cmd == "eval") { acc_idx = 0; acc_refresh(board, acc_stack[0]); std::cout << eval(board) << std::endl; }
else if (cmd == "datagen") {
int games = 1000; int64_t nodes = 5000; std::string out = "data.bin"; uint64_t seed = 0;
ss >> games >> nodes >> out >> seed;
handle_datagen(games, nodes, out, seed);
}
}
return 0;
}