if((penguin_copy&7)>rel_move)//If the penguin total moves in this direction are greater than the move we want to do for it (not equal because moves start at 0)
if(PENGUIN_MOVES_A(*p)>rel_move)//If the penguin total moves in this direction are greater than the move we want to do for it (not equal because moves start at 0)
{
{
//Move direction A
//Move direction A
(*p)=(7*(rel_move+1))+((*p)&63);
(*p)=(7*(rel_move+1))+((*p)&63);
return;
return;
}
}
rel_move-=penguin_copy&7;
rel_move-=PENGUIN_MOVES_A(*p);
penguin_copy=penguin_copy>>3;
if(PENGUIN_MOVES_B(*p)>rel_move)
if((penguin_copy&7)>rel_move)
{
{
//Move direction B
//Move direction B
(*p)=(-1*(rel_move+1))+((*p)&63);
(*p)=(-1*(rel_move+1))+((*p)&63);
return;
return;
}
}
rel_move-=penguin_copy&7;
rel_move-=PENGUIN_MOVES_B(*p);
penguin_copy=penguin_copy>>3;
if(PENGUIN_MOVES_C(*p)>rel_move)
if((penguin_copy&7)>rel_move)
{
{
//Move direction C
//Move direction C
(*p)=(-8*(rel_move+1))+((*p)&63);
(*p)=(-8*(rel_move+1))+((*p)&63);
return;
return;
}
}
rel_move-=penguin_copy&7;
rel_move-=PENGUIN_MOVES_C(*p);
penguin_copy=penguin_copy>>3;
if(PENGUIN_MOVES_D(*p)>rel_move)
if((penguin_copy&7)>rel_move)
{
{
//Move direction D
//Move direction D
(*p)=(-7*(rel_move+1))+((*p)&63);
(*p)=(-7*(rel_move+1))+((*p)&63);
return;
return;
}
}
rel_move-=penguin_copy&7;
rel_move-=PENGUIN_MOVES_D(*p);
penguin_copy=penguin_copy>>3;
if(PENGUIN_MOVES_E(*p)>rel_move)
if((penguin_copy&7)>rel_move)
{
{
//Move direction E
//Move direction E
(*p)=(1*(rel_move+1))+((*p)&63);
(*p)=(1*(rel_move+1))+((*p)&63);
return;
return;
}
}
rel_move-=penguin_copy&7;
rel_move-=PENGUIN_MOVES_E(*p);
penguin_copy=penguin_copy>>3;
//Move direction F
//Move direction F
(*p)=(8*(rel_move+1))+((*p)&63);
(*p)=(8*(rel_move+1))+((*p)&63);
}
}
...
@@ -268,39 +262,36 @@ namespace game
...
@@ -268,39 +262,36 @@ namespace game
{
{
/* We search for the first penguin that can make the move. If a penguin can't, we will decrese the move number
/* We search for the first penguin that can make the move. If a penguin can't, we will decrese the move number
by the number of moves that he can do */
by the number of moves that he can do */
#define TOT_MOVES(penguin) ((penguin >> 6) & 63)
for(i=0;(i<3)&&(PENGUIN_TOT_MOVES(state.peng_red[i])<=rel_move);i++)//While we didn't find the penguin
for(i=0;(i<3)&&(TOT_MOVES(state.peng_red[i])<=rel_move);i++)//While we didn't find the penguin
rel_move-=PENGUIN_TOT_MOVES(state.peng_red[i]);
rel_move-=TOT_MOVES(state.peng_red[i]);
// Now i is the number of the penguin that will move and rel_move is the move relative to this penguin (because we decreased it)
// Now i is the number of the penguin that will move and rel_move is the move relative to this penguin (because we decreased it)
peng=&state.peng_red[i];
peng=&state.peng_red[i];
}
}
else//If blue
else//If blue
{
{
#define TOT_MOVES(penguin) ((penguin >> 6) & 63)
for(i=0;(i<3)&&(PENGUIN_TOT_MOVES(state.peng_blue[i])<=rel_move);i++)//While we didn't find the penguin
for(i=0;(i<3)&&(TOT_MOVES(state.peng_blue[i])<=rel_move);i++)//While we didn't find the penguin
rel_move-=PENGUIN_TOT_MOVES(state.peng_blue[i]);
rel_move-=TOT_MOVES(state.peng_blue[i]);
peng=&state.peng_blue[i];
peng=&state.peng_blue[i];
}
}
// ADD PENGUIN TILE TO THE SCORE
// ADD PENGUIN TILE TO THE SCORE
#define POS(penguin) ((penguin) & 63)
if((state.one_fish>>PENGUIN_POS(*peng))&1)//If there is a one fish on this position
if((state.one_fish>>POS(*peng))&1)//If there is a one fish on this position
{
{
if(state.current_player_red)
if(state.current_player_red)
state.score_red+=1;
state.score_red+=1;
else
else
state.score_blue+=1;
state.score_blue+=1;
//We replace this tile with an empty one (0 in the bitboard)
//We replace this tile with an empty one (0 in the bitboard)