From 4f27362e708352dfd612b9df8aece4213e645e01 Mon Sep 17 00:00:00 2001 From: Francesco Bariatti <francesco.bariatti@insa-rennes.fr> Date: Tue, 17 May 2016 18:41:43 +0200 Subject: [PATCH] Implemented score update in play() with arrays --- AI/src/game/penguin.cpp | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/AI/src/game/penguin.cpp b/AI/src/game/penguin.cpp index bec187b..180ab43 100644 --- a/AI/src/game/penguin.cpp +++ b/AI/src/game/penguin.cpp @@ -280,37 +280,36 @@ namespace game } // ADD PENGUIN TILE TO THE SCORE - - /* - //TODO: implements methods with arrays - if ((state.one_fish >> position) & 1) + #define POS(penguin) ((penguin) & 63) + if((state.one_fish >> POS(*peng)) & 1) //If there is a one fish on this position { - if(current_player() == RED) + if(state.current_player_red) state.score_red += 1; else state.score_blue += 1; //We replace this tile with an empty one (0 in the bitboard) - state.one_fish = state.one_fish & ~(((uint64_t) 1) << position); + state.one_fish = state.one_fish & ~(((uint64_t) 1) << POS(*peng)); } - else if ((state.two_fish >> position) & 1) + else if((state.two_fish >> POS(*peng)) & 1) { - - if(current_player() == RED) + if(state.current_player_red) state.score_red += 2; else state.score_blue += 2; //We replace this tile with an empty one (0 in the bitboard) - state.two_fish = state.two_fish & ~(((uint64_t) 1) << position); + state.two_fish = state.two_fish & ~(((uint64_t) 1) << POS(*peng)); } else { - if(current_player() == RED) + if(state.current_player_red) state.score_red += 3; else state.score_blue += 3; //We replace this tile with an empty one (0 in the bitboard) - state.three_fish = state.three_fish & ~(((uint64_t) 1) << position); + state.one_fish = state.one_fish & ~(((uint64_t) 1) << POS(*peng)); } + /* + //TODO: implements methods with arrays //Move the current penguin move_penguin(p); -- GitLab