diff --git a/environments/MNPuzzle.h b/environments/MNPuzzle.h index 9d8a5d5cc..3938251d0 100644 --- a/environments/MNPuzzle.h +++ b/environments/MNPuzzle.h @@ -12,15 +12,15 @@ #include #include -#include "SearchEnvironment.h" +#include "../search/SearchEnvironment.h" #include "PermutationPuzzleEnvironment.h" -#include "UnitSimulation.h" +#include "../simulation/UnitSimulation.h" #include "GraphEnvironment.h" -#include "Graph.h" +#include "../graph/Graph.h" #include "GraphEnvironment.h" #include #include -#include "LexPermutationPDB.h" +#include "../search/LexPermutationPDB.h" enum puzzleWeight { kDWSTP, @@ -839,6 +839,7 @@ double MNPuzzle::DCost(const MNPuzzleState &state1 } } hval = std::max(hval, man_dist); + return hval; } template @@ -1012,8 +1013,11 @@ void MNPuzzle::GetStateFromPDBHash(uint64_t hash, MNPuzzleState static_cast(s.puzzle.size())) + count = static_cast(s.puzzle.size()); for (int x = 0; x < dual.size(); x++) { s.puzzle[dual[x]] = pattern[x]; diff --git a/environments/PermutationPuzzleEnvironment.h b/environments/PermutationPuzzleEnvironment.h index cec7cc394..dfee66e52 100644 --- a/environments/PermutationPuzzleEnvironment.h +++ b/environments/PermutationPuzzleEnvironment.h @@ -7,11 +7,11 @@ #include #include #include -#include "SearchEnvironment.h" -#include "Timer.h" -#include "SharedQueue.h" -#include "RangeCompression.h" -#include "MR1Permutation.h" +#include "../search/SearchEnvironment.h" +#include "../utils/Timer.h" +#include "../utils/SharedQueue.h" +#include "../utils/RangeCompression.h" +#include "../utils/MR1Permutation.h" #ifndef PERMPUZZ_H #define PERMPUZZ_H @@ -61,7 +61,8 @@ namespace PermutationPuzzle { double HCost(const state &s) const; virtual double AdditiveGCost(const state &s, const action &d) - { assert(!"Additive Gost used but not defined for this class\n"); } + { assert(!"Additive Gost used but not defined for this class\n"); + return 0.0; } void GetStateFromHash(state &s, uint64_t hash) const; uint64_t GetStateHash(const state &s) const; @@ -1357,30 +1358,28 @@ namespace PermutationPuzzle { n, each of the integers from 0 to n-1 occurs exactly once. **/ template - bool PermutationPuzzleEnvironment::Check_Permutation(const std::vector &to_check) + bool PermutationPuzzleEnvironment::Check_Permutation(const std::vector& to_check) { - const auto size = to_check.size(); - - bool in_puzzle[size]; - - for (size_t i = 0; i < size; i++) - { - in_puzzle[i] = false; - } - - for (size_t i = 0; i < size; i++) - { - in_puzzle[to_check[i]] = true; - } - - for (size_t i = 0; i < size; i++) - { - if (!in_puzzle[i]) + const size_t n = to_check.size(); + + // היה: bool in_puzzle[n]; // לא חוקי ב-MSVC + std::vector in_puzzle(n, 0); // "בדגל" לכל ערך 0..n-1 + + for (size_t i = 0; i < n; ++i) { + const int v = to_check[i]; + if (v < 0 || v >= static_cast(n)) // ערך מחוץ לטווח + return false; + if (in_puzzle[static_cast(v)]) // כפילות return false; + in_puzzle[static_cast(v)] = 1; } - + // לוודא שכל הערכים 0..n-1 הופיעו + for (size_t v = 0; v < n; ++v) + if (!in_puzzle[v]) return false; + return true; } + /** Outputs the set of puzzles in puzzle_vector to standard output. The output is of the diff --git a/search/PDBHeuristic.h b/search/PDBHeuristic.h index 861c66d17..5e373b23d 100644 --- a/search/PDBHeuristic.h +++ b/search/PDBHeuristic.h @@ -291,6 +291,7 @@ void PDBHeuristic double(COUNT-entries)*double(distribution[distribution.size()-2]))// || depth == 8) @@ -641,18 +652,28 @@ void PDBHeuristiclock(); for (auto d : cache) { + // std::cout << "im hereeeeeeeeee " << "\n"; + if (d.newGCost < DB.Get(d.rank)) // shorter path { if (DB.Get(d.rank) == (1<unlock(); + // std::cout << "countttttttttttttttttt " << count << "\n"; + cache.resize(0); } + // std::cout << "im hereeeeee countttt" << count << "\n"; results->Add(count); + // lock->lock(); // printf("Thread %d offline\n", threadNum); // lock->unlock(); diff --git a/search/TreePermutationPDB.h b/search/TreePermutationPDB.h index b8aa77508..bebe33c85 100644 --- a/search/TreePermutationPDB.h +++ b/search/TreePermutationPDB.h @@ -25,8 +25,8 @@ class TreePermutationPDB : public PermutationPDB::example; @@ -42,7 +42,7 @@ class TreePermutationPDB : public PermutationPDB > locsCache; mutable std::vector > tempCache; - state example; + state new_example; }; inline int mylog2(int val)