nathansttt / hog2

Pathfinding and search testbed/visualization suite. Current code is in PDB-refactor branch.
MIT License
107 stars 54 forks source link

Added real field default initialization to pancake evironment #79

Closed lior8 closed 3 months ago

lior8 commented 4 months ago

In the pancake environment there is a real field. If left uninitialized, it can lead to problems when compiling in release mode and trying to calculate a path length. For example, take the following Pancake-14 instance: 2 9 13 6 3 4 10 8 5 11 7 1 12 0

PancakePuzzleState<N> start; // The aforementioned state
PancakePuzzleState<N> goal; // Canonical goal
TemplateAStar<PancakePuzzleState<N>,PancakePuzzleAction,PancakePuzzle<N>> astar;
astar.GetPath(&env, start, goal, solutionPath);
printf("solution %1.0f;\n", env.GetPathLength(solutionPath));

will print 14, despite 14 states in the solution path (including the start), and overall cost of 13 as 13 actions are needed.