From c4140fccb0c892aa522a6bc51ae337e60787b541 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adrien=20Gast=C3=A9?= <adrien.gaste@insa-rennes.fr> Date: Mon, 9 Nov 2015 11:29:20 +0100 Subject: [PATCH] Implemented/added function updates_moves Create a list of all possible moves --- src/game/morpion.cpp | 14 +++++++++++--- src/game/morpion.hpp | 1 + 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/src/game/morpion.cpp b/src/game/morpion.cpp index 0934698..13c09b7 100644 --- a/src/game/morpion.cpp +++ b/src/game/morpion.cpp @@ -112,12 +112,20 @@ namespace game return false; } - /* + void morpion::update_moves(uint16_t move) { - //TODO: Implement + uint16_t free_bitboard = ~(state.cross_bitboard | state.circle_bitboard); + for(int i = 0; i <=8; i++) + { + if(free_bitboard & 1) + { + state.possible_moves += i; + state.possible_moves << 4; + } + free_bitboard = free_bitboard >> 1; + } } - */ void morpion::play(uint16_t m) { diff --git a/src/game/morpion.hpp b/src/game/morpion.hpp index f8c7cc7..17552e4 100644 --- a/src/game/morpion.hpp +++ b/src/game/morpion.hpp @@ -50,6 +50,7 @@ namespace game inline void update_win(); //Check if someone won and update the state inline bool has_won(uint16_t bitboard); //Check if the player whose bitboard was passed as a param has won inline bool get(uint16_t bitboard, uint8_t i, uint8_t j) const; //Get a case of the board + inline void update_moves(uint16_t move); //Update the list of all possible moves const uint8_t CROSS = 0; const uint8_t CIRCLE = 1; -- GitLab