Skip to content

Commit 20bc195

Browse files
AliceRoseliavondele
authored andcommitted
Speedup_threat_by_lesser
This patch could have been considered a non-functional speedup, but changing the ranking of illegal moves. Passed STC: LLR: 2.95 (-2.94,2.94) <0.00,2.00> Total: 131040 W: 34247 L: 33792 D: 63001 Ptnml(0-2): 407, 15281, 33675, 15764, 393 https://tests.stockfishchess.org/tests/live_elo/68a9a75b75da51a345a5a66d Passed LTC: LLR: 2.94 (-2.94,2.94) <0.50,2.50> Total: 280146 W: 72055 L: 71242 D: 136849 Ptnml(0-2): 153, 30252, 78438, 31089, 141 https://tests.stockfishchess.org/tests/view/68a9f58475da51a345a5a6e0 closes official-stockfish#6261 Bench: 2321931
1 parent d11f49b commit 20bc195

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

src/movepick.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -129,13 +129,15 @@ ExtMove* MovePicker::score(MoveList<Type>& ml) {
129129

130130
Color us = pos.side_to_move();
131131

132-
[[maybe_unused]] Bitboard threatByLesser[QUEEN + 1];
132+
[[maybe_unused]] Bitboard threatByLesser[KING + 1];
133133
if constexpr (Type == QUIETS)
134134
{
135+
threatByLesser[PAWN] = 0;
135136
threatByLesser[KNIGHT] = threatByLesser[BISHOP] = pos.attacks_by<PAWN>(~us);
136137
threatByLesser[ROOK] =
137138
pos.attacks_by<KNIGHT>(~us) | pos.attacks_by<BISHOP>(~us) | threatByLesser[KNIGHT];
138139
threatByLesser[QUEEN] = pos.attacks_by<ROOK>(~us) | threatByLesser[ROOK];
140+
threatByLesser[KING] = pos.attacks_by<QUEEN>(~us) | threatByLesser[QUEEN];
139141
}
140142

141143
ExtMove* it = cur;
@@ -170,12 +172,10 @@ ExtMove* MovePicker::score(MoveList<Type>& ml) {
170172

171173
// penalty for moving to a square threatened by a lesser piece
172174
// or bonus for escaping an attack by a lesser piece.
173-
if (KNIGHT <= pt && pt <= QUEEN)
174-
{
175-
static constexpr int bonus[QUEEN + 1] = {0, 0, 144, 144, 256, 517};
176-
int v = threatByLesser[pt] & to ? -95 : 100 * bool(threatByLesser[pt] & from);
177-
m.value += bonus[pt] * v;
178-
}
175+
static constexpr int bonus[KING + 1] = {0, 0, 144, 144, 256, 517, 10000};
176+
int v = threatByLesser[pt] & to ? -95 : 100 * bool(threatByLesser[pt] & from);
177+
m.value += bonus[pt] * v;
178+
179179

180180
if (ply < LOW_PLY_HISTORY_SIZE)
181181
m.value += 8 * (*lowPlyHistory)[ply][m.from_to()] / (1 + ply);

0 commit comments

Comments
 (0)