Skip to content
Snippets Groups Projects
Commit c0a53356 authored by Gaste Adrien's avatar Gaste Adrien
Browse files

Implemented play function

parent 2206bbd9
No related branches found
No related tags found
No related merge requests found
......@@ -121,7 +121,16 @@ namespace game
void morpion::play(uint16_t m)
{
uint16_t bitboard = state.cross_bitboard | state.circle_bitboard;
uint16_t position = (state.possible_moves >> 4*m) & 15; //15 is the mask to get only one move
if (current_player() == CROSS)
state.cross_bitboard += 1 << position;
else
state.circle_bitboard += 1 << position;
//State update
state.total_moves++;
update_win();
update_moves();
return;
}
......
......@@ -14,6 +14,7 @@ namespace game
uint16_t cross_bitboard = 0; //bitboard with the played moves of the cross
uint16_t circle_bitboard = 0; //bitboard with the played moves of the circle
uint8_t total_moves = 0; //Total played moves (<= 9)
uint64_t possible_moves = 0x876543210; //List of possible moves left
bool first_player_win = false; //First player is always the cross
bool second_player_win = false; //Second player is always the circle
};
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment