mirror of
https://github.com/sockspls/badfish
synced 2025-04-30 16:53:09 +00:00
Retire redundant endgames
The case of two lone kings on the board is already considered by the "No pawns" scaling factor rules in material.cpp as is KBK and KNK. Moreover we had a small leak in endgames map because for KK endgame it happens white and black material keys are the same (both equal to zero), so when adding the black endgame in Endgames::add() we were overwriting the already exsisting white one, leading to a memory leak found by Valgrind. So remove the endgames althogheter and rely on scaling to correctly set the endgames value to a draw. No functional change.
This commit is contained in:
parent
f39cf1b008
commit
c4533e0d94
3 changed files with 2 additions and 10 deletions
|
@ -89,10 +89,7 @@ namespace {
|
|||
|
||||
Endgames::Endgames() {
|
||||
|
||||
add<KK>("KK");
|
||||
add<KPK>("KPK");
|
||||
add<KBK>("KBK");
|
||||
add<KNK>("KNK");
|
||||
add<KNNK>("KNNK");
|
||||
add<KBNK>("KBNK");
|
||||
add<KRKP>("KRKP");
|
||||
|
@ -411,9 +408,6 @@ Value Endgame<KBBKN>::operator()(const Position& pos) const {
|
|||
|
||||
|
||||
/// Some cases of trivial draws
|
||||
template<> Value Endgame<KK>::operator()(const Position&) const { return VALUE_DRAW; }
|
||||
template<> Value Endgame<KBK>::operator()(const Position&) const { return VALUE_DRAW; }
|
||||
template<> Value Endgame<KNK>::operator()(const Position&) const { return VALUE_DRAW; }
|
||||
template<> Value Endgame<KNNK>::operator()(const Position&) const { return VALUE_DRAW; }
|
||||
template<> Value Endgame<KmmKm>::operator()(const Position&) const { return VALUE_DRAW; }
|
||||
|
||||
|
|
|
@ -33,9 +33,6 @@ enum EndgameType {
|
|||
|
||||
// Evaluation functions
|
||||
|
||||
KK, // K vs K
|
||||
KBK, // KB vs K
|
||||
KNK, // KN vs K
|
||||
KNNK, // KNN vs K
|
||||
KXK, // Generic "mate lone king" eval
|
||||
KBNK, // KBN vs K
|
||||
|
|
|
@ -240,7 +240,8 @@ Entry* probe(const Position& pos, Table& entries, Endgames& endgames) {
|
|||
}
|
||||
}
|
||||
|
||||
// No pawns makes it difficult to win, even with a material advantage
|
||||
// No pawns makes it difficult to win, even with a material advantage. This
|
||||
// catches some trivial draws like KK, KBK and KNK
|
||||
if (!pos.count<PAWN>(WHITE) && npm_w - npm_b <= BishopValueMg)
|
||||
{
|
||||
e->factor[WHITE] = (uint8_t)
|
||||
|
|
Loading…
Add table
Reference in a new issue