-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgame.hpp
72 lines (56 loc) · 1.73 KB
/
game.hpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
#ifndef GAME_H_
#define GAME_H_
#include <cstdint>
#include <optional>
#include <vector>
typedef enum tileState {B=0, W=1, E=2} Tile;
class Move;
class Game {
public:
// The current state of the game board
unsigned int numTiles;
unsigned int size;
Tile **board;
// The the number of colored tiles in each row and col
std::vector<unsigned int> rowB;
std::vector<unsigned int> colB;
std::vector<unsigned int> rowW;
std::vector<unsigned int> colW;
// Constructors/Destructor
Game(unsigned int size, Tile state[]);
Game(const Game &other);
~Game();
friend std::ostream & operator<<(std::ostream &os, Game const &game);
/* Verifies that the game has been solved */
bool verifySolved();
/* Returns a sorted vector of valid moves to try
* - Return: sorted vector of moves
* - Caller is responsible for freeing vector
* [Currently Unused]
*/
std::vector<Move> *generateMoves();
/* Checks if a move is valid */
bool isValid(Tile color, unsigned int row, unsigned int col);
/* Applies a move to the board. Does not check for validity */
void apply(const Move &m);
/* Undies an applied move to the board. */
void undo(const Move &m);
/* Verify internal representation */
bool checkrep();
/* Ensures that every non-empty tile has at least one valid move
* - overloaded if only one row/column needs to be checked
*/
bool isWinnable();
};
std::ostream & operator<<(std::ostream &, Game const &);
class Move {
public:
// The tile and location
Tile color;
unsigned int row;
unsigned int col;
Move(Tile color, unsigned int row, unsigned int col);
Move(const Move &o);
~Move();
};
#endif // GAME_H_