From: Fabian Fichter Date: Sat, 1 Dec 2018 14:34:51 +0000 (+0100) Subject: Add a simple evaluation for connect-n games X-Git-Url: http://winboard.nl/cgi-bin?a=commitdiff_plain;h=9c2184b02cd58b72e363cce0cd490017cd6cda44;p=fairystockfish.git Add a simple evaluation for connect-n games connect4 LLR: 2.98 (-2.94,2.94) [0.00,10.00] Total: 144 W: 92 L: 15 D: 37 --- diff --git a/src/evaluate.cpp b/src/evaluate.cpp index 12896ea..1b69905 100644 --- a/src/evaluate.cpp +++ b/src/evaluate.cpp @@ -853,6 +853,28 @@ namespace { score += make_score(3000, 1000) / (remainingChecks * remainingChecks); } + // Connect-n + if (pos.connect_n() > 0) + { + for (Direction d : {NORTH, NORTH_EAST, EAST, SOUTH_EAST, SOUTH, SOUTH_WEST, WEST, NORTH_WEST}) + { + // Bonus for uninterrupted rows + Bitboard b = pos.pieces(Us); + for (int i = 1; i < pos.connect_n() && b; i++) + { + score += make_score(100, 100) * popcount(b) * i * i / (pos.connect_n() - i); + b &= shift(-d, shift(d, shift(d, b)) & ~pos.pieces(Them) & pos.board_bb()); + } + // Bonus for rows containing holes + b = pos.pieces(Us); + for (int i = 1; i < pos.connect_n() && b; i++) + { + score += make_score(50, 50) * popcount(b) * i * i / (pos.connect_n() - i); + b &= shift(-d, shift(d, shift(d, b)) & ~pos.pieces(Them) & pos.board_bb()) | shift(d, shift(d, b) & ~pos.pieces()); + } + } + } + if (T) Trace::add(VARIANT, Us, score); @@ -868,7 +890,7 @@ namespace { Score Evaluation::initiative(Value eg) const { // No initiative bonus for extinction variants - if (pos.extinction_value() != VALUE_NONE || pos.captures_to_hand()) + if (pos.extinction_value() != VALUE_NONE || pos.captures_to_hand() || pos.connect_n()) return SCORE_ZERO; int outflanking = !pos.count(WHITE) || !pos.count(BLACK) ? 0