-
Notifications
You must be signed in to change notification settings - Fork 0
/
FromXboardToEngine.cpp
81 lines (72 loc) · 1.95 KB
/
FromXboardToEngine.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
// Zugzwang Chess Engine - stage 2
#include "FromXboardToEngine.h"
// Start engine.
void FromXboardtoEngine::xboardCommand(void) {
XBOARD_MODE = true;
}
// Initialize board, white moves, set engine to play black.
// Reset and stop clocks.
void FromXboardtoEngine::newCommand(void) {
ChessBoard::initializeBitboard();
WHITE_MOVING = true;
BLACK_MOVING = false;
WHITE_MODE = false;
BLACK_MODE = true;
FORCE_MODE = false;
//whiteMove.resetTimer();
//blackMove.resetTimer();
}
// Exit program.
void FromXboardtoEngine::quitCommand(void) {
ChessBoard::deleteTable();
exit(0);
}
// Set the engine to play neither color. Stop clocks.
void FromXboardtoEngine::forceCommand(void) {
FORCE_MODE = true;
WHITE_MODE = false;
BLACK_MODE = false;
//whiteMove.stopTimer();
//blackMove.stopTimer();
}
// Play color that is on the move. Associate the engine's clock with the color
// that is on move, the opponent's clock with the color that is not on move.
// Start the engine's clock.
void FromXboardtoEngine::goCommand(void) {
FORCE_MODE = false;
if (WHITE_MOVING) {
WHITE_MODE = true;
BLACK_MODE = false;
//whiteMove.startTimer();
} else {
WHITE_MODE = false;
BLACK_MODE = true;
//blackMove.startTimer();
}
}
// Set White on move. Set the engine to play Black. Stop clocks.
void FromXboardtoEngine::whiteCommand(void) {
WHITE_MOVING = true;
BLACK_MOVING = false;
WHITE_MODE = false;
BLACK_MODE = true;
//whiteMove.stopTimer();
//blackMove.stopTimer();
}
// Set Black on move. Set the engine to play White. Stop clocks.
void FromXboardtoEngine::blackCommand(void) {
WHITE_MOVING = false;
BLACK_MOVING = true;
WHITE_MODE = true;
BLACK_MODE = false;
//whiteMove.stopTimer();
//blackMove.stopTimer();
}
// Update board with opponent's move. Set engine on move.
void FromXboardtoEngine::moveCommand(char* command) {
//if (!FORCE_MODE) {
ChessBoard::updateOpponentMove(command, WHITE_MODE);
//}
WHITE_MOVING = !WHITE_MOVING;
BLACK_MOVING = !BLACK_MOVING;
}