File tree Expand file tree Collapse file tree 1 file changed +5
-5
lines changed Expand file tree Collapse file tree 1 file changed +5
-5
lines changed Original file line number Diff line number Diff line change @@ -152,7 +152,7 @@ PuzzleState::TILE PuzzleState::g_start[] =
152152
153153 // Three example start states from Bratko's Prolog Programming for Artificial Intelligence
154154
155- #if 1
155+ #if 0
156156 // ex a - 4 steps
157157 TL_1 ,
158158 TL_3 ,
@@ -267,7 +267,7 @@ PuzzleState::TILE PuzzleState::g_start[] =
267267 TL_7 ,
268268 TL_5 ,
269269
270- #elif 0
270+ #elif 1
271271
272272 // worst 30
273273 TL_5 ,
@@ -340,12 +340,12 @@ bool PuzzleState::IsSameState( PuzzleState &rhs )
340340// The 9 tiles positions can be encoded as digits
341341size_t PuzzleState::Hash ()
342342{
343- stringstream stream ;
343+ std:: size_t hash = 0 ;
344344 for ( size_t i = 0 ; i < (BOARD_HEIGHT * BOARD_WIDTH); i++ )
345345 {
346- stream << tiles[i];
346+ hash ^= std::hash< int >()( tiles[i]) + 0x9e3779b9 + (hash << 6 ) + (hash >> 2 ) ;
347347 }
348- return std:: hash<std::string>{}(stream. str ()) ;
348+ return hash;
349349}
350350
351351void PuzzleState::PrintNodeInfo ()
You can’t perform that action at this time.
0 commit comments