/*
Stockfish, a UCI chess playing engine derived from Glaurung 2.1
Copyright (C) 2004-2008 Tord Romstad (Glaurung author)
- Copyright (C) 2008-2014 Marco Costalba, Joona Kiiski, Tord Romstad
+ Copyright (C) 2008-2015 Marco Costalba, Joona Kiiski, Tord Romstad
Stockfish is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
const int PushAway [8] = { 0, 5, 20, 40, 60, 80, 90, 100 };
#ifndef NDEBUG
- bool verify_material(const Position& pos, Color c, Value npm, int num_pawns) {
- return pos.non_pawn_material(c) == npm && pos.count<PAWN>(c) == num_pawns;
+ bool verify_material(const Position& pos, Color c, Value npm, int pawnsCnt) {
+ return pos.non_pawn_material(c) == npm && pos.count<PAWN>(c) == pawnsCnt;
}
#endif
string fen = sides[0] + char(8 - sides[0].length() + '0') + "/8/8/8/8/8/8/"
+ sides[1] + char(8 - sides[1].length() + '0') + " w - - 0 10";
- return Position(fen, false, NULL).material_key();
+ return Position(fen, false, nullptr).material_key();
}
- template<typename M>
- void delete_endgame(const typename M::value_type& p) { delete p.second; }
-
} // namespace
add<KRPPKRP>("KRPPKRP");
}
-Endgames::~Endgames() {
-
- for_each(m1.begin(), m1.end(), delete_endgame<M1>);
- for_each(m2.begin(), m2.end(), delete_endgame<M2>);
-}
-template<EndgameType E>
+template<EndgameType E, typename T>
void Endgames::add(const string& code) {
-
- map((Endgame<E>*)0)[key(code, WHITE)] = new Endgame<E>(WHITE);
- map((Endgame<E>*)0)[key(code, BLACK)] = new Endgame<E>(BLACK);
+ map<T>()[key(code, WHITE)] = std::unique_ptr<EndgameBase<T>>(new Endgame<E>(WHITE));
+ map<T>()[key(code, BLACK)] = std::unique_ptr<EndgameBase<T>>(new Endgame<E>(BLACK));
}
if ( pos.count<QUEEN>(strongSide)
|| pos.count<ROOK>(strongSide)
||(pos.count<BISHOP>(strongSide) && pos.count<KNIGHT>(strongSide))
- || pos.bishop_pair(strongSide))
+ ||(pos.count<BISHOP>(strongSide) > 1 && opposite_colors(pos.list<BISHOP>(strongSide)[0],
+ pos.list<BISHOP>(strongSide)[1])))
result += VALUE_KNOWN_WIN;
return strongSide == pos.side_to_move() ? result : -result;
Color us = strongSide == pos.side_to_move() ? WHITE : BLACK;
- if (!Bitbases::probe_kpk(wksq, psq, bksq, us))
+ if (!Bitbases::probe(wksq, psq, bksq, us))
return VALUE_DRAW;
Value result = VALUE_KNOWN_WIN + PawnValueEg + Value(rank_of(psq));
// Probe the KPK bitbase with the weakest side's pawn removed. If it's a draw,
// it's probably at least a draw even with the pawn.
- return Bitbases::probe_kpk(wksq, psq, bksq, us) ? SCALE_FACTOR_NONE : SCALE_FACTOR_DRAW;
+ return Bitbases::probe(wksq, psq, bksq, us) ? SCALE_FACTOR_NONE : SCALE_FACTOR_DRAW;
}