From ba160f660f65e9255f30ab63a6215dfe0930cc08 Mon Sep 17 00:00:00 2001 From: Franck Dary <franck.dary@lis-lab.fr> Date: Sun, 21 Jul 2019 16:04:12 +0200 Subject: [PATCH] Changed hash method --- transition_machine/src/Config.cpp | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/transition_machine/src/Config.cpp b/transition_machine/src/Config.cpp index 69c3b50..c741a14 100644 --- a/transition_machine/src/Config.cpp +++ b/transition_machine/src/Config.cpp @@ -437,17 +437,12 @@ void Config::addToEntropyHistory(float entropy) std::size_t Config::computeHash() { - static int window = 10; - - int start = std::max(0, head-window); - int end = std::min(tapes[0].refSize()-1, head+window); - - std::hash<std::string> hasher; + static std::hash<std::string> strhasher; + static std::hash<int> inthasher; std::size_t result = 0; - for (int i = start; i < end; i++) - for (auto & tape : tapes) - result ^= (hasher(tape[i-head])*0x9e3779b9+(result << 6)+(result >>2)); + result ^= (strhasher(currentStateName)*0x9e3779b9+(result << 6)+(result >>2)); + result ^= (inthasher(getHead())*0x9e3779b9+(result << 6)+(result >>2)); return result; } -- GitLab