reduce number of map lookups

This commit is contained in:
Maximilian Keßler 2024-02-10 00:27:00 +01:00
parent 3dafee21dd
commit 9af42a43a4
Signed by: max
GPG key ID: BCC5A619923C0BA5

View file

@ -1034,8 +1034,10 @@ namespace Hanabi
return 0;
}
#ifndef GAME_STATE_NO_TABLEBASE_LOOKUP
if (_position_tablebase.count(id_of_state) == 1) {
return _position_tablebase[id_of_state];
auto lookup_it = _position_tablebase.find(id_of_state);
if (lookup_it != _position_tablebase.end())
{
return lookup_it->second;
}
#endif
@ -1401,10 +1403,12 @@ namespace Hanabi
std::cout << "\n" << std::endl;
}
#endif
#ifndef NDEBUG
if (_position_tablebase.count(id) == 1)
{
ASSERT(_position_tablebase[id] == probability);
}
#endif
if (save_state_to_map())
{
_position_tablebase[id] = probability;