Guest User

Untitled

a guest
Jul 16th, 2018
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.27 KB | None | 0 0
  1. // Generate successors/expansions of move
  2.         map<int, Board*> potentialMoveMap;
  3.         currentMove->_b->potentialMoves(potentialMoveMap);
  4.        
  5.         map<int,Board*>::iterator successor;
  6.        
  7.         // For each successor
  8.         for(successor = potentialMoveMap.begin(); successor != potentialMoveMap.end(); successor++){
  9.            
  10.             // if the board of successor is not in the closed board set
  11.             if(!closed_list.count(successor->second)){
  12.                        
  13.                 //Allocate memory for board and move
  14.                 Board* successorBoard = new Board(successor->second);
  15.                 PuzzleMove* successorMove = new PuzzleMove(successor->first,successorBoard,currentMove);
  16.  
  17.                
  18.                 // Compute f values for each potential move
  19.                 successorMove->score(ph);
  20.                
  21.                 // Add the board of successor to the board set
  22.                 closed_list.insert(successor->second);
  23.                
  24.                 // Add successorMove to the open_list
  25.                 open_list.push(successorMove);
  26.                
  27.                 // Increment number of expansions
  28.                 _expansions++;
  29.                
  30.             }
  31.            
  32.            
  33.         }
Add Comment
Please, Sign In to add comment