diff --git a/src/game/morpion.cpp b/src/game/morpion.cpp index e3445cee3c3e53ba93c90aa34e1ba11dbb41cc1c..0934698f84c92fb6b83edc3ea651182b83a44d7f 100644 --- a/src/game/morpion.cpp +++ b/src/game/morpion.cpp @@ -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; } diff --git a/src/game/morpion.hpp b/src/game/morpion.hpp index 327f1b5afcd72f9dd94535a6a2d7797a753f90dc..f8c7cc7d3222a95512d0522e2a40a79881bb412c 100644 --- a/src/game/morpion.hpp +++ b/src/game/morpion.hpp @@ -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 };