Board.h 855 B

1234567891011121314151617181920212223242526272829303132
  1. // ----------------------------------------------------------------
  2. // From Game Programming in C++ by Sanjay Madhav
  3. // Copyright (C) 2017 Sanjay Madhav. All rights reserved.
  4. //
  5. // Released under the BSD License
  6. // See LICENSE in root directory for full details.
  7. // ----------------------------------------------------------------
  8. #pragma once
  9. #include <vector>
  10. class BoardState
  11. {
  12. public:
  13. enum SquareState { Empty, Red, Yellow };
  14. BoardState();
  15. std::vector<BoardState*> GetPossibleMoves(SquareState player) const;
  16. bool IsTerminal() const;
  17. float GetScore() const;
  18. SquareState mBoard[6][7];
  19. protected:
  20. bool IsFull() const;
  21. int GetFourInARow() const;
  22. float CalculateHeuristic() const;
  23. };
  24. // Try to place the player's piece
  25. bool TryPlayerMove(class BoardState* state, int column);
  26. // Make the next CPU move
  27. void CPUMove(class BoardState* state);