Newer
Older
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
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
#include "penguin.hpp"
#include <sstream>
using namespace std;
namespace game
{
penguin::penguin()
{
}
shared_ptr<game<penguin_state>> penguin::do_copy() const
{
return shared_ptr<penguin>(new penguin(*this));
}
penguin_state penguin::get_state()
{
return state;
}
void penguin::set_state(const penguin_state& s)
{
state = s;
}
bool penguin::end_of_game() const
{
return false;
//return state.first_player_win || state.second_player_win || state.total_moves == 9;
}
bool penguin::won(std::uint8_t player) const
{
return false;
//if (player == CROSS) return state.first_player_win;
//return state.second_player_win;
}
bool penguin::lost(std::uint8_t player) const
{
return false;
/*if (player == CIRCLE) return state.first_player_win;
return state.second_player_win;*/
}
bool penguin::draw(std::uint8_t player) const
{
return false;
/*if (state.first_player_win || state.second_player_win) return false;
return state.total_moves == 9;*/
}
uint8_t penguin::current_player() const
{
return 0;
/*return state.total_moves & 1 ? CIRCLE : CROSS; // CROSS even, CIRCLE odd*/
}
int penguin::value(uint8_t player) const
{
/*if (player == CROSS) {
return state.first_player_win ? 1 : (state.second_player_win ? -1 : 0);
}
else if (player == CIRCLE) {
return state.second_player_win ? 1 : (state.first_player_win ? -1 : 0);
}
return 0;*/
return 0;
}
/* Number of moves that you can play */
uint16_t penguin::number_of_moves() const
{
//return 9 - state.total_moves;
return 0;
}
//Play the mth move in the possible moves list.
void penguin::play(uint16_t m)
{
/*uint64_t possible_moves = state.possible_moves;
possible_moves = possible_moves >> 4*m; //A move is coded with 4 bit
uint16_t move = possible_moves & 15; //15 = 1111
//cout << "You choose the possible move number " << m << endl;
//cout << "You choose move " << move << endl;
if (current_player() == CROSS)
state.cross_bitboard |= (((uint16_t) 1) << move);
else
state.circle_bitboard |= (((uint16_t) 1) << move);
//State update
state.total_moves++;
update_win();
update_moves();
return;*/
}
string penguin::player_to_string(uint8_t player) const
{
//return player == CROSS ? "X" : (player == CIRCLE ? "O" : " ");
return "TODO";
}
string penguin::move_to_string(uint16_t m) const
{
//return std::to_string((state.possible_moves >> (4 * m)) & 0xf);
return "TODO";
}
set<int> penguin::to_input_vector() const
{
return set<int>();
}
void penguin::from_input_vector(const std::set<int>& input)
{
}
string penguin::to_string() const
{
/*string result = "-------\n";
for (int row = 2; row >= 0; row--)
{
result += "|";
for (int col = 2; col >= 0; col--)
{
if(((state.cross_bitboard >> (3*row)) >> col) & 1)
result += player_to_string(CROSS)+"|";
else if (((state.circle_bitboard >> (3*row)) >> col) & 1)
result += player_to_string(CIRCLE)+"|";
else
result += std::to_string(row * 3 + col) + "|";
}
result += "\n-------\n";
}
return result;
*/
return "TODO";
}
std::uint64_t penguin::hash() const
{
return 0;
}
std::uint64_t penguin::hash(std::uint16_t m) const
{
return 0;
}
ostream& operator<<(ostream& os, const penguin& pen)
{
os << pen.to_string() << endl;
return os;
}
}