-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathChessEngine.cpp
41 lines (32 loc) · 985 Bytes
/
ChessEngine.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
#include <string>
#include <utility>
#include <array>
#include "ChessEngine.hpp"
#include "Player.hpp"
namespace chesslib {
ChessEngine::ChessEngine() = default;
ChessEngine::ChessEngine(ChessEngine&&) = default;
ChessEngine& ChessEngine::operator=(ChessEngine&&) = default;
void ChessEngine::addBlackPlayer(Player *p) {
this->p_black = p;
}
void ChessEngine::addWhitePlayer(Player *p) {
this->p_white = p;
}
void ChessEngine::start() {
std::array<std::pair<PlayerType, Player*>, 2> players = {
std::make_pair(PLAYER_WHITE, this->p_white),
std::make_pair(PLAYER_BLACK, this->p_black),
};
while (true) {
for (const auto & player_pair : players) {
std::string move = player_pair.second->getNextMove(
this->board,
player_pair.first
);
this->board.handleMove(player_pair.first, move);
}
this->board.incrementTurnCount();
}
}
} // namespace chesslib