Skip to content

Commit

Permalink
Merge remote-tracking branch 'ddugovic/master' into ddugovic
Browse files Browse the repository at this point in the history
  • Loading branch information
niklasf committed Apr 5, 2017
2 parents 5f10cad + 7f8cb76 commit 80e4dfd
Show file tree
Hide file tree
Showing 9 changed files with 328 additions and 100 deletions.
44 changes: 22 additions & 22 deletions src/evaluate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
};
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -382,17 +382,17 @@ namespace {
#ifdef THREECHECK
const Score ChecksGivenBonus[CHECKS_NB] = {
S(0, 0),
S(472, 369),
S(1980, 1159),
S(489, 373),
S(1998, 1102),
S(0, 0)
};
#endif

#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
Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -488,7 +488,7 @@ namespace {
S( 7, 0),
#endif
#ifdef THREECHECK
S(15, 10),
S(16, 9),
#endif
};
const Score PawnlessFlank = S( 20, 80);
Expand Down Expand Up @@ -749,7 +749,7 @@ namespace {
2 * int(BishopValueMg),
#endif
#ifdef THREECHECK
4 * int(BishopValueMg),
3264,
#endif
};

Expand Down
71 changes: 62 additions & 9 deletions src/material.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -153,6 +153,18 @@ namespace {
},
#endif
};
#ifdef CRAZYHOUSE
const int QuadraticOursInHand[PIECE_TYPE_NB][PIECE_TYPE_NB] = {
// OUR PIECES
//empty pawn knight bishop rook queen
{ -88 }, // Empty hand
{ 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

const int QuadraticTheirs[VARIANT_NB][PIECE_TYPE_NB][PIECE_TYPE_NB] = {
{
Expand Down Expand Up @@ -212,7 +224,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
Expand Down Expand Up @@ -276,6 +288,18 @@ namespace {
},
#endif
};
#ifdef CRAZYHOUSE
const int QuadraticTheirsInHand[PIECE_TYPE_NB][PIECE_TYPE_NB] = {
// THEIR PIECES
//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

// PawnsSet[count] contains a bonus/malus indexed by number of pawns
const int PawnsSet[FILE_NB + 1] = {
Expand Down Expand Up @@ -324,7 +348,12 @@ namespace {
/// imbalance() calculates the imbalance by comparing the piece count of each
/// piece type for both colors.
template<Color Us>
#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);

Expand Down Expand Up @@ -353,6 +382,21 @@ namespace {

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];

bonus += pieceCountInHand[Us][pt1] * v;
}
#endif

return bonus;
}
Expand Down Expand Up @@ -491,8 +535,17 @@ Entry* probe(const Position& pos) {
pos.count<BISHOP>(WHITE) , pos.count<ROOK>(WHITE), pos.count<QUEEN >(WHITE), pos.count<KING>(WHITE) },
{ pos.count<BISHOP>(BLACK) > 1, pos.count<PAWN>(BLACK), pos.count<KNIGHT>(BLACK),
pos.count<BISHOP>(BLACK) , pos.count<ROOK>(BLACK), pos.count<QUEEN >(BLACK), pos.count<KING>(BLACK) } };

#ifdef CRAZYHOUSE
const int PieceCountInHand[COLOR_NB][PIECE_TYPE_NB] = {
{ pos.count_in_hand<ALL_PIECES>(WHITE) == 0, pos.count_in_hand<PAWN>(WHITE), pos.count_in_hand<KNIGHT>(WHITE),
pos.count_in_hand<BISHOP>(WHITE) , pos.count_in_hand<ROOK>(WHITE), pos.count_in_hand<QUEEN >(WHITE), pos.count_in_hand<KING>(WHITE) },
{ pos.count_in_hand<ALL_PIECES>(BLACK) == 0, pos.count_in_hand<PAWN>(BLACK), pos.count_in_hand<KNIGHT>(BLACK),
pos.count_in_hand<BISHOP>(BLACK) , pos.count_in_hand<ROOK>(BLACK), pos.count_in_hand<QUEEN >(BLACK), pos.count_in_hand<KING>(BLACK) } };

e->value = int16_t((imbalance<WHITE>(pos, PieceCount, PieceCountInHand) - imbalance<BLACK>(pos, PieceCount, PieceCountInHand)) / 16);
#else
e->value = int16_t((imbalance<WHITE>(pos, PieceCount) - imbalance<BLACK>(pos, PieceCount)) / 16);
#endif
return e;
}

Expand Down
4 changes: 4 additions & 0 deletions src/movegen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -605,6 +605,10 @@ ExtMove* generate<EVASIONS>(const Position& pos, ExtMove* moveList) {
if (pos.is_anti())
return moveList;
#endif
#ifdef RACE
if (pos.is_race())
return moveList;
#endif

assert(pos.checkers());

Expand Down
Loading

0 comments on commit 80e4dfd

Please sign in to comment.