-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathUnitReversi.h
66 lines (57 loc) · 3.08 KB
/
UnitReversi.h
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
//---------------------------------------------------------------------------
/*
Reversi, a simple board game
Copyright (C) 2007 Richel Bilderbeek
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
//---------------------------------------------------------------------------
// From http://www.richelbilderbeek.nl
//---------------------------------------------------------------------------
#ifndef UnitReversiH
#define UnitReversiH
//---------------------------------------------------------------------------
#include <vector>
enum Square { empty, player1, player2 };
//---------------------------------------------------------------------------
struct Reversi
{
Reversi(const int size);
const std::vector<std::vector<Square> >& GetBoard() const;
const Square GetSquare(const int x, const int y) const;
void DoMove(const int x, const int y, const Square player);
void SetSquare(const int x, const int y, const Square player);
const bool IsValidMove(const int x, const int y, const Square player) const;
const std::vector< std::pair<int,int> > GetValidMoves(const Square player) const;
const int GetSize() const;
const int Count(const Square player) const;
private:
std::vector<std::vector<Square> > mBoard;
const bool IsValidMoveUp(const int x, const int y, const Square player) const;
const bool IsValidMoveUpLeft(const int x, const int y, const Square player) const;
const bool IsValidMoveLeft(const int x, const int y, const Square player) const;
const bool IsValidMoveDownLeft(const int x, const int y, const Square player) const;
const bool IsValidMoveDown(const int x, const int y, const Square player) const;
const bool IsValidMoveDownRight(const int x, const int y, const Square player) const;
const bool IsValidMoveRight(const int x, const int y, const Square player) const;
const bool IsValidMoveUpRight(const int x, const int y, const Square player) const;
void DoMoveUp(const int x, int y, const Square player);
void DoMoveUpLeft(int x, int y, const Square player);
void DoMoveLeft(int x, const int y, const Square player);
void DoMoveDownLeft(int x, int y, const Square player);
void DoMoveDown(const int x, int y, const Square player);
void DoMoveDownRight(int x, int y, const Square player);
void DoMoveRight(int x, const int y, const Square player);
void DoMoveUpRight(int x, int y, const Square player);
};
const Square GetSquareXy(const std::vector<std::vector<Square> >& board, const int x, const int y);
const Square GetOtherPlayer(const Square player);
#endif