Game.h 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. #ifndef GAME_H
  2. #define GAME_H
  3. #include <array>
  4. #include "String.h"
  5. #include "Types.h"
  6. #include "Vector.h"
  7. class Game final {
  8. public:
  9. enum FieldState {
  10. BLACK, WHITE, EMPTY
  11. };
  12. Game();
  13. void parse();
  14. private:
  15. void consumeLine() const;
  16. void consumeLine(uint y);
  17. void parseFields();
  18. bool isInRange(const Vector& v) const;
  19. void print(String& s) const;
  20. void printLine(String& s, int y) const;
  21. bool areNeighbours(const Vector& from, const Vector& to) const;
  22. void addLocation(const Vector& v);
  23. bool isInQueue(const Vector& v) const;
  24. void removeLine(const Vector& from, const Vector& to, FieldState state);
  25. uint getRank(const Vector& from, const Vector& to, FieldState state) const;
  26. uint getStoneTakes(const Vector& from, const Vector& to) const;
  27. uint getStoneFreedom(const Vector& from) const;
  28. uint getFreedom(FieldState state) const;
  29. bool hasState(const Vector& v, FieldState state) const;
  30. FieldState getState(const Vector& v) const;
  31. void setState(const Vector& v, FieldState state);
  32. void move(const Vector& from, const Vector& to);
  33. void makeSelection();
  34. void makeMove();
  35. void takeStone();
  36. int getQuality(const Vector& from, const Vector& to) const;
  37. int countBlack() const;
  38. bool isTakingPossible() const;
  39. FieldState fields[9][5];
  40. Vector active;
  41. Vector direction;
  42. bool mustTake;
  43. std::array<Vector, 20> lastLocations;
  44. uint lastLocation;
  45. static std::array<Vector, 8> neighbours;
  46. static std::array<Vector, 9 * 5> fieldVectors;
  47. };
  48. #endif