Skip to content
Snippets Groups Projects
Commit 793a36bf authored by Bariatti Francesco's avatar Bariatti Francesco
Browse files

Bugfix: penguin couldn't move in direction C to the tile 0

parent 44dd96ac
No related branches found
No related tags found
No related merge requests found
......@@ -46,7 +46,7 @@ namespace game
if(json_state["score"].count("red")) { state.score_red = json_state["score"]["red"]; }
if(json_state["score"].count("blue")) { state.score_blue = json_state["score"]["blue"]; }
}
//Update moves on all penguins
uint64_t obstacles = (~(state.one_fish | state.two_fish | state.three_fish));
obstacles |= ((uint64_t) 1) << (state.p1_red & 63);
......@@ -68,7 +68,7 @@ namespace game
state.nb_moves_blue += update_moves(&state.p2_blue, obstacles);
state.nb_moves_blue += update_moves(&state.p3_blue, obstacles);
state.nb_moves_blue += update_moves(&state.p4_blue, obstacles);
if (state.nb_moves_red == 0)
{
state.canPlay_red = false;
......@@ -294,7 +294,7 @@ namespace game
//Direction C
nbmoves = 0;
i = pos;
while((i-8 > 0) && (i%15 != 0) && IsFree(i-8))
while((i-8 >= 0) && (i%15 != 0) && IsFree(i-8))
{
i -= 8;
nbmoves++; total_moves++;
......@@ -388,7 +388,7 @@ namespace game
state.nb_moves_red = 0;
state.nb_moves_blue = 0;
if (state.current_player_red) //Red just played
{
if(state.canPlay_blue)
......@@ -407,7 +407,7 @@ namespace game
{
state.nb_moves_blue = 1;
}
state.current_player_red = false;
}
else //Blue just played
......@@ -428,7 +428,7 @@ namespace game
{
state.nb_moves_red = 1;
}
state.current_player_red = true;
}
}
......@@ -476,7 +476,7 @@ namespace game
json_state["possible_moves"]["blue"] = state.nb_moves_blue;
json_state["current_player"] = state.current_player_red ? "Red" : "Blue";
json_state["can_play"]["red"] = state.canPlay_red;
json_state["can_play"]["blue"] = state.canPlay_blue;
......
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