File tree Expand file tree Collapse file tree 5 files changed +22
-16
lines changed Expand file tree Collapse file tree 5 files changed +22
-16
lines changed Original file line number Diff line number Diff line change @@ -345,9 +345,7 @@ size_t PuzzleState::Hash()
345345 {
346346 stream << tiles[i];
347347 }
348- size_t state_digits;
349- stream >> state_digits;
350- return hash<size_t >{}(state_digits);
348+ return std::hash<std::string>{}(stream.str ());
351349}
352350
353351void PuzzleState::PrintNodeInfo ()
Original file line number Diff line number Diff line change 88
99// //////////////////////////////////////////////////////////////////////////////////////////////////////////////
1010
11- using namespace std ;
12-
13- #include " stlastar.h" // See header for copyright and usage information
14-
1511#include < iostream>
1612#include < stdio.h>
1713#include < math.h>
1814
15+ using namespace std ;
16+
17+ #include " stlastar.h" // See header for copyright and usage information
18+
1919#define DEBUG_LISTS 0
2020#define DEBUG_LIST_LENGTHS_ONLY 0
2121
Original file line number Diff line number Diff line change 11all : 8puzzle findpath minpathbucharest tests
22
3+ # Set the C++ compiler to g++
4+ CXX = g++
5+
6+ # Set some common C++ flags
7+ CXXFLAGS = -std=c++11 -Wall
8+
39clean :
410 rm 8puzzle findpath minpathbucharest tests
511
612minpathbucharest : min_path_to_Bucharest.cpp stlastar.h
7- g++ -Wall min_path_to_Bucharest.cpp -o minpathbucharest
13+ $( CXX ) $( CXXFLAGS ) min_path_to_Bucharest.cpp -o minpathbucharest
814
9158puzzle : 8puzzle.cpp stlastar.h
10- g++ -Wall 8puzzle.cpp -o 8puzzle
16+ $( CXX ) $( CXXFLAGS ) -Wall 8puzzle.cpp -o 8puzzle
1117
1218findpath : findpath.cpp stlastar.h
13- g++ -Wall findpath.cpp -o findpath
19+ $( CXX ) $( CXXFLAGS ) findpath.cpp -o findpath
1420
1521tests : tests.cpp 8puzzle findpath minpathbucharest
16- g++ -Wall tests.cpp -o tests
22+ $( CXX ) $( CXXFLAGS ) tests.cpp -o tests
1723
1824test : tests
1925 ./tests
Original file line number Diff line number Diff line change 1818// mention that the algorithm does some backtracking because the heuristic is not accurate (yet still admissable).
1919// //////////////////////////////////////////////////////////////////////////////////////////////////////////////
2020
21- using namespace std ;
22-
23- #include " stlastar.h"
2421#include < iostream>
2522#include < string>
2623#include < vector>
2724#include < stdio.h>
2825
26+ using namespace std ;
27+
28+ #include " stlastar.h"
29+
2930#define DEBUG_LISTS 0
3031#define DEBUG_LIST_LENGTHS_ONLY 0
3132
Original file line number Diff line number Diff line change @@ -81,7 +81,7 @@ template <class UserState> class AStarSearch
8181 Node *parent; // used during the search to record the parent of successor nodes
8282 Node *child; // used after the search for the application to view the search in reverse
8383
84- float g; // cost of this node + it's predecessors
84+ float g; // cost of this node + its predecessors
8585 float h; // heuristic estimate of distance to goal
8686 float f; // sum of cumulative cost of predecessors and self and heuristic
8787
@@ -321,8 +321,9 @@ template <class UserState> class AStarSearch
321321 continue ;
322322 }
323323 }
324+ typename unordered_set<Node*, NodeHash, NodeEqual>::iterator closedlist_result;
324325
325- auto closedlist_result = m_ClosedList.find (*successor);
326+ closedlist_result = m_ClosedList.find (*successor);
326327
327328 if ( closedlist_result != m_ClosedList.end () )
328329 {
You can’t perform that action at this time.
0 commit comments