-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathBoard.h
81 lines (70 loc) · 1.47 KB
/
Board.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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
// Board.h
// June 13th, 2017
// Ahmed Hussein ([email protected])
#ifndef BOARD_H_
#define BOARD_H_
#include "vector"
#include "list"
#include "Move.h"
#include "Piece.h"
#include "string"
namespace Shatranj
{
class Square
{
public:
Square();
Square(const Square& oSquare);
~Square();
Square& operator=(const Square& oSquare);
void Reset();
int GetFile() const;
int GetRank() const;
Piece* GetPiece() const;
void SetFile(const int& iFile);
void SetRank(const int& iRank);
bool CapturePiece(Piece* poNewPiece);
bool PutPiece(Piece* poPiece);
bool MovePiece();
bool IsEmpty() const;
bool IsWhite() const;
bool IsBlack() const;
std::string GetSymbol() const;
private:
protected:
void Initialize();
int m_iRank;
int m_iFile;
Piece* m_poPiece;
};
class Board
{
public:
Board();
~Board();
void Reset();
Square* GetSquare(const int& iRank,const int& iFile) const;
bool IsWhiteInCheck() const;
bool IsBlackInCheck() const;
void ApplyMove(Move* poMove);
Move* GetLastMove() const;
void GenerateInitialState();
void GenerateRandomState();
void Show() const;
private:
// do not copy or equate boards
Board(const Board& oBoard);
Board& operator=(const Board& oBoard);
protected:
void Initialize();
void ClearBoard();
void BuildBoard();
void ClearPieces();
std::vector<Square*> m_vpoSquares;
bool m_bIsWhiteCheck;
bool m_bIsBlackCheck;
std::list<Move*> m_lpoMoves;
std::list<Piece*> m_lpoPieces;
};
}
#endif