Advertisement
Guest User

Untitled

a guest
Nov 24th, 2014
140
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.31 KB | None | 0 0
  1. #ifndef BRICKSDATA_H
  2. #define BRICKSDATA_H
  3.  
  4. #include <vector>
  5.  
  6. class BricksData
  7. {
  8. public:
  9. enum Movement {Up = -4, Left = -1, None = 0, Right = 1, Down = 4};
  10.  
  11. // Initialize data structures to the initial position:
  12. // 1 2 3 4
  13. // 5 6 7 8
  14. // 9 10 11 12
  15. // 13 14 15
  16. BricksData();
  17.  
  18. // If 'toMove' is a legal brick to move then update the data
  19. // structures, add the moved bricks to 'brickList', and return the
  20. // direction of the move
  21. // Otherwise return the move direction 'None'
  22. Movement Move(int toMove, std::vector<int> &brickList);
  23.  
  24. // Add all brick numbers in order according to their current
  25. // position (use '0' for the empty square)
  26. // The order for the initial positions is:
  27. // 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 0
  28. void Positions(std::vector<int> &brickList);
  29.  
  30. // Reset the data structures to the initial position
  31. void Reset();
  32.  
  33. // Shuffle the bricks to random positions
  34. void Shuffle();
  35.  
  36. // Return 'true' if the puzzle is solved, i.e. all bricks are in
  37. // their initial positions
  38. bool Check();
  39.  
  40. private:
  41. int matrix[4][4];
  42. int zeroX, zeroY;
  43. };
  44.  
  45. #endif // BRICKSDATA_H
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement