OzZy_M

Sorted Move List

Feb 20th, 2012
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.61 KB | None | 0 0
  1.       // Create Sorted Move List //
  2.       MoveMaxHeap xheap(p->numMoves());
  3.  
  4.       for (int i = 0; i < p->numMoves(); i++) {
  5.         p->getRowCol(i, r, c);
  6.         MoveNode* node = new MoveNode(r, c, OMirza::POINT_BOARD[r][c]);
  7.         xheap.Insert(node);
  8.       }
  9.  
  10.       // Take top x amount, discard the rest
  11.       MoveNode* TopMoves[TOP_NUMBER_OF_MOVES] = {0};
  12.       int heapSize = xheap.Size();
  13.       heapSize = (heapSize > TOP_NUMBER_OF_MOVES) ? TOP_NUMBER_OF_MOVES : heapSize;
  14.       for (int i = 0; i < heapSize; i++) {
  15.         TopMoves[i] = xheap.Pop();
  16.       }
  17.  
  18.       // END: Create Sorted Move List
Advertisement
Add Comment
Please, Sign In to add comment