-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
44 lines (42 loc) · 1.38 KB
/
main.cpp
File metadata and controls
44 lines (42 loc) · 1.38 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
#include "Board.h"
#include "uci.h"
#include <string>
#include <cstring>
#include <chrono>
using namespace std;
int main(int argc, char* argv[]) {
if(argc > 1) {
Board b;
b.setupGameFromFEN("rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1");
for(int i = 0; i < argc; i++) {
if(strcmp(argv[i], "--perft") == 0) {
if(i == argc-1) {
cout << "--perft expects a numbers.\n";
return 12;
}
auto t1 = chrono::high_resolution_clock::now();
int maxDepth = atoi(argv[i+1]);
for(int depth = 1; depth <= maxDepth; depth++) {
cout << b.perft2(depth, true) << "\n";
}
auto t2 = chrono::high_resolution_clock::now();
cout << "Time taken: ";
cout << chrono::duration_cast<chrono::milliseconds>(t2-t1).count() << "\n";
} else if(strcmp(argv[i], "--play") == 0) {
string move;
while(true) {
b.printGame();
cout << "Enter move: ";
cin >> move;
if(!b.play(move)) {
cout << "Invalid Move\n";
}
}
}
}
} else {
UCI uci;
uci.uciLoop();
}
return 0;
}