Removed the python version and kept just the c++ one
This commit is contained in:
29
src/controller/human_vs_ai.cpp
Normal file
29
src/controller/human_vs_ai.cpp
Normal file
@ -0,0 +1,29 @@
|
||||
#include "human_vs_ai.hpp"
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
HumanVsAIController::HumanVsAIController(Board b, View& v, ai::AI& ai)
|
||||
: ManualController(b, v),
|
||||
ai(ai) {}
|
||||
|
||||
void HumanVsAIController::on_tile_selected(int x, int y) {
|
||||
Coords c{x, y};
|
||||
Piece piece = board.piece_at(c);
|
||||
|
||||
if (selected_index == -1
|
||||
|| (piece != Piece::None && piece != selected_piece
|
||||
&& (piece & 0b11000) != (selected_piece & 0b11000))) {
|
||||
show_legal_moves(c);
|
||||
} else {
|
||||
auto boh = std::find(targets.begin(), targets.end(), c.to_index());
|
||||
if (boh != targets.end()) {
|
||||
make_move(Move{selected_index, c.to_index()});
|
||||
|
||||
if (board.is_terminal())
|
||||
return;
|
||||
Move ai_move = ai.search(board);
|
||||
make_move(ai_move);
|
||||
} else
|
||||
reset_selection();
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user