mirror of
https://github.com/sockspls/badfish
synced 2025-05-02 01:29:36 +00:00
Merge branch 'master' into nnue-player-wip
Bench: 4746616
This commit is contained in:
commit
97724370e7
3 changed files with 22 additions and 21 deletions
|
@ -130,12 +130,6 @@ constexpr bool more_than_one(Bitboard b) {
|
||||||
return b & (b - 1);
|
return b & (b - 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Counts the occupation of the bitboard depending on the occupation of SQ_A1
|
|
||||||
/// as in `b & (1ULL << SQ_A1) ? more_than_two(b) : more_than_one(b)`
|
|
||||||
|
|
||||||
constexpr bool conditional_more_than_two(Bitboard b) {
|
|
||||||
return b & (b - 1) & (b - 2);
|
|
||||||
}
|
|
||||||
|
|
||||||
constexpr bool opposite_colors(Square s1, Square s2) {
|
constexpr bool opposite_colors(Square s1, Square s2) {
|
||||||
return (s1 + rank_of(s1) + s2 + rank_of(s2)) & 1;
|
return (s1 + rank_of(s1) + s2 + rank_of(s2)) & 1;
|
||||||
|
|
|
@ -345,13 +345,15 @@ namespace {
|
||||||
|
|
||||||
if (Pt == BISHOP || Pt == KNIGHT)
|
if (Pt == BISHOP || Pt == KNIGHT)
|
||||||
{
|
{
|
||||||
// Bonus if piece is on an outpost square or can reach one
|
// Bonus if the piece is on an outpost square or can reach one
|
||||||
|
// Reduced bonus for knights (BadOutpost) if few relevant targets
|
||||||
bb = OutpostRanks & attackedBy[Us][PAWN] & ~pe->pawn_attacks_span(Them);
|
bb = OutpostRanks & attackedBy[Us][PAWN] & ~pe->pawn_attacks_span(Them);
|
||||||
|
Bitboard targets = pos.pieces(Them) & ~pos.pieces(PAWN);
|
||||||
|
|
||||||
if ( Pt == KNIGHT
|
if ( Pt == KNIGHT
|
||||||
&& bb & s & ~CenterFiles
|
&& bb & s & ~CenterFiles // on a side outpost
|
||||||
&& !(b & pos.pieces(Them) & ~pos.pieces(PAWN))
|
&& !(b & targets) // no relevant attacks
|
||||||
&& !conditional_more_than_two(
|
&& (!more_than_one(targets & (s & QueenSide ? QueenSide : KingSide))))
|
||||||
pos.pieces(Them) & ~pos.pieces(PAWN) & (s & QueenSide ? QueenSide : KingSide)))
|
|
||||||
score += BadOutpost;
|
score += BadOutpost;
|
||||||
else if (bb & s)
|
else if (bb & s)
|
||||||
score += Outpost[Pt == BISHOP];
|
score += Outpost[Pt == BISHOP];
|
||||||
|
@ -612,17 +614,21 @@ namespace {
|
||||||
// Bonus for threats on the next moves against enemy queen
|
// Bonus for threats on the next moves against enemy queen
|
||||||
if (pos.count<QUEEN>(Them) == 1)
|
if (pos.count<QUEEN>(Them) == 1)
|
||||||
{
|
{
|
||||||
|
bool queenImbalance = pos.count<QUEEN>() == 1;
|
||||||
|
|
||||||
Square s = pos.square<QUEEN>(Them);
|
Square s = pos.square<QUEEN>(Them);
|
||||||
safe = mobilityArea[Us] & ~stronglyProtected;
|
safe = mobilityArea[Us]
|
||||||
|
& ~pos.pieces(Us, PAWN)
|
||||||
|
& ~stronglyProtected;
|
||||||
|
|
||||||
b = attackedBy[Us][KNIGHT] & attacks_bb<KNIGHT>(s);
|
b = attackedBy[Us][KNIGHT] & attacks_bb<KNIGHT>(s);
|
||||||
|
|
||||||
score += KnightOnQueen * popcount(b & safe);
|
score += KnightOnQueen * popcount(b & safe) * (1 + queenImbalance);
|
||||||
|
|
||||||
b = (attackedBy[Us][BISHOP] & attacks_bb<BISHOP>(s, pos.pieces()))
|
b = (attackedBy[Us][BISHOP] & attacks_bb<BISHOP>(s, pos.pieces()))
|
||||||
| (attackedBy[Us][ROOK ] & attacks_bb<ROOK >(s, pos.pieces()));
|
| (attackedBy[Us][ROOK ] & attacks_bb<ROOK >(s, pos.pieces()));
|
||||||
|
|
||||||
score += SliderOnQueen * popcount(b & safe & attackedBy2[Us]);
|
score += SliderOnQueen * popcount(b & safe & attackedBy2[Us]) * (1 + queenImbalance);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (T)
|
if (T)
|
||||||
|
|
|
@ -1069,7 +1069,7 @@ moves_loop: // When in check, search starts from here
|
||||||
// search of (alpha-s, beta-s), and just one fails high on (alpha, beta),
|
// search of (alpha-s, beta-s), and just one fails high on (alpha, beta),
|
||||||
// then that move is singular and should be extended. To verify this we do
|
// then that move is singular and should be extended. To verify this we do
|
||||||
// a reduced search on all the other moves but the ttMove and if the
|
// a reduced search on all the other moves but the ttMove and if the
|
||||||
// result is lower than ttValue minus a margin then we will extend the ttMove.
|
// result is lower than ttValue minus a margin, then we will extend the ttMove.
|
||||||
if ( depth >= 6
|
if ( depth >= 6
|
||||||
&& move == ttMove
|
&& move == ttMove
|
||||||
&& !rootNode
|
&& !rootNode
|
||||||
|
@ -1133,12 +1133,6 @@ moves_loop: // When in check, search starts from here
|
||||||
if (type_of(move) == CASTLING)
|
if (type_of(move) == CASTLING)
|
||||||
extension = 1;
|
extension = 1;
|
||||||
|
|
||||||
// Late irreversible move extension
|
|
||||||
if ( move == ttMove
|
|
||||||
&& pos.rule50_count() > 80
|
|
||||||
&& (captureOrPromotion || type_of(movedPiece) == PAWN))
|
|
||||||
extension = 2;
|
|
||||||
|
|
||||||
// Add extension to new depth
|
// Add extension to new depth
|
||||||
newDepth += extension;
|
newDepth += extension;
|
||||||
|
|
||||||
|
@ -1175,6 +1169,13 @@ moves_loop: // When in check, search starts from here
|
||||||
{
|
{
|
||||||
Depth r = reduction(improving, depth, moveCount);
|
Depth r = reduction(improving, depth, moveCount);
|
||||||
|
|
||||||
|
// Decrease reduction at non-check cut nodes for second move at low depths
|
||||||
|
if ( cutNode
|
||||||
|
&& depth <= 10
|
||||||
|
&& moveCount <= 2
|
||||||
|
&& !ss->inCheck)
|
||||||
|
r--;
|
||||||
|
|
||||||
// Decrease reduction if the ttHit running average is large
|
// Decrease reduction if the ttHit running average is large
|
||||||
if (thisThread->ttHitAverage > 473 * TtHitAverageResolution * TtHitAverageWindow / 1024)
|
if (thisThread->ttHitAverage > 473 * TtHitAverageResolution * TtHitAverageWindow / 1024)
|
||||||
r--;
|
r--;
|
||||||
|
|
Loading…
Add table
Reference in a new issue