-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
78 lines (59 loc) · 1.94 KB
/
Copy pathmain.cpp
File metadata and controls
78 lines (59 loc) · 1.94 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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
#include "src/engine/engine.h"
#include "src/engine/pieces.h"
#include "src/engine/zobrist.h"
#include "src/engine/ttable.h"
#include <iostream>
#include <memory>
#ifdef USE_GUI
#include "src/gui/controller.h"
#endif
#ifdef DEV
#include "test/test.h"
#endif
int main()
{
// --------------------
// Initialization stage
// --------------------
Chessboard::initialize_board_space();
Pieces::initialize_attack_tables();
Zobrist::initialize_zobrist_numbers();
// ....
// -------------
// Testing stage
// -------------
#ifdef DEV
bool test_results = Testing::run_tests();
if (!test_results)
std::abort();
#endif
// ---------------
// Main processing
// ---------------
std::unique_ptr<Board> board = std::make_unique<Board>();
std::unique_ptr<Engine> engine = std::make_unique<Engine>(Engine::Mode::STANDARD);
// An appropriate compilation argument decides whether to use command line or graphic interface
#ifdef USE_GUI
GUI::Textures::load_textures();
std::unique_ptr<GUI::Controller> controller = std::make_unique<GUI::Controller>(board.get(), engine.get());
controller->run();
#else
std::string fen;
while (true) {
std::cout << "Enter position FEN and depth:\n";
std::cout << ">>> ";
std::getline(std::cin, fen);
if (fen.empty()) break;
int depth;
std::cout << ">>> ";
std::cin >> depth;
std::cin.get();
engine->set_position(fen);
auto [score, best_move] = engine->evaluate(Search::Depth(depth));
std::cout << "\n---------- Search results (depth " << depth << ") ----------\n";
std::cout << "- Best move: " << best_move << "\n" << std::dec;
std::cout << "- Evaluation: " << (score >= 0 ? "+" : "") << (float(score) / 100.f) << "\n\n";
}
#endif
return 0;
}