Advertisement
Guest User

Untitled

a guest
Jun 22nd, 2017
51
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.15 KB | None | 0 0
  1. void GameBoard::place_knight(unsigned& row, unsigned& column)
  2. {
  3. if(!tour)
  4. {
  5. board[row * columns_ + column] = moveNumber;
  6. ++moves;
  7. ++moveNumber;
  8.  
  9. callback_(*this, &board[0], MSG_PLACING, moves, rows_, columns_, row, column);
  10.  
  11. if(policy_ == tpSTATIC)
  12. {
  13. std::vector<position> staticNumbers;
  14. position temp = { -1, -1};
  15. std::fill(staticNumbers.begin(), staticNumbers.end(), temp);
  16.  
  17. calculateMoves(row, column, staticNumbers);
  18.  
  19. /*if(staticNumbers.size() == 0)
  20. callback_(*this, &board[0], MSG_FINISHED_FAIL, moves, rows_, columns_, row, column);*/
  21.  
  22. for(unsigned i = 0; i < staticNumbers.size(); ++i)
  23. {
  24. place_knight(staticNumbers[i].y, staticNumbers[i].x);
  25. --moveNumber;
  26. board[staticNumbers[i].y * columns_ + staticNumbers[i].x] = 0;
  27. callback_(*this, &board[0], MSG_REMOVING, moves, rows_, columns_, row, column);
  28. }
  29.  
  30. }
  31.  
  32. //if(policy_ == tpHEURISTICS)
  33.  
  34. if(moves == totalSquares)
  35. {
  36. tour = true;
  37. callback_(*this, &board[0], MSG_FINISHED_OK, moves, rows_, columns_, row, column);
  38. }
  39.  
  40. }
  41. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement