1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071 |
- #ifndef GAME_H
- #define GAME_H
- #include <array>
- #include "String.h"
- #include "Types.h"
- #include "Vector.h"
- #include "List.h"
- class Game final {
- public:
- enum FieldState {
- BLACK, WHITE, EMPTY
- };
- Game();
- void readLine();
- private:
- bool parseLine(const String& command);
-
- void consumeLine() const;
- void readLine(uint y);
- void readFields();
- void printFields() const;
- bool isInRange(const Vector& v) const;
- char getChar(int x, int y) const;
- void toString(String& s) const;
- void lineToString(String& s, int y) const;
-
- bool areNeighbours(const Vector& from, const Vector& to) const;
-
- void removeLine(const Vector& from, const Vector& to, FieldState state);
- uint getRank(const Vector& from, const Vector& to, FieldState state) const;
- uint getStoneTakes(const Vector& from, const Vector& to) const;
- uint getStoneFreedom(const Vector& from) const;
- uint getFreedom(FieldState state) const;
- bool hasState(const Vector& v, FieldState state) const;
- FieldState getState(const Vector& v) const;
- void setState(const Vector& v, FieldState state);
-
- void move(const Vector& from, const Vector& to);
-
- void makeSelection();
- void makeMove();
- void takeStone();
-
- int getQuality(const Vector& from, const Vector& to) const;
-
- int countBlack() const;
-
- bool isTakingPossible() const;
- FieldState fields[9][5];
- Vector active;
- Vector direction;
- bool mustTake;
-
- List<Vector, 20> lastLocations;
- static std::array<Vector, 8> neighbours;
- static std::array<Vector, 9 * 5> fieldVectors;
- };
- #endif
|