From: Fabian Fichter Date: Mon, 1 Jun 2020 08:45:22 +0000 (+0200) Subject: Merge official-stockfish/master X-Git-Url: http://winboard.nl/cgi-bin?a=commitdiff_plain;h=54b1c2e5756037d9a2ba365665b6c8d12d0ded50;p=fairystockfish.git Merge official-stockfish/master bench: 5148422 --- 54b1c2e5756037d9a2ba365665b6c8d12d0ded50 diff --cc src/evaluate.cpp index 450e182,ceba258..ec6cd3b --- a/src/evaluate.cpp +++ b/src/evaluate.cpp @@@ -1002,37 -697,29 +1001,36 @@@ namespace template Score Evaluation::initiative(Score score) const { - int outflanking = distance(pos.square(WHITE), pos.square(BLACK)) - - distance(pos.square(WHITE), pos.square(BLACK)); + // No initiative bonus for extinction variants + 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 + : distance(pos.square(WHITE), pos.square(BLACK)) + - distance(pos.square(WHITE), pos.square(BLACK)); - bool infiltration = (pos.count(WHITE) && rank_of(pos.square(WHITE)) > RANK_4) - || (pos.count(BLACK) && rank_of(pos.square(BLACK)) < RANK_5); - bool pawnsOnBothFlanks = (pos.pieces(PAWN) & QueenSide) && (pos.pieces(PAWN) & KingSide); bool almostUnwinnable = !pe->passed_count() && outflanking < 0 + && pos.stalemate_value() == VALUE_DRAW && !pawnsOnBothFlanks; - bool infiltration = rank_of(pos.square(WHITE)) > RANK_4 - || rank_of(pos.square(BLACK)) < RANK_5; ++ bool infiltration = (pos.count(WHITE) && rank_of(pos.square(WHITE)) > RANK_4) ++ || (pos.count(BLACK) && rank_of(pos.square(BLACK)) < RANK_5); + // Compute the initiative bonus for the attacking side int complexity = 9 * pe->passed_count() + 11 * pos.count() + + 15 * pos.count() + 9 * outflanking - + 12 * infiltration + 21 * pawnsOnBothFlanks + + 24 * infiltration + 51 * !pos.non_pawn_material() - 43 * almostUnwinnable - - 100 ; + -110 ; - // Give more importance to non-material score Value mg = mg_value(score); Value eg = eg_value(score); diff --cc src/main.cpp index a044994,182cf10..2b57302 --- a/src/main.cpp +++ b/src/main.cpp @@@ -26,9 -27,6 +27,8 @@@ #include "thread.h" #include "tt.h" #include "uci.h" - #include "endgame.h" +#include "piece.h" +#include "variant.h" #include "syzygy/tbprobe.h" namespace PSQT { diff --cc src/movegen.cpp index bf20c95,7e8961a..129d596 --- a/src/movegen.cpp +++ b/src/movegen.cpp @@@ -87,10 -52,10 +87,9 @@@ namespace template ExtMove* generate_pawn_moves(const Position& pos, ExtMove* moveList, Bitboard target) { - // Compute some compile time parameters relative to the white side constexpr Color Them = (Us == WHITE ? BLACK : WHITE); - constexpr Bitboard TRank7BB = (Us == WHITE ? Rank7BB : Rank2BB); - constexpr Bitboard TRank3BB = (Us == WHITE ? Rank3BB : Rank6BB); constexpr Direction Up = pawn_push(Us); + constexpr Direction Down = -pawn_push(Us); constexpr Direction UpRight = (Us == WHITE ? NORTH_EAST : SOUTH_WEST); constexpr Direction UpLeft = (Us == WHITE ? NORTH_WEST : SOUTH_EAST); diff --cc src/position.cpp index 266d651,0ac4505..9a5b739 --- a/src/position.cpp +++ b/src/position.cpp @@@ -1084,54 -634,15 +1086,54 @@@ bool Position::gives_check(Move m) cons Square from = from_sq(m); Square to = to_sq(m); + // No check possible without king + if (!count(~sideToMove)) + return false; + // Is there a direct check? - if (check_squares(type_of(piece_on(from))) & to) - return true; + if (type_of(m) != PROMOTION && type_of(m) != PIECE_PROMOTION && type_of(m) != PIECE_DEMOTION) + { + PieceType pt = type_of(moved_piece(m)); + if (AttackRiderTypes[pt] & (HOPPING_RIDERS | ASYMMETRICAL_RIDERS)) + { + Bitboard occupied = (type_of(m) != DROP ? pieces() ^ from : pieces()) | to; + if (attacks_bb(sideToMove, pt, to, occupied) & square(~sideToMove)) + return true; + } - else if (st->checkSquares[pt] & to) ++ else if (check_squares(pt) & to) + return true; + } + + Bitboard janggiCannons = pieces(JANGGI_CANNON); + if (type_of(moved_piece(m)) == JANGGI_CANNON) + janggiCannons = (type_of(m) == DROP ? janggiCannons : janggiCannons ^ from) | to; + else if (janggiCannons & to) + janggiCannons ^= to; // Is there a discovered check? - if ( ((type_of(m) != DROP && (st->blockersForKing[~sideToMove] & from)) || pieces(sideToMove, CANNON, BANNER) - if ( (blockers_for_king(~sideToMove) & from) - && !aligned(from, to, square(~sideToMove))) ++ if ( ((type_of(m) != DROP && (blockers_for_king(~sideToMove) & from)) || pieces(sideToMove, CANNON, BANNER) + || pieces(HORSE, ELEPHANT) || pieces(JANGGI_CANNON, JANGGI_ELEPHANT)) + && attackers_to(square(~sideToMove), (type_of(m) == DROP ? pieces() : pieces() ^ from) | to, sideToMove, janggiCannons)) + return true; + + // Is there a check by gated pieces? + if ( is_gating(m) + && attacks_bb(sideToMove, gating_type(m), gating_square(m), (pieces() ^ from) | to) & square(~sideToMove)) return true; + // Is there a check by special diagonal moves? + if (more_than_one(diagonal_lines() & (to | square(~sideToMove)))) + { + PieceType pt = type_of(moved_piece(m)); + PieceType diagType = pt == WAZIR ? FERS : pt == SOLDIER ? PAWN : pt == ROOK ? BISHOP : NO_PIECE_TYPE; + Bitboard occupied = type_of(m) == DROP ? pieces() : pieces() ^ from; + if (diagType && (attacks_bb(sideToMove, diagType, to, occupied) & square(~sideToMove))) + return true; + // TODO: fix for longer diagonals + else if (pt == JANGGI_CANNON && (attacks_bb(sideToMove, ALFIL, to, occupied) & ~attacks_bb(sideToMove, ELEPHANT, to, occupied) & square(~sideToMove))) + return true; + } + switch (type_of(m)) { case NORMAL: