From 9af42a43a47d11bc0dea64f0cbb305f827a8f991 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maximilian=20Ke=C3=9Fler?= Date: Sat, 10 Feb 2024 00:27:00 +0100 Subject: [PATCH] reduce number of map lookups --- include/game_state.hpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/include/game_state.hpp b/include/game_state.hpp index 1ea8673..8c61b56 100644 --- a/include/game_state.hpp +++ b/include/game_state.hpp @@ -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;