-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbenchmark.cpp
executable file
·96 lines (77 loc) · 2.15 KB
/
benchmark.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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
/**********************************************************************
|
| Bogart
| Chess Engine
|
| Copyright (C) 2009-2013 Dr.Kameleon
|
|**********************************************************************
| benchmark.cpp
|**********************************************************************/
#include "bogart.h"
//=======================================================
// Constructors
//=======================================================
Benchmark::Benchmark(Board* b)
{
this->board = b;
/*
this->board->debug();
cout << "KEY : " << this->board->key << endl;
Move m = Move("e2e4",this->board);
MAKE(m,this->board);
HASHUNHASH(m,this->board);
this->board->debug();
cout << "KEY : " << this->board->key << endl;
UNMAKE(m,this->board);
HASHUNHASH(m,this->board);
this->board->debug();
cout << "KEY : " << this->board->key << endl;
cout << "--------------" << endl;*/
cout << BENCH_HEADER("Benchmark");
cout << BENCH_SUBHEADER("Board");
this->board->debug();
cout << BENCH_SUBHEADER("Result");
}
//=======================================================
// Functions
//=======================================================
void Benchmark::perft(UINT depth, BOOL loop)
{
int start = (loop)? 1 : depth;
for (int i=start; i<=depth; i++)
{
Timer *timer = new Timer();
UINT result = this->board->countNodes(0,i);
cout << "Perft(" << i << ") = " << left << setw(20) << result << "(" << (timer->timeElapsed()/1000) << "s)" << endl;
}
cout << endl;
}
void Benchmark::eval(UINT depth, BOOL loop)
{
this->board->kingTropism();
int start = (loop)? 1 : depth;
for (int i=start; i<=depth; i++)
{
Timer *timer = new Timer();
Move result = this->board->search(AlphaBetaPvs,i);
cout << "Eval(" << i << ") = " << left << setw(20) << result.out() << "(" << (timer->timeElapsed()/1000) << "s)" << endl;
}
cout << endl;
}
void Benchmark::generate()
{
vector<Move> moves;
this->board->possibleMoves(moves);
int cnt=0;
FOREACH(Move,move,moves)
{
MAKE((*move),this->board);
if (!this->board->isKingAttacked())
{
cout << ++cnt << "\t: " << (*move).notation() << endl;
}
UNMAKE((*move),this->board);
}
cout << endl;
}