fixed warnings
This commit is contained in:
parent
62a35ecafd
commit
4eae988999
@ -46,31 +46,32 @@ namespace ai {
|
||||
|
||||
class v2_alpha_beta : public AI {
|
||||
// looks two moves ahead, with alpha-beta pruning (no move ordering)
|
||||
int _search(const Board&, int, int, int);
|
||||
virtual int _search(const Board&, int, int, int);
|
||||
|
||||
public:
|
||||
v2_alpha_beta(bool w, std::chrono::milliseconds tt): AI(w, tt) {}
|
||||
|
||||
Move _search(const Board&) override;
|
||||
int eval(const Board&) override;
|
||||
virtual Move _search(const Board&) override;
|
||||
virtual int eval(const Board&) override;
|
||||
};
|
||||
|
||||
class v3_AB_ordering : public AI {
|
||||
// looks two moves ahead, with alpha-beta pruning, with move ordering
|
||||
virtual int _search(const Board&, int, int, int);
|
||||
virtual int _ab_search(const Board&, int, int, int);
|
||||
|
||||
public:
|
||||
v3_AB_ordering(bool w, std::chrono::milliseconds tt): AI(w, tt) {}
|
||||
|
||||
Move _search(const Board&) override;
|
||||
int eval(const Board&) override;
|
||||
virtual Move _search(const Board&) override;
|
||||
virtual int eval(const Board&) override;
|
||||
};
|
||||
|
||||
class v4_search_captures : public v3_AB_ordering {
|
||||
protected:
|
||||
// same as v3, but looking at only at captures when leaf is reached,
|
||||
// until no captures are left
|
||||
int _search(const Board&, int, int, int) override;
|
||||
int _search_captures(const Board&, int, int);
|
||||
virtual int _ab_search(const Board&, int, int, int) override;
|
||||
virtual int _search_captures(const Board&, int, int);
|
||||
|
||||
public:
|
||||
v4_search_captures(bool w, std::chrono::milliseconds tt)
|
||||
@ -85,6 +86,7 @@ namespace ai {
|
||||
v5_better_endgame(bool w, std::chrono::milliseconds tt)
|
||||
: v4_search_captures(w, tt) {}
|
||||
|
||||
int eval(const Board&) override;
|
||||
virtual int eval(const Board&) override;
|
||||
};
|
||||
};
|
||||
} // namespace ai
|
||||
|
@ -25,9 +25,11 @@ Move ai::v3_AB_ordering::_search(const Board& b) {
|
||||
std::map<Move, std::future<int>> futures;
|
||||
for (const Move& move : moves) {
|
||||
Board tmp_board = b.make_move(move);
|
||||
futures.insert({move, pool.enqueue([&, tmp_board]() {
|
||||
return _search(tmp_board, 3, -INFINITY, INFINITY);
|
||||
})});
|
||||
futures.insert(
|
||||
{move, pool.enqueue([&, tmp_board]() {
|
||||
return _ab_search(tmp_board, 3, -INFINITY, INFINITY);
|
||||
})}
|
||||
);
|
||||
}
|
||||
|
||||
int counter = 0;
|
||||
@ -58,7 +60,7 @@ Move ai::v3_AB_ordering::_search(const Board& b) {
|
||||
return best_move;
|
||||
}
|
||||
|
||||
int ai::v3_AB_ordering::_search(
|
||||
int ai::v3_AB_ordering::_ab_search(
|
||||
const Board& b, int depth, int alpha, int beta
|
||||
) {
|
||||
if (depth == 0 || stop_computation)
|
||||
@ -78,7 +80,7 @@ int ai::v3_AB_ordering::_search(
|
||||
Move best_move;
|
||||
for (const Move& move : moves) {
|
||||
Board tmp_board = b.make_move(move);
|
||||
int tmp_eval = -_search(tmp_board, depth - 1, -beta, -alpha);
|
||||
int tmp_eval = -_ab_search(tmp_board, depth - 1, -beta, -alpha);
|
||||
if (tmp_eval >= beta)
|
||||
return beta;
|
||||
alpha = std::max(alpha, tmp_eval);
|
||||
|
@ -9,7 +9,7 @@
|
||||
|
||||
static int position_counter;
|
||||
|
||||
int ai::v4_search_captures::_search(
|
||||
int ai::v4_search_captures::_ab_search(
|
||||
const Board& b, int depth, int alpha, int beta
|
||||
) {
|
||||
if (depth == 0 || stop_computation)
|
||||
@ -29,7 +29,7 @@ int ai::v4_search_captures::_search(
|
||||
Move best_move;
|
||||
for (const Move& move : moves) {
|
||||
Board tmp_board = b.make_move(move);
|
||||
int tmp_eval = -_search(tmp_board, depth - 1, -beta, -alpha);
|
||||
int tmp_eval = -_ab_search(tmp_board, depth - 1, -beta, -alpha);
|
||||
if (tmp_eval >= beta)
|
||||
return beta;
|
||||
alpha = std::max(alpha, tmp_eval);
|
||||
|
Loading…
x
Reference in New Issue
Block a user