From 97f6e15806c0b56c0fc2e5804b5b1cd00b396aa6 Mon Sep 17 00:00:00 2001 From: ianfab Date: Tue, 28 Mar 2017 15:07:03 +0200 Subject: [PATCH 01/24] Tweak imbalance parameters for horde chess STC LLR: 2.96 (-2.94,2.94) [0.00,10.00] Total: 9153 W: 4628 L: 4395 D: 130 http://35.161.250.236:6543/tests/view/58da603b6e23db2fa8080e56 LTC LLR: 2.97 (-2.94,2.94) [0.00,10.00] Total: 4349 W: 2222 L: 2058 D: 69 http://35.161.250.236:6543/tests/view/58da9e856e23db2fa8080e59 --- src/material.cpp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/material.cpp b/src/material.cpp index ae3b23b2..523c2dd2 100644 --- a/src/material.cpp +++ b/src/material.cpp @@ -83,13 +83,13 @@ namespace { { // OUR PIECES // pair pawn knight bishop rook queen king - { 0 }, // Bishop pair - { 0, 0 }, // Pawn - { 0, 0, 0 }, // Knight OUR PIECES - { 0, 0, 0, 0 }, // Bishop - { 0, 0, 0, 0, 0 }, // Rook - { 0, 0, 0, 0, 0, 0 }, // Queen - { 0, 0, 0, 0, 0, 0, 0 } // King + { 13 }, // Bishop pair + { -2, 0 }, // Pawn + { -65, 66, 15 }, // Knight OUR PIECES + { 0, 81, -2, 0 }, // Bishop + { 26, 21, -38, 80, -70 }, // Rook + { 24, -27, 75, 32, 2, -70 }, // Queen + { 0, 0, 0, 0, 0, 0, 0 } // King }, #endif #ifdef KOTH @@ -212,7 +212,7 @@ namespace { { 0, 0, 0, 0 }, // Bishop { 0, 0, 0, 0, 0 }, // Rook { 0, 0, 0, 0, 0, 0 }, // Queen - { 0, -789, -872, -19, -416, -594, 0 } // King + { 0, -557, -711, -86, -386, -655, 0 } // King }, #endif #ifdef KOTH From 87e0a96e3b358dedde1c9941b79b3e7ac3019c91 Mon Sep 17 00:00:00 2001 From: Daniel Dugovic Date: Sun, 5 Mar 2017 04:02:12 -0600 Subject: [PATCH 02/24] Evaluate material imbalance for pieces in hand --- src/material.cpp | 46 +++++++++++++++++++++++++++++++++++++++++++++- src/position.h | 4 ++++ 2 files changed, 49 insertions(+), 1 deletion(-) diff --git a/src/material.cpp b/src/material.cpp index 523c2dd2..6bbacab7 100644 --- a/src/material.cpp +++ b/src/material.cpp @@ -153,6 +153,18 @@ namespace { }, #endif }; +#ifdef CRAZYHOUSE + const int QuadraticOursInHand[PIECE_TYPE_NB][PIECE_TYPE_NB] = { + // OUR PIECES + // pair pawn knight bishop rook queen + { 11 }, // Bishop pair + { -49, -27 }, // Pawn + { 13, -20, 10 }, // Knight OUR PIECES + { -15, -4, 42, -15 }, // Bishop + { 50, -15, 10, 0, 25 }, // Rook + { 30, 50, 15, 19, 16, -9 } // Queen + }; +#endif const int QuadraticTheirs[VARIANT_NB][PIECE_TYPE_NB][PIECE_TYPE_NB] = { { @@ -276,6 +288,18 @@ namespace { }, #endif }; +#ifdef CRAZYHOUSE + const int QuadraticTheirsInHand[PIECE_TYPE_NB][PIECE_TYPE_NB] = { + // THEIR PIECES + // pair pawn knight bishop rook queen + { -12 }, // Bishop pair + { 13, -3 }, // Pawn + { 20, 33, 0 }, // Knight OUR PIECES + { 15, 12, -25, -30 }, // Bishop + { 27, 2, -37, -1, -10 }, // Rook + { 23, -14, -25, -11, -15, -10 } // Queen + }; +#endif // PawnsSet[count] contains a bonus/malus indexed by number of pawns const int PawnsSet[FILE_NB + 1] = { @@ -324,7 +348,12 @@ namespace { /// imbalance() calculates the imbalance by comparing the piece count of each /// piece type for both colors. template +#ifdef CRAZYHOUSE + int imbalance(const Position& pos, const int pieceCount[][PIECE_TYPE_NB], + const int pieceCountInHand[][PIECE_TYPE_NB]) { +#else int imbalance(const Position& pos, const int pieceCount[][PIECE_TYPE_NB]) { +#endif const Color Them = (Us == WHITE ? BLACK : WHITE); @@ -348,8 +377,14 @@ namespace { int v = 0; for (int pt2 = NO_PIECE_TYPE; pt2 <= pt1; ++pt2) + { v += QuadraticOurs[pos.variant()][pt1][pt2] * pieceCount[Us][pt2] + QuadraticTheirs[pos.variant()][pt1][pt2] * pieceCount[Them][pt2]; +#ifdef CRAZYHOUSE + v += QuadraticOursInHand[pt1][pt2] * pieceCountInHand[Us][pt2] + + QuadraticTheirsInHand[pt1][pt2] * pieceCountInHand[Them][pt2]; +#endif + } bonus += pieceCount[Us][pt1] * v; } @@ -491,8 +526,17 @@ Entry* probe(const Position& pos) { pos.count(WHITE) , pos.count(WHITE), pos.count(WHITE), pos.count(WHITE) }, { pos.count(BLACK) > 1, pos.count(BLACK), pos.count(BLACK), pos.count(BLACK) , pos.count(BLACK), pos.count(BLACK), pos.count(BLACK) } }; - +#ifdef CRAZYHOUSE + const int PieceCountInHand[COLOR_NB][PIECE_TYPE_NB] = { + { pos.count_in_hand(WHITE) > 1, pos.count_in_hand(WHITE), pos.count_in_hand(WHITE), + pos.count_in_hand(WHITE) , pos.count_in_hand(WHITE), pos.count_in_hand(WHITE), pos.count_in_hand(WHITE) }, + { pos.count_in_hand(BLACK) > 1, pos.count_in_hand(BLACK), pos.count_in_hand(BLACK), + pos.count_in_hand(BLACK) , pos.count_in_hand(BLACK), pos.count_in_hand(BLACK), pos.count_in_hand(BLACK) } }; + + e->value = int16_t((imbalance(pos, PieceCount, PieceCountInHand) - imbalance(pos, PieceCount, PieceCountInHand)) / 16); +#else e->value = int16_t((imbalance(pos, PieceCount) - imbalance(pos, PieceCount)) / 16); +#endif return e; } diff --git a/src/position.h b/src/position.h index 9edd68bc..8b44cff9 100644 --- a/src/position.h +++ b/src/position.h @@ -186,6 +186,7 @@ class Position { #endif #ifdef CRAZYHOUSE bool is_house() const; + template int count_in_hand(Color c) const; int count_in_hand(Color c, PieceType pt) const; void add_to_hand(Color c, PieceType pt); void remove_from_hand(Color c, PieceType pt); @@ -640,6 +641,9 @@ inline bool Position::is_house() const { return var == CRAZYHOUSE_VARIANT; } +template inline int Position::count_in_hand(Color c) const { + return pieceCountInHand[c][Pt]; +} inline int Position::count_in_hand(Color c, PieceType pt) const { return pieceCountInHand[c][pt]; } From 9a7fb32f0191ba3e54a0f9578c7bbdf731197874 Mon Sep 17 00:00:00 2001 From: Isaac Levy Date: Tue, 7 Mar 2017 23:26:12 -0500 Subject: [PATCH 03/24] Update material.cpp fix covariant math --- src/material.cpp | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/src/material.cpp b/src/material.cpp index 6bbacab7..1e4f1f7b 100644 --- a/src/material.cpp +++ b/src/material.cpp @@ -375,19 +375,28 @@ namespace { continue; int v = 0; - for (int pt2 = NO_PIECE_TYPE; pt2 <= pt1; ++pt2) { v += QuadraticOurs[pos.variant()][pt1][pt2] * pieceCount[Us][pt2] + QuadraticTheirs[pos.variant()][pt1][pt2] * pieceCount[Them][pt2]; + } + bonus += pieceCount[Us][pt1] * v; + } #ifdef CRAZYHOUSE + for (int pt1 = NO_PIECE_TYPE; pt1 <= pt_max; ++pt1) + { + if (!pieceCountInHand[Us][pt1]) + continue; + + int v = 0; + for (int pt2 = NO_PIECE_TYPE; pt2 <= pt1; ++pt2) + { v += QuadraticOursInHand[pt1][pt2] * pieceCountInHand[Us][pt2] + QuadraticTheirsInHand[pt1][pt2] * pieceCountInHand[Them][pt2]; -#endif } - - bonus += pieceCount[Us][pt1] * v; + bonus += pieceCountInHand[Us][pt1] * v; } +#endif return bonus; } From 7b0ccda3cbf12b7fb8bb9bf14e824617d78d4f29 Mon Sep 17 00:00:00 2001 From: Daniel Dugovic Date: Sat, 11 Mar 2017 10:07:47 -0600 Subject: [PATCH 04/24] Tune material imbalance for pieces in hand --- src/material.cpp | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/src/material.cpp b/src/material.cpp index 1e4f1f7b..937d03d7 100644 --- a/src/material.cpp +++ b/src/material.cpp @@ -157,12 +157,12 @@ namespace { const int QuadraticOursInHand[PIECE_TYPE_NB][PIECE_TYPE_NB] = { // OUR PIECES // pair pawn knight bishop rook queen - { 11 }, // Bishop pair - { -49, -27 }, // Pawn - { 13, -20, 10 }, // Knight OUR PIECES - { -15, -4, 42, -15 }, // Bishop - { 50, -15, 10, 0, 25 }, // Rook - { 30, 50, 15, 19, 16, -9 } // Queen + { -20 }, // Bishop pair + { 3, -40 }, // Pawn + { -30, -1, 19 }, // Knight OUR PIECES + { 11, -41, -8, -6 }, // Bishop + { -29, -5, 0, -13, -21 }, // Rook + { -8, -28, 17, -9, 7, 3 } // Queen }; #endif @@ -292,12 +292,12 @@ namespace { const int QuadraticTheirsInHand[PIECE_TYPE_NB][PIECE_TYPE_NB] = { // THEIR PIECES // pair pawn knight bishop rook queen - { -12 }, // Bishop pair - { 13, -3 }, // Pawn - { 20, 33, 0 }, // Knight OUR PIECES - { 15, 12, -25, -30 }, // Bishop - { 27, 2, -37, -1, -10 }, // Rook - { 23, -14, -25, -11, -15, -10 } // Queen + { -4 }, // Bishop pair + { -1, -11 }, // Pawn + { 16, 23, 20 }, // Knight OUR PIECES + { -2, 12, 8, 27 }, // Bishop + { -33, 24, -11, 13, -20 }, // Rook + { -25, 14, -22, -6, 5, 40 } // Queen }; #endif From 422bf75166f850fdb755636f36f0aa1d78680ff0 Mon Sep 17 00:00:00 2001 From: Daniel Dugovic Date: Sat, 11 Mar 2017 10:12:55 -0600 Subject: [PATCH 05/24] Tidy/format with respect to current master --- src/material.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/material.cpp b/src/material.cpp index 937d03d7..73ce4991 100644 --- a/src/material.cpp +++ b/src/material.cpp @@ -375,11 +375,11 @@ namespace { continue; int v = 0; + for (int pt2 = NO_PIECE_TYPE; pt2 <= pt1; ++pt2) - { v += QuadraticOurs[pos.variant()][pt1][pt2] * pieceCount[Us][pt2] + QuadraticTheirs[pos.variant()][pt1][pt2] * pieceCount[Them][pt2]; - } + bonus += pieceCount[Us][pt1] * v; } #ifdef CRAZYHOUSE @@ -389,11 +389,11 @@ namespace { continue; int v = 0; + for (int pt2 = NO_PIECE_TYPE; pt2 <= pt1; ++pt2) - { v += QuadraticOursInHand[pt1][pt2] * pieceCountInHand[Us][pt2] + QuadraticTheirsInHand[pt1][pt2] * pieceCountInHand[Them][pt2]; - } + bonus += pieceCountInHand[Us][pt1] * v; } #endif From 6c1e01bf7a7f458ed1767daa006efc7904ced926 Mon Sep 17 00:00:00 2001 From: Daniel Dugovic Date: Wed, 22 Mar 2017 19:02:45 -0500 Subject: [PATCH 06/24] Add empty hand malus (replacing bishop pair hand) --- src/material.cpp | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/src/material.cpp b/src/material.cpp index 73ce4991..862b6bd0 100644 --- a/src/material.cpp +++ b/src/material.cpp @@ -157,12 +157,12 @@ namespace { const int QuadraticOursInHand[PIECE_TYPE_NB][PIECE_TYPE_NB] = { // OUR PIECES // pair pawn knight bishop rook queen - { -20 }, // Bishop pair - { 3, -40 }, // Pawn - { -30, -1, 19 }, // Knight OUR PIECES - { 11, -41, -8, -6 }, // Bishop - { -29, -5, 0, -13, -21 }, // Rook - { -8, -28, 17, -9, 7, 3 } // Queen + { -4 }, // Empty hand + { -20, -65 }, // Pawn + { -43, -15, 0 }, // Knight OUR PIECES + { -1, -51, 41, -51 }, // Bishop + { -38, -16, 21, -25, -12 }, // Rook + { -8, 7, -8, -12, -40, -23 } // Queen }; #endif @@ -292,12 +292,12 @@ namespace { const int QuadraticTheirsInHand[PIECE_TYPE_NB][PIECE_TYPE_NB] = { // THEIR PIECES // pair pawn knight bishop rook queen - { -4 }, // Bishop pair - { -1, -11 }, // Pawn - { 16, 23, 20 }, // Knight OUR PIECES - { -2, 12, 8, 27 }, // Bishop - { -33, 24, -11, 13, -20 }, // Rook - { -25, 14, -22, -6, 5, 40 } // Queen + { 37 }, // Empty hand + { -7, -38 }, // Pawn + { -29, 28, -11 }, // Knight OUR PIECES + { 25, 27, -3, 27 }, // Bishop + { -45, 24, 1, -6, 4 }, // Rook + { -31, 15, 17, -10, -8, 31 } // Queen }; #endif @@ -537,10 +537,10 @@ Entry* probe(const Position& pos) { pos.count(BLACK) , pos.count(BLACK), pos.count(BLACK), pos.count(BLACK) } }; #ifdef CRAZYHOUSE const int PieceCountInHand[COLOR_NB][PIECE_TYPE_NB] = { - { pos.count_in_hand(WHITE) > 1, pos.count_in_hand(WHITE), pos.count_in_hand(WHITE), - pos.count_in_hand(WHITE) , pos.count_in_hand(WHITE), pos.count_in_hand(WHITE), pos.count_in_hand(WHITE) }, - { pos.count_in_hand(BLACK) > 1, pos.count_in_hand(BLACK), pos.count_in_hand(BLACK), - pos.count_in_hand(BLACK) , pos.count_in_hand(BLACK), pos.count_in_hand(BLACK), pos.count_in_hand(BLACK) } }; + { pos.count_in_hand(WHITE) > 1, pos.count_in_hand(WHITE), pos.count_in_hand(WHITE), + pos.count_in_hand(WHITE) , pos.count_in_hand(WHITE), pos.count_in_hand(WHITE), pos.count_in_hand(WHITE) }, + { pos.count_in_hand(BLACK) > 1, pos.count_in_hand(BLACK), pos.count_in_hand(BLACK), + pos.count_in_hand(BLACK) , pos.count_in_hand(BLACK), pos.count_in_hand(BLACK), pos.count_in_hand(BLACK) } }; e->value = int16_t((imbalance(pos, PieceCount, PieceCountInHand) - imbalance(pos, PieceCount, PieceCountInHand)) / 16); #else From 7815f26721cd63994d04c6fc5a5c8cc8275ad497 Mon Sep 17 00:00:00 2001 From: Daniel Dugovic Date: Thu, 23 Mar 2017 02:15:37 -0500 Subject: [PATCH 07/24] Fix empty hand condition #265 --- src/material.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/material.cpp b/src/material.cpp index 862b6bd0..c5ac9a01 100644 --- a/src/material.cpp +++ b/src/material.cpp @@ -537,10 +537,10 @@ Entry* probe(const Position& pos) { pos.count(BLACK) , pos.count(BLACK), pos.count(BLACK), pos.count(BLACK) } }; #ifdef CRAZYHOUSE const int PieceCountInHand[COLOR_NB][PIECE_TYPE_NB] = { - { pos.count_in_hand(WHITE) > 1, pos.count_in_hand(WHITE), pos.count_in_hand(WHITE), - pos.count_in_hand(WHITE) , pos.count_in_hand(WHITE), pos.count_in_hand(WHITE), pos.count_in_hand(WHITE) }, - { pos.count_in_hand(BLACK) > 1, pos.count_in_hand(BLACK), pos.count_in_hand(BLACK), - pos.count_in_hand(BLACK) , pos.count_in_hand(BLACK), pos.count_in_hand(BLACK), pos.count_in_hand(BLACK) } }; + { pos.count_in_hand(WHITE) == 0, pos.count_in_hand(WHITE), pos.count_in_hand(WHITE), + pos.count_in_hand(WHITE) , pos.count_in_hand(WHITE), pos.count_in_hand(WHITE), pos.count_in_hand(WHITE) }, + { pos.count_in_hand(BLACK) == 0, pos.count_in_hand(BLACK), pos.count_in_hand(BLACK), + pos.count_in_hand(BLACK) , pos.count_in_hand(BLACK), pos.count_in_hand(BLACK), pos.count_in_hand(BLACK) } }; e->value = int16_t((imbalance(pos, PieceCount, PieceCountInHand) - imbalance(pos, PieceCount, PieceCountInHand)) / 16); #else From 08c86eb077af4fc1cc90a0269bcced9a593ce6e2 Mon Sep 17 00:00:00 2001 From: Daniel Dugovic Date: Wed, 29 Mar 2017 21:45:22 -0500 Subject: [PATCH 08/24] Add bonuses for count of pieces in hand and checkers in hand #265 STC LLR: 2.95 (-2.94,2.94) [0.00,10.00] Total: 6236 W: 3079 L: 2891 D: 266 http://35.161.250.236:6543/tests/view/58dc72606e23db2fa8080e89 LTC LLR: 2.96 (-2.94,2.94) [0.00,10.00] Total: 1610 W: 824 L: 703 D: 83 http://35.161.250.236:6543/tests/view/58dcfa196e23db2fa8080e8c --- src/evaluate.cpp | 2 +- src/material.cpp | 24 ++++++++++++------------ 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/src/evaluate.cpp b/src/evaluate.cpp index 27463022..fe5e65ce 100644 --- a/src/evaluate.cpp +++ b/src/evaluate.cpp @@ -427,7 +427,7 @@ namespace { #ifdef CRAZYHOUSE const int KingDangerInHand[PIECE_TYPE_NB] = { - 0, 128, 128, 28, 69, 75 + 0, 134, 199, 37, 100, 110 }; #endif diff --git a/src/material.cpp b/src/material.cpp index c5ac9a01..6f0a2952 100644 --- a/src/material.cpp +++ b/src/material.cpp @@ -157,12 +157,12 @@ namespace { const int QuadraticOursInHand[PIECE_TYPE_NB][PIECE_TYPE_NB] = { // OUR PIECES // pair pawn knight bishop rook queen - { -4 }, // Empty hand - { -20, -65 }, // Pawn - { -43, -15, 0 }, // Knight OUR PIECES - { -1, -51, 41, -51 }, // Bishop - { -38, -16, 21, -25, -12 }, // Rook - { -8, 7, -8, -12, -40, -23 } // Queen + { -88 }, // Empty hand + { -29, -44 }, // Pawn + { -33, 33, 21 }, // Knight OUR PIECES + { 8, -52, -16, -6 }, // Bishop + { -95, 14, 44, -54, 19 }, // Rook + { -43, -5, 5, -19, 2, -29 } // Queen }; #endif @@ -292,12 +292,12 @@ namespace { const int QuadraticTheirsInHand[PIECE_TYPE_NB][PIECE_TYPE_NB] = { // THEIR PIECES // pair pawn knight bishop rook queen - { 37 }, // Empty hand - { -7, -38 }, // Pawn - { -29, 28, -11 }, // Knight OUR PIECES - { 25, 27, -3, 27 }, // Bishop - { -45, 24, 1, -6, 4 }, // Rook - { -31, 15, 17, -10, -8, 31 } // Queen + { 6 }, // Empty hand + { -6, -4 }, // Pawn + { 7, 13, 12 }, // Knight OUR PIECES + { -19, 34, -17, 29 }, // Bishop + { -37, -8, -7, 7, -38 }, // Rook + { 1, 16, -25, 32, -3, 29 } // Queen }; #endif From 1d25150ebdd7167b1e0720184652b53e497d41f3 Mon Sep 17 00:00:00 2001 From: ianfab Date: Thu, 30 Mar 2017 21:24:18 +0200 Subject: [PATCH 09/24] Tweak king safety related bonuses for three-check chess STC LLR: 2.96 (-2.94,2.94) [0.00,10.00] Total: 2985 W: 1413 L: 1277 D: 295 http://35.161.250.236:6543/tests/view/58dd5beb6e23db2fa8080e92 LTC LLR: 2.97 (-2.94,2.94) [0.00,10.00] Total: 2977 W: 1390 L: 1255 D: 332 http://35.161.250.236:6543/tests/view/58dd96eb6e23db2fa8080e98 --- src/evaluate.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/evaluate.cpp b/src/evaluate.cpp index fe5e65ce..628f2ac8 100644 --- a/src/evaluate.cpp +++ b/src/evaluate.cpp @@ -382,8 +382,8 @@ namespace { #ifdef THREECHECK const Score ChecksGivenBonus[CHECKS_NB] = { S(0, 0), - S(472, 369), - S(1980, 1159), + S(508, 377), + S(2224, 1000), S(0, 0) }; #endif @@ -488,7 +488,7 @@ namespace { S( 7, 0), #endif #ifdef THREECHECK - S(15, 10), + S(17, 10), #endif }; const Score PawnlessFlank = S( 20, 80); @@ -749,7 +749,7 @@ namespace { 2 * int(BishopValueMg), #endif #ifdef THREECHECK - 4 * int(BishopValueMg), + 3264, #endif }; From c8e359f895a7392bda5098e39c53862db5014979 Mon Sep 17 00:00:00 2001 From: ianfab Date: Fri, 31 Mar 2017 15:55:55 +0200 Subject: [PATCH 10/24] Fix failed assertion in three-check chess No functional change. --- src/position.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/position.cpp b/src/position.cpp index de859540..be1604f3 100644 --- a/src/position.cpp +++ b/src/position.cpp @@ -1754,7 +1754,9 @@ bool Position::see_ge(Move m, Value v) const { #endif #ifdef THREECHECK - if (is_three_check() && gives_check(m)) + if ( is_three_check() + && ( (color_of(moved_piece(m)) == sideToMove && gives_check(m)) + || (st->checkSquares[type_of(moved_piece(m))] & to_sq(m)))) return true; #endif From 5dc22f62b552adf26a91b5b0019d0e70758e902e Mon Sep 17 00:00:00 2001 From: ianfab Date: Fri, 31 Mar 2017 16:32:45 +0200 Subject: [PATCH 11/24] Set unused parameters to zero Some parameters are either unused or added twice with opposite sign, so replace them by zeros. No functional change. --- src/material.cpp | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/src/material.cpp b/src/material.cpp index 6f0a2952..bdc40459 100644 --- a/src/material.cpp +++ b/src/material.cpp @@ -156,13 +156,13 @@ namespace { #ifdef CRAZYHOUSE const int QuadraticOursInHand[PIECE_TYPE_NB][PIECE_TYPE_NB] = { // OUR PIECES - // pair pawn knight bishop rook queen + //empty pawn knight bishop rook queen { -88 }, // Empty hand - { -29, -44 }, // Pawn - { -33, 33, 21 }, // Knight OUR PIECES - { 8, -52, -16, -6 }, // Bishop - { -95, 14, 44, -54, 19 }, // Rook - { -43, -5, 5, -19, 2, -29 } // Queen + { 0, -44 }, // Pawn + { 0, 33, 21 }, // Knight OUR PIECES + { 0, -52, -16, -6 }, // Bishop + { 0, 14, 44, -54, 19 }, // Rook + { 0, -5, 5, -19, 2, -29 } // Queen }; #endif @@ -291,13 +291,13 @@ namespace { #ifdef CRAZYHOUSE const int QuadraticTheirsInHand[PIECE_TYPE_NB][PIECE_TYPE_NB] = { // THEIR PIECES - // pair pawn knight bishop rook queen - { 6 }, // Empty hand - { -6, -4 }, // Pawn - { 7, 13, 12 }, // Knight OUR PIECES - { -19, 34, -17, 29 }, // Bishop - { -37, -8, -7, 7, -38 }, // Rook - { 1, 16, -25, 32, -3, 29 } // Queen + //empty pawn knight bishop rook queen + { 0 }, // Empty hand + { -6, 0 }, // Pawn + { 7, 13, 0 }, // Knight OUR PIECES + { -19, 34, -17, 0 }, // Bishop + { -37, -8, -7, 7, 0 }, // Rook + { 1, 16, -25, 32, -3, 0 } // Queen }; #endif From 8d6cca969116c8717595529877bbc3c1f399aadb Mon Sep 17 00:00:00 2001 From: ianfab Date: Thu, 30 Mar 2017 21:13:58 +0200 Subject: [PATCH 12/24] Tweak king distance bonus for king of the hill STC LLR: 2.96 (-2.94,2.94) [0.00,10.00] Total: 9061 W: 3740 L: 3529 D: 1792 http://35.161.250.236:6543/tests/view/58dd59ce6e23db2fa8080e8f LTC LLR: 2.97 (-2.94,2.94) [0.00,10.00] Total: 2377 W: 957 L: 842 D: 578 http://35.161.250.236:6543/tests/view/58de1d2f6e23db2fa8080e9a --- src/evaluate.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/evaluate.cpp b/src/evaluate.cpp index fe5e65ce..7482db7a 100644 --- a/src/evaluate.cpp +++ b/src/evaluate.cpp @@ -390,9 +390,9 @@ namespace { #ifdef KOTH const Score KothDistanceBonus[6] = { - S(1634, 1553), S(400, 384), S(165, 174), S(83, 87), S(49, 50), S(0, 0) + S(1991, 1658), S(448, 364), S(163, 176), S(80, 89), S(50, 50), S(0, 0) }; - const Score KothSafeCenter = S(159, 211); + const Score KothSafeCenter = S(157, 202); #endif #ifdef ANTI From 1c9ff9fafe7f5c0d573ae415f3e77fb1c1304ebe Mon Sep 17 00:00:00 2001 From: ianfab Date: Thu, 30 Mar 2017 22:33:04 +0200 Subject: [PATCH 13/24] Simplification for racing kings Do not consider king advances to the eigth rank to be checks. STC LLR: 2.98 (-2.94,2.94) [-10.00,5.00] Total: 22270 W: 5603 L: 5678 D: 10989 http://35.161.250.236:6543/tests/view/58dd6d006e23db2fa8080e95 LTC LLR: 2.96 (-2.94,2.94) [-10.00,5.00] Total: 9382 W: 2362 L: 2367 D: 4653 http://35.161.250.236:6543/tests/view/58de1d846e23db2fa8080e9c --- src/movegen.cpp | 4 ++++ src/position.cpp | 13 ------------- src/position.h | 3 --- src/search.cpp | 8 +++----- 4 files changed, 7 insertions(+), 21 deletions(-) diff --git a/src/movegen.cpp b/src/movegen.cpp index 5614cff2..e23eb01c 100644 --- a/src/movegen.cpp +++ b/src/movegen.cpp @@ -605,6 +605,10 @@ ExtMove* generate(const Position& pos, ExtMove* moveList) { if (pos.is_anti()) return moveList; #endif +#ifdef RACE + if (pos.is_race()) + return moveList; +#endif assert(pos.checkers()); diff --git a/src/position.cpp b/src/position.cpp index be1604f3..6001bdda 100644 --- a/src/position.cpp +++ b/src/position.cpp @@ -530,14 +530,6 @@ void Position::set_state(StateInfo* si) const { si->nonPawnMaterial[WHITE] = si->nonPawnMaterial[BLACK] = VALUE_ZERO; si->psq = SCORE_ZERO; set_check_info(si); -#ifdef RACE - if (is_race()) - { - Rank r = rank_of(square(sideToMove)); - si->checkersBB = r == RANK_8 ? 0 : Rank8BB & square(~sideToMove); - } - else -#endif #ifdef HORDE if (is_horde() && is_horde_color(sideToMove)) si->checkersBB = 0; @@ -1456,11 +1448,6 @@ void Position::do_move(Move m, StateInfo& newSt, bool givesCheck) { // Update the key with the final value st->key = k; -#ifdef RACE - if (is_race()) - st->checkersBB = Rank8BB & square(us); - else -#endif // Calculate checkers bitboard (if move gives check) st->checkersBB = givesCheck ? attackers_to(square(them)) & pieces(us) : 0; diff --git a/src/position.h b/src/position.h index 8b44cff9..194d7a7a 100644 --- a/src/position.h +++ b/src/position.h @@ -444,9 +444,6 @@ inline Bitboard Position::attackers_to(Square s) const { inline Bitboard Position::checkers() const { #ifdef ANTI assert(!is_anti() || !st->checkersBB); -#endif -#ifdef RACE - assert(!is_race() || !(st->checkersBB - square(~sideToMove))); #endif return st->checkersBB; } diff --git a/src/search.cpp b/src/search.cpp index 2b93d90e..12485425 100644 --- a/src/search.cpp +++ b/src/search.cpp @@ -1517,11 +1517,6 @@ namespace { { assert(is_ok(move)); -#ifdef RACE - if (pos.is_race()) - givesCheck = type_of(pos.piece_on(from_sq(move))) == KING && rank_of(to_sq(move)) == RANK_8; - else -#endif givesCheck = type_of(move) == NORMAL && !pos.discovered_check_candidates() #ifdef ATOMIC && !pos.is_atomic() @@ -1535,6 +1530,9 @@ namespace { // Futility pruning if ( !InCheck && !givesCheck +#ifdef RACE + && !(pos.is_race() && type_of(pos.piece_on(from_sq(move))) == KING && rank_of(to_sq(move)) == RANK_8) +#endif && futilityBase > -VALUE_KNOWN_WIN && !pos.advanced_pawn_push(move)) { From 0a021732d35fe7774fca6c97155442a321ce793d Mon Sep 17 00:00:00 2001 From: Daniel Dugovic Date: Tue, 28 Mar 2017 06:32:48 -0500 Subject: [PATCH 14/24] Three-check opponent moves do not put the opponent into check --- src/position.cpp | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/position.cpp b/src/position.cpp index 6001bdda..d0cff5cd 100644 --- a/src/position.cpp +++ b/src/position.cpp @@ -1741,9 +1741,7 @@ bool Position::see_ge(Move m, Value v) const { #endif #ifdef THREECHECK - if ( is_three_check() - && ( (color_of(moved_piece(m)) == sideToMove && gives_check(m)) - || (st->checkSquares[type_of(moved_piece(m))] & to_sq(m)))) + if (is_three_check() && color_of(moved_piece(m)) == sideToMove && gives_check(m)) return true; #endif From b432b315f1650b0ea2feb78dfa89b79d23ae2c56 Mon Sep 17 00:00:00 2001 From: Daniel Dugovic Date: Sat, 1 Apr 2017 09:08:42 -0500 Subject: [PATCH 15/24] Simplify three-check see_ge and retune parameters STC LLR: 2.96 (-2.94,2.94) [-10.00,5.00] Total: 238 W: 139 L: 78 D: 21 http://35.161.250.236:6543/tests/view/58dfb5d06e23db2fa8080eb5 LTC LLR: 2.98 (-2.94,2.94) [-10.00,5.00] Total: 449 W: 230 L: 171 D: 48 http://35.161.250.236:6543/tests/view/58dfe6466e23db2fa8080ec1 --- src/evaluate.cpp | 32 ++++++++++++++++---------------- src/pawns.cpp | 8 ++++---- src/types.h | 10 +++++----- 3 files changed, 25 insertions(+), 25 deletions(-) diff --git a/src/evaluate.cpp b/src/evaluate.cpp index 00b6702d..77ec6fa5 100644 --- a/src/evaluate.cpp +++ b/src/evaluate.cpp @@ -271,19 +271,19 @@ namespace { #endif #ifdef THREECHECK { - { S(-75,-76), S(-56,-54), S( -9,-26), S( -2,-10), S( 6, 5), S( 15, 11), // Knights - S( 22, 26), S( 30, 28), S( 36, 29) }, - { S(-48,-58), S(-21,-19), S( 16, -2), S( 26, 12), S( 37, 22), S( 51, 42), // Bishops - S( 54, 54), S( 63, 58), S( 65, 63), S( 71, 70), S( 79, 74), S( 81, 86), - S( 92, 90), S( 97, 94) }, - { S(-56,-78), S(-25,-18), S(-11, 26), S( -5, 55), S( -4, 70), S( -1, 81), // Rooks - S( 8,109), S( 14,120), S( 21,128), S( 23,143), S( 31,154), S( 32,160), - S( 43,165), S( 49,168), S( 59,169) }, - { S(-40,-35), S(-25,-12), S( 2, 7), S( 4, 19), S( 14, 37), S( 24, 55), // Queens - S( 25, 62), S( 40, 76), S( 43, 79), S( 47, 87), S( 54, 94), S( 56,102), - S( 60,111), S( 70,116), S( 72,118), S( 73,122), S( 75,128), S( 77,130), - S( 85,133), S( 94,136), S( 99,140), S(108,157), S(112,158), S(113,161), - S(118,174), S(119,177), S(123,191), S(128,199) } + { S(-74,-76), S(-55,-54), S( -9,-26), S( -2,-10), S( 6, 5), S( 15, 11), // Knights + S( 22, 26), S( 31, 27), S( 37, 29) }, + { S(-49,-56), S(-23,-18), S( 15, -2), S( 25, 12), S( 36, 22), S( 50, 42), // Bishops + S( 53, 54), S( 64, 57), S( 67, 63), S( 71, 68), S( 84, 76), S( 79, 87), + S( 95, 91), S( 98, 93) }, + { S(-57,-76), S(-25,-18), S(-11, 25), S( -5, 53), S( -4, 70), S( -1, 78), // Rooks + S( 8,111), S( 14,116), S( 22,125), S( 24,148), S( 31,159), S( 31,173), + S( 44,163), S( 50,162), S( 56,168) }, + { S(-42,-35), S(-25,-12), S( 2, 7), S( 4, 19), S( 14, 37), S( 24, 53), // Queens + S( 26, 63), S( 39, 80), S( 42, 77), S( 48, 88), S( 53, 96), S( 57, 96), + S( 61,108), S( 71,116), S( 70,116), S( 74,125), S( 75,133), S( 78,133), + S( 85,137), S( 97,135), S(103,141), S(107,165), S(109,153), S(115,162), + S(119,164), S(121,184), S(121,192), S(131,203) } }, #endif }; @@ -382,8 +382,8 @@ namespace { #ifdef THREECHECK const Score ChecksGivenBonus[CHECKS_NB] = { S(0, 0), - S(508, 377), - S(2224, 1000), + S(489, 373), + S(1998, 1102), S(0, 0) }; #endif @@ -488,7 +488,7 @@ namespace { S( 7, 0), #endif #ifdef THREECHECK - S(17, 10), + S(16, 9), #endif }; const Score PawnlessFlank = S( 20, 80); diff --git a/src/pawns.cpp b/src/pawns.cpp index 8b6b6574..65db88b6 100644 --- a/src/pawns.cpp +++ b/src/pawns.cpp @@ -233,10 +233,10 @@ namespace { #endif #ifdef THREECHECK { - { V(103), V( 0), V(21), V( 54), V(87), V( 89), V(100) }, - { V(112), V( 3), V(54), V(105), V(85), V(105), V(100) }, - { V(118), V(22), V(68), V( 93), V(60), V( 88), V(119) }, - { V( 92), V(11), V(51), V( 66), V(93), V( 86), V(118) } + { V(105), V( 1), V(22), V( 52), V(86), V( 89), V( 98) }, + { V(116), V( 3), V(55), V(109), V(81), V( 97), V( 99) }, + { V(121), V(23), V(69), V( 93), V(58), V( 88), V(112) }, + { V( 94), V(11), V(52), V( 67), V(90), V( 85), V(112) } }, #endif }; diff --git a/src/types.h b/src/types.h index 02b552f0..577e9c88 100644 --- a/src/types.h +++ b/src/types.h @@ -351,11 +351,11 @@ enum Value : int { QueenValueMgRace = 1848, QueenValueEgRace = 2141, #endif #ifdef THREECHECK - PawnValueMgThreeCheck = 181, PawnValueEgThreeCheck = 245, - KnightValueMgThreeCheck = 691, KnightValueEgThreeCheck = 850, - BishopValueMgThreeCheck = 829, BishopValueEgThreeCheck = 845, - RookValueMgThreeCheck = 1222, RookValueEgThreeCheck = 1386, - QueenValueMgThreeCheck = 2274, QueenValueEgThreeCheck = 2573, + PawnValueMgThreeCheck = 153, PawnValueEgThreeCheck = 220, + KnightValueMgThreeCheck = 638, KnightValueEgThreeCheck = 811, + BishopValueMgThreeCheck = 690, BishopValueEgThreeCheck = 849, + RookValueMgThreeCheck = 1121, RookValueEgThreeCheck = 1438, + QueenValueMgThreeCheck = 2214, QueenValueEgThreeCheck = 2342, #endif MidgameLimit = 15258, EndgameLimit = 3915 From 075bce1bc05bc02dec1f4ea44e2735aafabd9367 Mon Sep 17 00:00:00 2001 From: ianfab Date: Sat, 1 Apr 2017 17:13:43 +0200 Subject: [PATCH 16/24] Tweak pawn evaluation for atomic chess STC LLR: 2.95 (-2.94,2.94) [0.00,10.00] Total: 2114 W: 746 L: 643 D: 725 http://35.161.250.236:6543/tests/view/58dfc4376e23db2fa8080eb9 LTC LLR: 2.97 (-2.94,2.94) [0.00,10.00] Total: 2412 W: 808 L: 703 D: 901 http://35.161.250.236:6543/tests/view/58dfcab16e23db2fa8080ebc --- src/evaluate.cpp | 4 ++-- src/pawns.cpp | 16 ++++++++-------- src/psqt.cpp | 14 +++++++------- src/types.h | 2 +- 4 files changed, 18 insertions(+), 18 deletions(-) diff --git a/src/evaluate.cpp b/src/evaluate.cpp index 77ec6fa5..1e22ed00 100644 --- a/src/evaluate.cpp +++ b/src/evaluate.cpp @@ -331,8 +331,8 @@ namespace { #endif #ifdef ATOMIC { - { V(85), V(120), V(85), V(138), V(184), V(207) }, - { V(80), V( 49), V(55), V( 77), V(156), V(241) } + { V(95), V(118), V(94), V(142), V(196), V(204) }, + { V(86), V( 43), V(61), V( 62), V(150), V(256) } }, #endif #ifdef CRAZYHOUSE diff --git a/src/pawns.cpp b/src/pawns.cpp index 65db88b6..51a9e70d 100644 --- a/src/pawns.cpp +++ b/src/pawns.cpp @@ -38,7 +38,7 @@ namespace { { S(50, 80), S(54, 69) }, #endif #ifdef ATOMIC - { S(25, 27), S(27, 18) }, + { S(27, 28), S(24, 14) }, #endif #ifdef CRAZYHOUSE { S(45, 40), S(30, 27) }, @@ -70,7 +70,7 @@ namespace { { S(64, 25), S(26, 50) }, #endif #ifdef ATOMIC - { S(41, 25), S(41, 13) }, + { S(48, 21), S(35, 15) }, #endif #ifdef CRAZYHOUSE { S(56, 33), S(41, 19) }, @@ -102,7 +102,7 @@ namespace { S(-45, -48), #endif #ifdef ATOMIC - S( 45, 0), + S( 39, 0), #endif #ifdef CRAZYHOUSE S( 17, 8), @@ -182,10 +182,10 @@ namespace { #endif #ifdef ATOMIC { - { V(100), V(50), V(10), V(46), V(82), V( 86), V( 98) }, - { V(116), V(50), V(10), V(87), V(94), V(108), V(104) }, - { V(109), V(50), V(10), V(87), V(62), V( 91), V(116) }, - { V( 75), V(50), V(10), V(59), V(90), V( 84), V(112) } + { V( 88), V(34), V( 5), V(44), V( 89), V( 90), V( 94) }, + { V(116), V(61), V(-4), V(80), V( 95), V(101), V(104) }, + { V( 97), V(68), V(34), V(82), V( 62), V(104), V(110) }, + { V(103), V(44), V(44), V(77), V(103), V( 66), V(118) } }, #endif #ifdef CRAZYHOUSE @@ -391,7 +391,7 @@ void init() { { 0, 8, 19, 13, 71, 94, 169, 324 }, #endif #ifdef ATOMIC - { 0, 8, 19, 13, 71, 94, 169, 324 }, + { 0,18, 11, 14, 82,109, 170, 315 }, #endif #ifdef CRAZYHOUSE { 0, 8, 19, 13, 71, 94, 169, 324 }, diff --git a/src/psqt.cpp b/src/psqt.cpp index d195e0e4..dbb8150e 100644 --- a/src/psqt.cpp +++ b/src/psqt.cpp @@ -252,13 +252,13 @@ const Score Bonus[VARIANT_NB][PIECE_TYPE_NB][RANK_NB][int(FILE_NB) / 2] = { { { }, { // Pawn - { S( 0, 0), S( 0, 0), S( 0, 0), S( 0, 0) }, - { S(-11, 7), S( 6,-4), S( 7, 8), S( 3,-2) }, - { S(-18,-4), S( -2,-5), S( 19, 5), S(24, 4) }, - { S(-17, 3), S( -9, 3), S( 20,-8), S(35,-3) }, - { S( -6, 8), S( 5, 9), S( 3, 7), S(21,-6) }, - { S( -6, 8), S( -8,-5), S( -6, 2), S(-2, 4) }, - { S( -4, 3), S( 20,-9), S( -8, 1), S(-4,18) } + { S( 0, 0), S( 0, 0), S( 0, 0), S( 0, 0) }, + { S( -9,12), S( 7, -4), S( 12, 6), S( 6,-3) }, + { S(-18,-6), S( 0,-10), S( 18, 4), S(23, 6) }, + { S(-15,-1), S( -7, 1), S( 21,-7), S(36,-4) }, + { S(-10, 7), S( 4, 7), S( 8, 9), S(26,-4) }, + { S(-13,10), S( -5, -3), S( -3, 2), S( 1, 7) }, + { S( -2,-1), S( 16, -5), S( -6, 2), S(-3,28) } }, { // Knight { S(-143, -97), S(-96,-82), S(-80,-46), S(-73,-14) }, diff --git a/src/types.h b/src/types.h index 577e9c88..361105db 100644 --- a/src/types.h +++ b/src/types.h @@ -309,7 +309,7 @@ enum Value : int { KingValueMgAnti = -23, KingValueEgAnti = 231, #endif #ifdef ATOMIC - PawnValueMgAtomic = 314, PawnValueEgAtomic = 447, + PawnValueMgAtomic = 300, PawnValueEgAtomic = 437, KnightValueMgAtomic = 474, KnightValueEgAtomic = 755, BishopValueMgAtomic = 652, BishopValueEgAtomic = 762, RookValueMgAtomic = 899, RookValueEgAtomic = 1199, From a38ab75116e8aef282240e275c337acb5eec6ce3 Mon Sep 17 00:00:00 2001 From: ianfab Date: Sun, 2 Apr 2017 01:26:32 +0200 Subject: [PATCH 17/24] Tweak king piece-square table for horde chess STC LLR: 2.95 (-2.94,2.94) [0.00,10.00] Total: 2588 W: 1342 L: 1204 D: 42 http://35.161.250.236:6543/tests/view/58e037c06e23db2fa8080ec7 LTC LLR: 2.96 (-2.94,2.94) [0.00,10.00] Total: 4545 W: 2327 L: 2160 D: 58 http://35.161.250.236:6543/tests/view/58e037ed6e23db2fa8080eca --- src/psqt.cpp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/psqt.cpp b/src/psqt.cpp index d195e0e4..cf6552ae 100644 --- a/src/psqt.cpp +++ b/src/psqt.cpp @@ -429,14 +429,14 @@ const Score Bonus[VARIANT_NB][PIECE_TYPE_NB][RANK_NB][int(FILE_NB) / 2] = { { S(-1,-75), S(-4,-54), S(-1,-44), S( 0,-30) } }, { // King - { S(230, 28), S(390,-35), S(397,146), S(352, 83) }, - { S(243, 37), S(274, 74), S(348,229), S(296,393) }, - { S(236, 25), S(305,105), S(255, 95), S(254,188) }, - { S(246,175), S(267,245), S(180,249), S( 0, 0) }, - { S(151,120), S(199,207), S(156,231), S( 0, 0) }, - { S(177,107), S(189,230), S(141,172), S(211,251) }, - { S( 26, 36), S(164,145), S(102,139), S(-42,133) }, - { S(147, 2), S(186, 7), S( 49, 79), S( 48, 50) } + { S(205, 67), S(403, -6), S(394,115), S(518,102) }, + { S(214, 63), S(308,116), S(333,169), S(245,255) }, + { S(277, -2), S(261,141), S(286, 69), S(189,207) }, + { S(280,164), S(298,233), S(126,266), S(-45, 55) }, + { S(134, 89), S(255,225), S(152,245), S( 28,-67) }, + { S(212,156), S(191,171), S( 59,160), S(153,248) }, + { S( 75,-25), S(203,134), S(168,141), S(-76,133) }, + { S(137, 49), S(187, 1), S( 60, 26), S(-25, 56) } } }, #endif From 42dcefc300608c4457d93cb0eaec9ea565fafb81 Mon Sep 17 00:00:00 2001 From: ianfab Date: Sun, 2 Apr 2017 12:41:55 +0200 Subject: [PATCH 18/24] Tweak knight piece-square table for crazyhouse STC LLR: 2.96 (-2.94,2.94) [0.00,10.00] Total: 1158 W: 616 L: 500 D: 42 http://35.161.250.236:6543/tests/view/58e0d5c66e23db2fa8080ed4 LTC LLR: 2.96 (-2.94,2.94) [0.00,10.00] Total: 1293 W: 683 L: 565 D: 45 http://35.161.250.236:6543/tests/view/58e118686e23db2fa8080f1c --- src/psqt.cpp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/psqt.cpp b/src/psqt.cpp index b5e27938..6a7166c5 100644 --- a/src/psqt.cpp +++ b/src/psqt.cpp @@ -325,14 +325,14 @@ const Score Bonus[VARIANT_NB][PIECE_TYPE_NB][RANK_NB][int(FILE_NB) / 2] = { { S( -4, 3), S( 20,-9), S( -8, 1), S(-4,18) } }, { // Knight - { S(-143, -97), S(-96,-82), S(-80,-46), S(-73,-14) }, - { S( -83, -69), S(-43,-55), S(-21,-17), S(-10, 9) }, - { S( -71, -50), S(-22,-39), S( 0, -8), S( 9, 28) }, - { S( -25, -41), S( 18,-25), S( 43, 7), S( 47, 38) }, - { S( -26, -46), S( 16,-25), S( 38, 2), S( 50, 41) }, - { S( -11, -55), S( 37,-38), S( 56, -8), S( 71, 27) }, - { S( -62, -64), S(-17,-50), S( 5,-24), S( 14, 13) }, - { S(-195,-110), S(-66,-90), S(-42,-50), S(-29,-13) } + { S(-132,-159), S(-309, -68), S(-117, -37), S( -79,-20) }, + { S( -91,-153), S( -24, -78), S( -80, -4), S(-129, 62) }, + { S( -28, -18), S( -59, -11), S( -17, 39), S( -10,-50) }, + { S( -17, -56), S( 85, -20), S( 75, 28), S( 95, 20) }, + { S( 91, -53), S( 38, -60), S( -7, 60), S( 115, 90) }, + { S( 20, -3), S( 88,-102), S( 33, -71), S( 57, 2) }, + { S(-119, -48), S( -17, -13), S( -15, -56), S( 24,-60) }, + { S(-222,-103), S( -84, -68), S(-126,-112), S( 73, 38) } }, { // Bishop { S(-54,-68), S(-23,-40), S(-35,-46), S(-44,-28) }, From ebe021f6a5da63cf0e31da89d4c21e9b5f673fcd Mon Sep 17 00:00:00 2001 From: VoyagerOne Date: Sun, 2 Apr 2017 20:31:52 -0700 Subject: [PATCH 19/24] Don't update TT at excluded move ply STC: LLR: 2.96 (-2.94,2.94) [0.00,5.00] Total: 38906 W: 7125 L: 6835 D: 24946 LTC: LLR: 2.95 (-2.94,2.94) [0.00,5.00] Total: 28600 W: 3752 L: 3543 D: 21305 Bench: 6861050 Closes #1048 --- src/search.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/search.cpp b/src/search.cpp index 7029ae03..d555b62e 100644 --- a/src/search.cpp +++ b/src/search.cpp @@ -1125,10 +1125,11 @@ namespace { && cm_ok) update_cm_stats(ss-1, pos.piece_on(prevSq), prevSq, stat_bonus(depth)); - tte->save(posKey, value_to_tt(bestValue, ss->ply), - bestValue >= beta ? BOUND_LOWER : - PvNode && bestMove ? BOUND_EXACT : BOUND_UPPER, - depth, bestMove, ss->staticEval, TT.generation()); + if(!excludedMove) + tte->save(posKey, value_to_tt(bestValue, ss->ply), + bestValue >= beta ? BOUND_LOWER : + PvNode && bestMove ? BOUND_EXACT : BOUND_UPPER, + depth, bestMove, ss->staticEval, TT.generation()); assert(bestValue > -VALUE_INFINITE && bestValue < VALUE_INFINITE); From c9917f7756da2dbd117e2f0f31b39d4649675921 Mon Sep 17 00:00:00 2001 From: ianfab Date: Sun, 2 Apr 2017 23:19:26 +0200 Subject: [PATCH 20/24] Introduce new pawn evaluation term for horde chess Add a penalty for pawns in the horde with only few neighbors, since they lack support for advancing. STC LLR: 2.95 (-2.94,2.94) [0.00,10.00] Total: 2569 W: 1336 L: 1198 D: 35 http://35.161.250.236:6543/tests/view/58e16b9b6e23db2fa8080f3d LTC LLR: 2.97 (-2.94,2.94) [0.00,10.00] Total: 6121 W: 3118 L: 2928 D: 75 http://35.161.250.236:6543/tests/view/58e17cc46e23db2fa8080f4e --- src/pawns.cpp | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/pawns.cpp b/src/pawns.cpp index 51a9e70d..f7bf2b68 100644 --- a/src/pawns.cpp +++ b/src/pawns.cpp @@ -267,6 +267,10 @@ namespace { // in front of the king and no enemy pawn on the horizon. const Value MaxSafetyBonus = V(258); +#ifdef HORDE + const Score ImbalancedHorde = S(30, 30); +#endif + #undef S #undef V @@ -296,6 +300,18 @@ namespace { e->pawnsOnSquares[Us][BLACK] = popcount(ourPawns & DarkSquares); e->pawnsOnSquares[Us][WHITE] = pos.count(Us) - e->pawnsOnSquares[Us][BLACK]; +#ifdef HORDE + if (pos.is_horde() && pos.is_horde_color(Us)) + { + int l = 0, m = 0, r = popcount(ourPawns & FileBB[FILE_A]); + for (File f1 = FILE_A; f1 <= FILE_H; ++f1) + { + l = m; m = r; r = f1 < FILE_H ? popcount(ourPawns & FileBB[f1 + 1]) : 0; + score -= ImbalancedHorde * m / ((l + 1) * (r + 1)); + } + } +#endif + // Loop through all pawns of the current color and score each pawn while ((s = *pl++) != SQ_NONE) { From 7a14727cfffdee17b373ea0e8fad6fcc9128ce0c Mon Sep 17 00:00:00 2001 From: ianfab Date: Mon, 3 Apr 2017 14:21:35 +0200 Subject: [PATCH 21/24] Tweak formula for imbalanced horde penalty STC LLR: 2.96 (-2.94,2.94) [0.00,10.00] Total: 828 W: 464 L: 351 D: 13 http://35.161.250.236:6543/tests/view/58e24a856e23db2fa8080f68 LTC LLR: 2.96 (-2.94,2.94) [0.00,10.00] Total: 944 W: 523 L: 408 D: 13 http://35.161.250.236:6543/tests/view/58e2562a6e23db2fa8080f6a --- src/pawns.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pawns.cpp b/src/pawns.cpp index f7bf2b68..379e1ea0 100644 --- a/src/pawns.cpp +++ b/src/pawns.cpp @@ -307,7 +307,7 @@ namespace { for (File f1 = FILE_A; f1 <= FILE_H; ++f1) { l = m; m = r; r = f1 < FILE_H ? popcount(ourPawns & FileBB[f1 + 1]) : 0; - score -= ImbalancedHorde * m / ((l + 1) * (r + 1)); + score -= ImbalancedHorde * m / (1 + l * r); } } #endif From db92f68f8ef14cdbfc602a4cbfbf4d493fe2ac05 Mon Sep 17 00:00:00 2001 From: ianfab Date: Wed, 5 Apr 2017 01:43:05 +0200 Subject: [PATCH 22/24] Introduce per-variant StormDanger No functional change. --- src/pawns.cpp | 169 +++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 167 insertions(+), 2 deletions(-) diff --git a/src/pawns.cpp b/src/pawns.cpp index 379e1ea0..787821e6 100644 --- a/src/pawns.cpp +++ b/src/pawns.cpp @@ -244,7 +244,47 @@ namespace { // Danger of enemy pawns moving toward our king by [type][distance from edge][rank]. // For the unopposed and unblocked cases, RANK_1 = 0 is used when opponent has no pawn // on the given file, or their pawn is behind our king. - const Value StormDanger[][4][RANK_NB] = { + const Value StormDanger[VARIANT_NB][4][4][RANK_NB] = { + { + { { V( 0), V(-290), V(-274), V(57), V(41) }, //BlockedByKing + { V( 0), V( 60), V( 144), V(39), V(13) }, + { V( 0), V( 65), V( 141), V(41), V(34) }, + { V( 0), V( 53), V( 127), V(56), V(14) } }, + { { V( 4), V( 73), V( 132), V(46), V(31) }, //Unopposed + { V( 1), V( 64), V( 143), V(26), V(13) }, + { V( 1), V( 47), V( 110), V(44), V(24) }, + { V( 0), V( 72), V( 127), V(50), V(31) } }, + { { V( 0), V( 0), V( 79), V(23), V( 1) }, //BlockedByPawn + { V( 0), V( 0), V( 148), V(27), V( 2) }, + { V( 0), V( 0), V( 161), V(16), V( 1) }, + { V( 0), V( 0), V( 171), V(22), V(15) } }, + { { V(22), V( 45), V( 104), V(62), V( 6) }, //Unblocked + { V(31), V( 30), V( 99), V(39), V(19) }, + { V(23), V( 29), V( 96), V(41), V(15) }, + { V(21), V( 23), V( 116), V(41), V(15) } } + }, +#ifdef ANTI + { + { { V( 0), V(-290), V(-274), V(57), V(41) }, //BlockedByKing + { V( 0), V( 60), V( 144), V(39), V(13) }, + { V( 0), V( 65), V( 141), V(41), V(34) }, + { V( 0), V( 53), V( 127), V(56), V(14) } }, + { { V( 4), V( 73), V( 132), V(46), V(31) }, //Unopposed + { V( 1), V( 64), V( 143), V(26), V(13) }, + { V( 1), V( 47), V( 110), V(44), V(24) }, + { V( 0), V( 72), V( 127), V(50), V(31) } }, + { { V( 0), V( 0), V( 79), V(23), V( 1) }, //BlockedByPawn + { V( 0), V( 0), V( 148), V(27), V( 2) }, + { V( 0), V( 0), V( 161), V(16), V( 1) }, + { V( 0), V( 0), V( 171), V(22), V(15) } }, + { { V(22), V( 45), V( 104), V(62), V( 6) }, //Unblocked + { V(31), V( 30), V( 99), V(39), V(19) }, + { V(23), V( 29), V( 96), V(41), V(15) }, + { V(21), V( 23), V( 116), V(41), V(15) } } + }, +#endif +#ifdef ATOMIC + { { { V( 0), V(-290), V(-274), V(57), V(41) }, //BlockedByKing { V( 0), V( 60), V( 144), V(39), V(13) }, { V( 0), V( 65), V( 141), V(41), V(34) }, @@ -261,6 +301,131 @@ namespace { { V(31), V( 30), V( 99), V(39), V(19) }, { V(23), V( 29), V( 96), V(41), V(15) }, { V(21), V( 23), V( 116), V(41), V(15) } } + }, +#endif +#ifdef CRAZYHOUSE + { + { { V( 0), V(-290), V(-274), V(57), V(41) }, //BlockedByKing + { V( 0), V( 60), V( 144), V(39), V(13) }, + { V( 0), V( 65), V( 141), V(41), V(34) }, + { V( 0), V( 53), V( 127), V(56), V(14) } }, + { { V( 4), V( 73), V( 132), V(46), V(31) }, //Unopposed + { V( 1), V( 64), V( 143), V(26), V(13) }, + { V( 1), V( 47), V( 110), V(44), V(24) }, + { V( 0), V( 72), V( 127), V(50), V(31) } }, + { { V( 0), V( 0), V( 79), V(23), V( 1) }, //BlockedByPawn + { V( 0), V( 0), V( 148), V(27), V( 2) }, + { V( 0), V( 0), V( 161), V(16), V( 1) }, + { V( 0), V( 0), V( 171), V(22), V(15) } }, + { { V(22), V( 45), V( 104), V(62), V( 6) }, //Unblocked + { V(31), V( 30), V( 99), V(39), V(19) }, + { V(23), V( 29), V( 96), V(41), V(15) }, + { V(21), V( 23), V( 116), V(41), V(15) } } + }, +#endif +#ifdef HORDE + { + { { V( 0), V(-290), V(-274), V(57), V(41) }, //BlockedByKing + { V( 0), V( 60), V( 144), V(39), V(13) }, + { V( 0), V( 65), V( 141), V(41), V(34) }, + { V( 0), V( 53), V( 127), V(56), V(14) } }, + { { V( 4), V( 73), V( 132), V(46), V(31) }, //Unopposed + { V( 1), V( 64), V( 143), V(26), V(13) }, + { V( 1), V( 47), V( 110), V(44), V(24) }, + { V( 0), V( 72), V( 127), V(50), V(31) } }, + { { V( 0), V( 0), V( 79), V(23), V( 1) }, //BlockedByPawn + { V( 0), V( 0), V( 148), V(27), V( 2) }, + { V( 0), V( 0), V( 161), V(16), V( 1) }, + { V( 0), V( 0), V( 171), V(22), V(15) } }, + { { V(22), V( 45), V( 104), V(62), V( 6) }, //Unblocked + { V(31), V( 30), V( 99), V(39), V(19) }, + { V(23), V( 29), V( 96), V(41), V(15) }, + { V(21), V( 23), V( 116), V(41), V(15) } } + }, +#endif +#ifdef KOTH + { + { { V( 0), V(-290), V(-274), V(57), V(41) }, //BlockedByKing + { V( 0), V( 60), V( 144), V(39), V(13) }, + { V( 0), V( 65), V( 141), V(41), V(34) }, + { V( 0), V( 53), V( 127), V(56), V(14) } }, + { { V( 4), V( 73), V( 132), V(46), V(31) }, //Unopposed + { V( 1), V( 64), V( 143), V(26), V(13) }, + { V( 1), V( 47), V( 110), V(44), V(24) }, + { V( 0), V( 72), V( 127), V(50), V(31) } }, + { { V( 0), V( 0), V( 79), V(23), V( 1) }, //BlockedByPawn + { V( 0), V( 0), V( 148), V(27), V( 2) }, + { V( 0), V( 0), V( 161), V(16), V( 1) }, + { V( 0), V( 0), V( 171), V(22), V(15) } }, + { { V(22), V( 45), V( 104), V(62), V( 6) }, //Unblocked + { V(31), V( 30), V( 99), V(39), V(19) }, + { V(23), V( 29), V( 96), V(41), V(15) }, + { V(21), V( 23), V( 116), V(41), V(15) } } + }, +#endif +#ifdef LOSERS + { + { { V( 0), V(-290), V(-274), V(57), V(41) }, //BlockedByKing + { V( 0), V( 60), V( 144), V(39), V(13) }, + { V( 0), V( 65), V( 141), V(41), V(34) }, + { V( 0), V( 53), V( 127), V(56), V(14) } }, + { { V( 4), V( 73), V( 132), V(46), V(31) }, //Unopposed + { V( 1), V( 64), V( 143), V(26), V(13) }, + { V( 1), V( 47), V( 110), V(44), V(24) }, + { V( 0), V( 72), V( 127), V(50), V(31) } }, + { { V( 0), V( 0), V( 79), V(23), V( 1) }, //BlockedByPawn + { V( 0), V( 0), V( 148), V(27), V( 2) }, + { V( 0), V( 0), V( 161), V(16), V( 1) }, + { V( 0), V( 0), V( 171), V(22), V(15) } }, + { { V(22), V( 45), V( 104), V(62), V( 6) }, //Unblocked + { V(31), V( 30), V( 99), V(39), V(19) }, + { V(23), V( 29), V( 96), V(41), V(15) }, + { V(21), V( 23), V( 116), V(41), V(15) } } + }, +#endif +#ifdef RACE + {}, +#endif +#ifdef RELAY + { + { { V( 0), V(-290), V(-274), V(57), V(41) }, //BlockedByKing + { V( 0), V( 60), V( 144), V(39), V(13) }, + { V( 0), V( 65), V( 141), V(41), V(34) }, + { V( 0), V( 53), V( 127), V(56), V(14) } }, + { { V( 4), V( 73), V( 132), V(46), V(31) }, //Unopposed + { V( 1), V( 64), V( 143), V(26), V(13) }, + { V( 1), V( 47), V( 110), V(44), V(24) }, + { V( 0), V( 72), V( 127), V(50), V(31) } }, + { { V( 0), V( 0), V( 79), V(23), V( 1) }, //BlockedByPawn + { V( 0), V( 0), V( 148), V(27), V( 2) }, + { V( 0), V( 0), V( 161), V(16), V( 1) }, + { V( 0), V( 0), V( 171), V(22), V(15) } }, + { { V(22), V( 45), V( 104), V(62), V( 6) }, //Unblocked + { V(31), V( 30), V( 99), V(39), V(19) }, + { V(23), V( 29), V( 96), V(41), V(15) }, + { V(21), V( 23), V( 116), V(41), V(15) } } + }, +#endif +#ifdef THREECHECK + { + { { V( 0), V(-290), V(-274), V(57), V(41) }, //BlockedByKing + { V( 0), V( 60), V( 144), V(39), V(13) }, + { V( 0), V( 65), V( 141), V(41), V(34) }, + { V( 0), V( 53), V( 127), V(56), V(14) } }, + { { V( 4), V( 73), V( 132), V(46), V(31) }, //Unopposed + { V( 1), V( 64), V( 143), V(26), V(13) }, + { V( 1), V( 47), V( 110), V(44), V(24) }, + { V( 0), V( 72), V( 127), V(50), V(31) } }, + { { V( 0), V( 0), V( 79), V(23), V( 1) }, //BlockedByPawn + { V( 0), V( 0), V( 148), V(27), V( 2) }, + { V( 0), V( 0), V( 161), V(16), V( 1) }, + { V( 0), V( 0), V( 171), V(22), V(15) } }, + { { V(22), V( 45), V( 104), V(62), V( 6) }, //Unblocked + { V(31), V( 30), V( 99), V(39), V(19) }, + { V(23), V( 29), V( 96), V(41), V(15) }, + { V(21), V( 23), V( 116), V(41), V(15) } } + }, +#endif }; // Max bonus for king safety. Corresponds to start position with all the pawns @@ -492,7 +657,7 @@ Value Entry::shelter_storm(const Position& pos, Square ksq) { int d = std::min(f, FILE_H - f); safety -= ShelterWeakness[pos.variant()][d][rkUs] - + StormDanger + + StormDanger[pos.variant()] [f == file_of(ksq) && rkThem == relative_rank(Us, ksq) + 1 ? BlockedByKing : rkUs == RANK_1 ? Unopposed : rkThem == rkUs + 1 ? BlockedByPawn : Unblocked] From aa085b5835b3e103094ef55fb814aaff1e33287d Mon Sep 17 00:00:00 2001 From: ianfab Date: Wed, 5 Apr 2017 01:53:29 +0200 Subject: [PATCH 23/24] Tweak StormDanger for crazyhouse STC LLR: 2.95 (-2.94,2.94) [0.00,10.00] Total: 1885 W: 971 L: 845 D: 69 http://35.161.250.236:6543/tests/view/58e432506e23db2fa8080fb4 LTC LLR: 2.95 (-2.94,2.94) [0.00,10.00] Total: 845 W: 458 L: 348 D: 39 http://35.161.250.236:6543/tests/view/58e433136e23db2fa8080fb9 --- src/pawns.cpp | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/src/pawns.cpp b/src/pawns.cpp index 787821e6..6ce951c4 100644 --- a/src/pawns.cpp +++ b/src/pawns.cpp @@ -305,22 +305,22 @@ namespace { #endif #ifdef CRAZYHOUSE { - { { V( 0), V(-290), V(-274), V(57), V(41) }, //BlockedByKing - { V( 0), V( 60), V( 144), V(39), V(13) }, - { V( 0), V( 65), V( 141), V(41), V(34) }, - { V( 0), V( 53), V( 127), V(56), V(14) } }, - { { V( 4), V( 73), V( 132), V(46), V(31) }, //Unopposed - { V( 1), V( 64), V( 143), V(26), V(13) }, - { V( 1), V( 47), V( 110), V(44), V(24) }, - { V( 0), V( 72), V( 127), V(50), V(31) } }, - { { V( 0), V( 0), V( 79), V(23), V( 1) }, //BlockedByPawn - { V( 0), V( 0), V( 148), V(27), V( 2) }, - { V( 0), V( 0), V( 161), V(16), V( 1) }, - { V( 0), V( 0), V( 171), V(22), V(15) } }, - { { V(22), V( 45), V( 104), V(62), V( 6) }, //Unblocked - { V(31), V( 30), V( 99), V(39), V(19) }, - { V(23), V( 29), V( 96), V(41), V(15) }, - { V(21), V( 23), V( 116), V(41), V(15) } } + { { V(-34), V(-366), V(-249), V( 12), V( 80) }, //BlockedByKing + { V( -6), V( 122), V( 158), V( 90), V( 3) }, + { V( 35), V( 89), V( 174), V( 87), V( 86) }, + { V(-77), V( 17), V( 154), V( 82), V( 99) } }, + { { V( 71), V( 67), V( 177), V( 49), V( 28) }, //Unopposed + { V(-86), V( 108), V( 104), V( 86), V( 26) }, + { V( 8), V( 20), V( 107), V(137), V( 35) }, + { V(-95), V( 69), V( 101), V(-10), V(-43) } }, + { { V( -8), V( 75), V( 276), V( 14), V(-71) }, //BlockedByPawn + { V(-28), V( -10), V( 231), V( 8), V( -6) }, + { V( 59), V( -14), V( 300), V( 26), V( -3) }, + { V(-81), V( 2), V( 104), V( 79), V(-19) } }, + { { V( 73), V( 78), V( 88), V( 46), V( 75) }, //Unblocked + { V( 35), V( 48), V( -21), V( 22), V(-52) }, + { V( 37), V( 67), V( 122), V( 6), V( 64) }, + { V( -5), V( 55), V( 101), V( 61), V( 33) } } }, #endif #ifdef HORDE From 2b8c66ee4379f5a9414473863bd7c64299403545 Mon Sep 17 00:00:00 2001 From: ianfab Date: Mon, 3 Apr 2017 20:51:22 +0200 Subject: [PATCH 24/24] Fix material hash for crazyhouse When a piece is dropped, we have to update the material hash. Bugfix tested with simplification bounds: STC LLR: 2.97 (-2.94,2.94) [-10.00,5.00] Total: 12721 W: 6111 L: 6136 D: 474 http://35.161.250.236:6543/tests/view/58e299fe6e23db2fa8080fa2 LTC LLR: 2.99 (-2.94,2.94) [-10.00,5.00] Total: 11874 W: 5660 L: 5679 D: 535 http://35.161.250.236:6543/tests/view/58e2abff6e23db2fa8080fa6 --- src/position.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/position.cpp b/src/position.cpp index d0cff5cd..69e9938d 100644 --- a/src/position.cpp +++ b/src/position.cpp @@ -1355,7 +1355,10 @@ void Position::do_move(Move m, StateInfo& newSt, bool givesCheck) { // Move the piece. The tricky Chess960 castling is handled earlier #ifdef CRAZYHOUSE if (type_of(m) == DROP) + { drop_piece(pc, to); + st->materialKey ^= Zobrist::psq[pc][pieceCount[pc]-1]; + } else #endif if (type_of(m) != CASTLING)