-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbenchmark.cpp
More file actions
55 lines (44 loc) · 1.42 KB
/
benchmark.cpp
File metadata and controls
55 lines (44 loc) · 1.42 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
#define DEBUG_MODE
#include <array>
#include <fstream>
#include <iostream>
#include <vector>
#include "headers/system.hpp"
#include "headers/rng.hpp"
#include "chess/chess.hpp"
using namespace std;
using namespace chess;
//MAIN
int main() {
cout << "START PROGRAM" << endl;
cout << "Hardware concurrency: " << thread::hardware_concurrency() << '\n';
rng_init(0);
ChessBoard board;
board.default_setup();
bool white_turn = true;
cout << "FINISH SETUP" << endl;
const int N = 20;
double t_tot = 0;
int mov_tot = 0;
for (int i = 0; i < N; i++) {
board.print_board();
board.print_pcs();
double t0 = time();
move_score_t best_mps = board.get_best_move_concurrent(white_turn, 4);
double t = time();
cout << best_mps << " computed in " << t-t0 << '\n';
t_tot += t-t0;
mov_tot += board.get_all_moves(white_turn).size();
if (best_mps.is_invalid()) {return 0;}
const auto& [move, score] = best_mps;
const auto& [piece, pos] = move;
ChessPiece* captpiece = board.grid[pos.x][pos.y];
if (captpiece) {board.rem_piece(*captpiece);}
board.move_piece(*piece, pos.x, pos.y);
white_turn = !white_turn;
cout << '\n';
}
cout << "Average time per move: " << t_tot/N << endl;
cout << "Average time per possibility (1st order approximation): " << t_tot/mov_tot << endl;
return 0;
}