mirror of
https://github.com/sockspls/badfish
synced 2025-04-30 16:53:09 +00:00
Simplify Endgames::probe()
With this API change we simplify both function and caller site. No functional change. Signed-off-by: Marco Costalba <mcostalba@gmail.com>
This commit is contained in:
parent
dda0fa1a43
commit
7a8429d9f1
3 changed files with 11 additions and 14 deletions
|
@ -94,7 +94,7 @@ private:
|
||||||
|
|
||||||
/// Endgames class stores in two std::map the pointers to endgame evaluation
|
/// Endgames class stores in two std::map the pointers to endgame evaluation
|
||||||
/// and scaling base objects. Then we use polymorphism to invoke the actual
|
/// and scaling base objects. Then we use polymorphism to invoke the actual
|
||||||
/// endgame function calling its operator() method that is virtual.
|
/// endgame function calling its operator() that is virtual.
|
||||||
|
|
||||||
class Endgames {
|
class Endgames {
|
||||||
|
|
||||||
|
@ -104,8 +104,8 @@ class Endgames {
|
||||||
M1 m1;
|
M1 m1;
|
||||||
M2 m2;
|
M2 m2;
|
||||||
|
|
||||||
M1& map(M1::value_type::second_type) { return m1; }
|
M1& map(M1::mapped_type) { return m1; }
|
||||||
M2& map(M2::value_type::second_type) { return m2; }
|
M2& map(M2::mapped_type) { return m2; }
|
||||||
|
|
||||||
template<EndgameType E> void add(const std::string& code);
|
template<EndgameType E> void add(const std::string& code);
|
||||||
|
|
||||||
|
@ -113,9 +113,8 @@ public:
|
||||||
Endgames();
|
Endgames();
|
||||||
~Endgames();
|
~Endgames();
|
||||||
|
|
||||||
template<typename T> EndgameBase<T>* probe(Key key) {
|
template<typename T> T probe(Key key, T& eg)
|
||||||
return map((EndgameBase<T>*)0).count(key) ? map((EndgameBase<T>*)0)[key] : NULL;
|
{ return eg = map(eg).count(key) ? map(eg)[key] : NULL; }
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // !defined(ENDGAME_H_INCLUDED)
|
#endif // !defined(ENDGAME_H_INCLUDED)
|
||||||
|
|
|
@ -108,7 +108,7 @@ MaterialEntry* MaterialTable::probe(const Position& pos) {
|
||||||
// Let's look if we have a specialized evaluation function for this
|
// Let's look if we have a specialized evaluation function for this
|
||||||
// particular material configuration. First we look for a fixed
|
// particular material configuration. First we look for a fixed
|
||||||
// configuration one, then a generic one if previous search failed.
|
// configuration one, then a generic one if previous search failed.
|
||||||
if ((e->evaluationFunction = endgames.probe<Value>(key)) != NULL)
|
if (endgames.probe(key, e->evaluationFunction))
|
||||||
return e;
|
return e;
|
||||||
|
|
||||||
if (is_KXK<WHITE>(pos))
|
if (is_KXK<WHITE>(pos))
|
||||||
|
@ -145,7 +145,7 @@ MaterialEntry* MaterialTable::probe(const Position& pos) {
|
||||||
// scaling functions and we need to decide which one to use.
|
// scaling functions and we need to decide which one to use.
|
||||||
EndgameBase<ScaleFactor>* sf;
|
EndgameBase<ScaleFactor>* sf;
|
||||||
|
|
||||||
if ((sf = endgames.probe<ScaleFactor>(key)) != NULL)
|
if (endgames.probe(key, sf))
|
||||||
{
|
{
|
||||||
e->scalingFunction[sf->color()] = sf;
|
e->scalingFunction[sf->color()] = sf;
|
||||||
return e;
|
return e;
|
||||||
|
|
10
src/misc.cpp
10
src/misc.cpp
|
@ -51,17 +51,15 @@ const string engine_info(bool to_uci) {
|
||||||
string month, day, year;
|
string month, day, year;
|
||||||
stringstream s, date(__DATE__); // From compiler, format is "Sep 21 2008"
|
stringstream s, date(__DATE__); // From compiler, format is "Sep 21 2008"
|
||||||
|
|
||||||
|
s << "Stockfish " << Version;
|
||||||
|
|
||||||
if (Version.empty())
|
if (Version.empty())
|
||||||
{
|
{
|
||||||
date >> month >> day >> year;
|
date >> month >> day >> year;
|
||||||
|
|
||||||
s << "Stockfish " << Tag
|
s << Tag << setfill('0') << " " << year.substr(2)
|
||||||
<< setfill('0') << " " << year.substr(2)
|
<< setw(2) << (1 + months.find(month) / 4) << setw(2) << day;
|
||||||
<< setw(2) << (1 + months.find(month) / 4)
|
|
||||||
<< setw(2) << day;
|
|
||||||
}
|
}
|
||||||
else
|
|
||||||
s << "Stockfish " << Version;
|
|
||||||
|
|
||||||
s << cpu64 << popcnt << (to_uci ? "\nid author ": " by ")
|
s << cpu64 << popcnt << (to_uci ? "\nid author ": " by ")
|
||||||
<< "Tord Romstad, Marco Costalba and Joona Kiiski";
|
<< "Tord Romstad, Marco Costalba and Joona Kiiski";
|
||||||
|
|
Loading…
Add table
Reference in a new issue