summary |
shortlog |
log |
commit | commitdiff |
tree
raw |
patch |
inline | side by side (from parent 1:
44c320a)
Similar to PSQT we only need one instance of the Endgames resource. The current per thread copies are identical and read only(after initialization) so from a design point of view it doesn't make sense to have them.
Tested for no slowdown.
http://tests.stockfishchess.org/tests/view/
5c94377a0ebc5925cfff43ca
LLR: 2.95 (-2.94,2.94) [-3.00,1.00]
Total: 17320 W: 3487 L: 3359 D: 10474
No functional change.
+namespace Endgames {
+
+ std::pair<Map<Value>, Map<ScaleFactor>> maps;
+
+ void init() {
+
+ add<KPK>("KPK");
+ add<KNNK>("KNNK");
+ add<KBNK>("KBNK");
+ add<KRKP>("KRKP");
+ add<KRKB>("KRKB");
+ add<KRKN>("KRKN");
+ add<KQKP>("KQKP");
+ add<KQKR>("KQKR");
+ add<KNNKP>("KNNKP");
+
+ add<KNPK>("KNPK");
+ add<KNPKB>("KNPKB");
+ add<KRPKR>("KRPKR");
+ add<KRPKB>("KRPKB");
+ add<KBPKB>("KBPKB");
+ add<KBPKN>("KBPKN");
+ add<KBPPKB>("KBPPKB");
+ add<KRPPKRP>("KRPPKRP");
+ }
+}
+
/// Mate with KX vs K. This function is used to evaluate positions with
/// king and plenty of material vs a lone king. It simply gives the
/// attacking side a bonus for driving the defending king towards the edge
/// Mate with KX vs K. This function is used to evaluate positions with
/// king and plenty of material vs a lone king. It simply gives the
/// attacking side a bonus for driving the defending king towards the edge
/// base objects in two std::map. We use polymorphism to invoke the actual
/// endgame function by calling its virtual operator().
/// base objects in two std::map. We use polymorphism to invoke the actual
/// endgame function by calling its virtual operator().
template<typename T> using Ptr = std::unique_ptr<EndgameBase<T>>;
template<typename T> using Map = std::map<Key, Ptr<T>>;
template<typename T> using Ptr = std::unique_ptr<EndgameBase<T>>;
template<typename T> using Map = std::map<Key, Ptr<T>>;
+
+ extern std::pair<Map<Value>, Map<ScaleFactor>> maps;
template<typename T>
Map<T>& map() {
template<typename T>
Map<T>& map() {
map<T>()[Position().set(code, BLACK, &st).material_key()] = Ptr<T>(new Endgame<E>(BLACK));
}
map<T>()[Position().set(code, BLACK, &st).material_key()] = Ptr<T>(new Endgame<E>(BLACK));
}
- std::pair<Map<Value>, Map<ScaleFactor>> maps;
-
-public:
- Endgames() {
-
- add<KPK>("KPK");
- add<KNNK>("KNNK");
- add<KBNK>("KBNK");
- add<KRKP>("KRKP");
- add<KRKB>("KRKB");
- add<KRKN>("KRKN");
- add<KQKP>("KQKP");
- add<KQKR>("KQKR");
- add<KNNKP>("KNNKP");
-
- add<KNPK>("KNPK");
- add<KNPKB>("KNPKB");
- add<KRPKR>("KRPKR");
- add<KRPKB>("KRPKB");
- add<KBPKB>("KBPKB");
- add<KBPKN>("KBPKN");
- add<KBPPKB>("KBPPKB");
- add<KRPPKRP>("KRPPKRP");
- }
-
template<typename T>
const EndgameBase<T>* probe(Key key) {
return map<T>().count(key) ? map<T>()[key].get() : nullptr;
}
template<typename T>
const EndgameBase<T>* probe(Key key) {
return map<T>().count(key) ? map<T>()[key].get() : nullptr;
}
#endif // #ifndef ENDGAME_H_INCLUDED
#endif // #ifndef ENDGAME_H_INCLUDED
#include "thread.h"
#include "tt.h"
#include "uci.h"
#include "thread.h"
#include "tt.h"
#include "uci.h"
#include "syzygy/tbprobe.h"
namespace PSQT {
#include "syzygy/tbprobe.h"
namespace PSQT {
Position::init();
Bitbases::init();
Search::init();
Position::init();
Bitbases::init();
Search::init();
Threads.set(Options["Threads"]);
Search::clear(); // After threads are up
Threads.set(Options["Threads"]);
Search::clear(); // After threads are up
// Let's look if we have a specialized evaluation function for this particular
// material configuration. Firstly we look for a fixed configuration one, then
// for a generic one if the previous search failed.
// Let's look if we have a specialized evaluation function for this particular
// material configuration. Firstly we look for a fixed configuration one, then
// for a generic one if the previous search failed.
- if ((e->evaluationFunction = pos.this_thread()->endgames.probe<Value>(key)) != nullptr)
+ if ((e->evaluationFunction = Endgames::probe<Value>(key)) != nullptr)
return e;
for (Color c = WHITE; c <= BLACK; ++c)
return e;
for (Color c = WHITE; c <= BLACK; ++c)
// OK, we didn't find any special evaluation function for the current material
// configuration. Is there a suitable specialized scaling function?
// OK, we didn't find any special evaluation function for the current material
// configuration. Is there a suitable specialized scaling function?
- const auto* sf = pos.this_thread()->endgames.probe<ScaleFactor>(key);
+ const auto* sf = Endgames::probe<ScaleFactor>(key);
Pawns::Table pawnsTable;
Material::Table materialTable;
Pawns::Table pawnsTable;
Material::Table materialTable;
size_t pvIdx, pvLast;
int selDepth, nmpMinPly;
Color nmpColor;
size_t pvIdx, pvLast;
int selDepth, nmpMinPly;
Color nmpColor;