-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathGame.hpp
108 lines (87 loc) · 1.8 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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
#pragma once
#ifndef GAME_HPP_
#define GAME_HPP_
#include "BitBoard.hpp"
#include "Save.hpp"
#include <map>
#include <string>
#include <vector>
#include <utility>
class SimpleAI;
class Game {
public:
friend class SimpleAI;
friend class NewAI;
friend class SFMLGame;
/* Constructor */
Game(const bool debug, const bool interact);
/* Constructor from memory */
Game(const Save& record, const bool debug, const bool interact);
/* Destructor */
virtual ~Game();
/* return save game */
Save getSave();
/* Print game */
void print() const;
/* Movement */
MoveCode move(const Move& move)
{
if (move.jump)
return jump(move);
else
return makeMove(move);
}
/* restore game to save */
void restoreToSave(const Save& record);
/* Receive input for CLI */
MoveCode receiveInput();
/* Get p1 score */
unsigned getP1score() const
{
return Bit::bitCount(mBP & ~mK) + 2 * Bit::bitCount(mBP & mK);
}
/* Get p2 score */
unsigned getP2score() const
{
return Bit::bitCount(mWP & ~mK) + 2 * Bit::bitCount(mWP & mK);
}
int grade() const;
unsigned p1NumPieces() const
{
return Bit::bitCount(mBP);
}
unsigned p2NumPieces() const
{
return Bit::bitCount(mWP);
}
bool isLive() const
{
return (getMovers() || getJumpers());
}
std::vector<Cell> toArr() const;
private:
BitBoard mWP;
BitBoard mBP;
BitBoard mK;
typedef BitBoard BB;
/* Tracks if it's P1's turn or not */
bool mTurn;
bool mDebug;
Save mSave;
bool mInteract;
BB mMustJump;
/* Update save game */
void updateSave();
BitBoard getJumpers() const;
BitBoard getMovers() const;
BitBoard getEmpty() const
{
return ~(mWP | mBP);
}
inline BB canJump(const BB src, const BB vict);
/* Piece Movement */
MoveCode makeMove(const Move& move);
/* Jumping */
MoveCode jump(const Move& move);
};
#endif /* GAME_HPP_ */