Game.h 1.6 KB

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