Advertisement
Guest User

Header

a guest
Feb 27th, 2017
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.75 KB | None | 0 0
  1. #ifndef BOARD_H
  2. #define BOARD_H
  3.  
  4. #include <opencv2/core/core.hpp>
  5. #include <opencv2/highgui/highgui.hpp>
  6. #include <iostream>
  7.  
  8. using namespace std;
  9. using namespace cv; // OpenCV API is in the C++ "cv" namespace
  10.  
  11. class Board
  12. {
  13. public:
  14. // Initialise the board
  15. Board(int blockSize, int numberOfSquares, int offset);
  16.  
  17. // Deallocates the board
  18. ~Board();
  19.  
  20. void deleteBoard();
  21.  
  22. // --------------------------------------BOARD VARIABLES----------------------------------- //
  23. int** othelloBoard;
  24. Vec3b color;
  25. Mat clearBoard;
  26. // ---------------------------------------------------------------------------------------- //
  27.  
  28.  
  29. // --------------------------------------PRINT OPERATIONS-----------------------------------//
  30. void printBoardValues();
  31. int printWinner();
  32. // ---------------------------------------------------------------------------------------- //
  33.  
  34. // --------------------------------------BOARD OPERATIONS---------------------------------- //
  35. // Sets a disc void such that it can't be played on
  36. void setDiscUnplayable(int row, int column);
  37.  
  38. void setDiscEmpty(int row, int column);
  39.  
  40. void setInitialSquares();
  41.  
  42. Mat drawAvailablePositions(int playerNumber, Mat currentBoard);
  43.  
  44. // Draws an empty board
  45. Mat drawBoard();
  46.  
  47. // Draws discs onto the board
  48. Mat drawDiscs(Mat emptyBoard, int**);
  49.  
  50. // Places a disc at the given row / column for player *playerNumber*
  51. bool placeDisc(int row, int column, int playerNumber);
  52.  
  53. // Sets the board values
  54. void setBoardValues(int** newBoardValues);
  55.  
  56. // Transforms pixel co-ordinates into row/column co-ordinates
  57. int* scalePixelSelection(int* selection);
  58.  
  59. // Places a disc and flips the respective discs
  60. int flipDiscs(int row, int column, int playerNumber);
  61.  
  62. // Flips the discs in the respective direction
  63. int flipDiscsAbove(int row, int column, int playerNumber, bool flipping);
  64. int flipDiscsBelow(int row, int column, int playerNumber, bool flipping);
  65. int flipDiscsLeft(int row, int column, int playerNumber, bool flipping);
  66. int flipDiscsRight(int row, int column, int playerNumber, bool flipping);
  67.  
  68. int flipDiscsLeftUp(int row, int column, int playerNumber, bool flipping);
  69. int flipDiscsLeftDown(int row, int column, int playerNumber, bool flipping);
  70. int flipDiscsRightUp(int row, int column, int playerNumber, bool flipping);
  71. int flipDiscsRightDown(int row, int column, int playerNumber, bool flipping);
  72. // ---------------------------------------------------------------------------------------- //
  73.  
  74. // --------------------------------------GET OPERATIONS------------------------------------ //
  75. // Returns the array of arrays representing disc locations
  76. int** getBoard();
  77.  
  78. // Returns the board values
  79. int** getBoardValues() { return othelloBoard; }
  80.  
  81. // Checks if there are any empty squares in the board - true if no gaps
  82. bool hasEmpty();
  83.  
  84. // Calculates how many moves are available to player *playerNumber*
  85. int numberOfAvailableMoves(int playerNumber);
  86.  
  87. // Returns an array of arrays representing the moves available to player *playerNumber*
  88. // 2nd parameter = number of moves available - needed to create the correct sized array
  89. int** availableMoveLocations(int playerNumber, int numberOfMoves);
  90.  
  91. // Calculates who won the game
  92. int calculateWinner();
  93.  
  94. // Obvious
  95. int getBlockSize() { return blockSize; }
  96. int getBoardSize() { return boardSize; }
  97. int getOffset() { return offset; }
  98. // ---------------------------------------------------------------------------------------- //
  99.  
  100. private:
  101. // size of each square
  102. int blockSize;
  103.  
  104. // width or height of board (pixels) - both the same as its a square
  105. int boardSize;
  106.  
  107. // the size of the background area around the board
  108. int offset;
  109.  
  110. // size of total image (pixels)
  111. int imageSize;
  112. };
  113. #endif
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement