-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.cpp
executable file
·80 lines (64 loc) · 2.16 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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
#include <cstdio>
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <sstream>
#include <iomanip>
#include <cmath>
#include <cstdlib>
#include <ctype.h>
#include <cstring>
#include <ctime>
using namespace std;
#include "Position.h"
#include "Engine.h"
int main(int argc, char **argv) {
if(argc != 3) {
printf("Usage: [FEN notation] [DIFFICULTY: 0-3]\n");
return 1;
}
int aux = atoi(argv[2]);
if(aux < 0 || aux > 3) {
printf("The difficulty should be in [0, 3]\n");
return 1;
}
difficulty_t difficulty = (difficulty_t)aux;
string FEN(argv[1]);
Position pos(FEN);
clock_t start;
clock_t end;
start = clock();
Engine e(difficulty, 1 << 20);
e.loadOpeningBook("geobot_opening_book.txt");
end = clock();
//cout << "Initialized engine in: " << fixed << setprecision(2) << (double)(end - start) / CLOCKS_PER_SEC << endl;
start = clock();
pair<Move, pair<double, int> > res = e.getBestMove(&pos);
end = clock();
cout << res.first.toString() << endl;
FILE *log = fopen("log.txt", "a");
if(log == NULL) {
printf("Can't open log file!\n");
return 1;
}
fprintf(log, "%s => ", argv[1]);
if(res.second.first == BOOK_MOVE)
fprintf(log, "(BM) ");
else
fprintf(log, "(%.2lf, D=%d) ", res.second.first, res.second.second);
fprintf(log, "%s\n", res.first.toString().c_str());
fclose(log);
//cout << "Score: " << fixed << setprecision(2) << res.second << endl;
//cout << "Time: " << fixed << setprecision(2) << (double)(end - start) / CLOCKS_PER_SEC << endl;
//cout << "Evaluated nodes: " << Engine::evaluatedNodes << endl;
//cout << "Speed: " << fixed << setprecision(2) << Engine::evaluatedNodes / ((double)(end - start) / CLOCKS_PER_SEC)
// << " nodes / second"<< endl;
//cout << "Found in hash table: " << Engine::totalFound << endl;
//cout << "Collisions in hash table: " << Engine::totalCollisions << endl;
return 0;
}