From: Fabian Fichter Date: Tue, 16 Apr 2019 20:28:45 +0000 (+0200) Subject: Merge branch 'master' of https://github.com/official-stockfish/Stockfish X-Git-Url: http://winboard.nl/cgi-bin?a=commitdiff_plain;h=2b8ff249c7c43f25a1787c56dd22bc78ed1d5870;p=fairystockfish.git Merge branch 'master' of https://github.com/official-stockfish/Stockfish bench: 3359419 --- 2b8ff249c7c43f25a1787c56dd22bc78ed1d5870 diff --cc src/evaluate.cpp index 48e2c86,fbe768b..9ce64e3 --- a/src/evaluate.cpp +++ b/src/evaluate.cpp @@@ -396,15 -354,15 +396,15 @@@ namespace if (Pt == ROOK) { // Bonus for aligning rook with enemy pawns on the same rank/file - if (relative_rank(Us, s) >= RANK_5) - score += RookOnPawn * popcount(pos.pieces(Them, PAWN) & PseudoAttacks[ROOK][s]); + if (relative_rank(Us, s, pos.max_rank()) >= RANK_5) + score += RookOnPawn * popcount(pos.pieces(Them, PAWN) & PseudoAttacks[Us][ROOK][s]); // Bonus for rook on an open or semi-open file - if (pe->semiopen_file(Us, file_of(s))) - score += RookOnFile[bool(pe->semiopen_file(Them, file_of(s)))]; + if (pos.semiopen_file(Us, file_of(s))) + score += RookOnFile[bool(pos.semiopen_file(Them, file_of(s)))]; // Penalty when trapped by the king, even more if the king cannot castle - else if (mob <= 3) + else if (mob <= 3 && pos.count(Us)) { File kf = file_of(pos.square(Us)); if ((kf < FILE_E) == (file_of(s) < kf)) @@@ -854,21 -710,17 +854,24 @@@ // Find the available squares for our pieces inside the area defined by SpaceMask Bitboard safe = SpaceMask - & ~pos.pieces(Us, PAWN) - & ~attackedBy[Them][PAWN]; + & ~pos.pieces(Us, PAWN, SHOGI_PAWN) + & ~attackedBy[Them][PAWN] + & ~attackedBy[Them][SHOGI_PAWN]; - if (pawnsOnly) - safe = pos.pieces(Us, PAWN) & ~attackedBy[Them][ALL_PIECES]; - // Find all squares which are at most three squares behind some friendly pawn - Bitboard behind = pos.pieces(Us, PAWN); + Bitboard behind = pos.pieces(Us, PAWN, SHOGI_PAWN); behind |= shift(behind); behind |= shift(shift(behind)); ++ if (pawnsOnly) ++ { ++ safe = behind & ~attackedBy[Them][ALL_PIECES]; ++ behind = 0; ++ } ++ int bonus = popcount(safe) + popcount(behind & safe); int weight = pos.count(Us) - - 2 * popcount(pe->semiopenFiles[WHITE] & pe->semiopenFiles[BLACK]); + - (16 - pos.count()) / 4; Score score = make_score(bonus * weight * weight / 16, 0); diff --cc src/pawns.cpp index 22be218,4c2ff39..c0d2002 --- a/src/pawns.cpp +++ b/src/pawns.cpp @@@ -89,9 -88,8 +88,8 @@@ namespace assert(pos.piece_on(s) == make_piece(Us, PAWN)); File f = file_of(s); - Rank r = relative_rank(Us, s); + Rank r = relative_rank(Us, s, pos.max_rank()); - e->semiopenFiles[Us] &= ~(1 << f); e->pawnAttacksSpan[Us] |= pawn_attack_span(Us, s); // Flag the pawn @@@ -146,30 -141,6 +144,28 @@@ score -= Doubled; } + // Double pawn evaluation if there are no non-pawn pieces + if (pos.count(Us) == pos.count(Us)) + score = score * 2; + + const Square* pl_shogi = pos.squares(Us); + + ourPawns = pos.pieces(Us, SHOGI_PAWN); + theirPawns = pos.pieces(Them, SHOGI_PAWN); + + // Loop through all shogi pawns of the current color and score each one + while ((s = *pl_shogi++) != SQ_NONE) + { + assert(pos.piece_on(s) == make_piece(Us, SHOGI_PAWN)); + + File f = file_of(s); + - e->semiopenFiles[Us] &= ~(1 << f); - + neighbours = ourPawns & adjacent_files_bb(f); + + if (!neighbours) + score -= Isolated / 2; + } + return score; } diff --cc src/position.h index 35c81d5,1351d0d..b2ce510 --- a/src/position.h +++ b/src/position.h @@@ -160,8 -94,8 +160,9 @@@ public template int count(Color c) const; template int count() const; template const Square* squares(Color c) const; + const Square* squares(Color c, PieceType pt) const; template Square square(Color c) const; + int semiopen_file(Color c, File f) const; // Castling int castling_rights(Color c) const; @@@ -668,6 -261,10 +669,10 @@@ inline Square Position::ep_square() con return st->epSquare; } + inline int Position::semiopen_file(Color c, File f) const { - return !(pieces(c, PAWN) & file_bb(f)); ++ return !(pieces(c, PAWN, SHOGI_PAWN) & file_bb(f)); + } + inline bool Position::can_castle(CastlingRight cr) const { return st->castlingRights & cr; }