uint8_tmove_number=((*p)>>6)&63;//Move number for the current penguin
uint32_tpenguin_copy=(*p)>>12;
//Direction A
if((penguin_copy&7)>move_number)
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
(*p)=(7*(move_number+1))+((*p)&63);
(*p)=(7*(rel_move+1))+((*p)&63);
return;
}
move_number-=penguin_copy&7;
penguin_copy=penguin_copy>>3;
if((penguin_copy&7)>move_number)
rel_move-=PENGUIN_MOVES_A(*p);
if(PENGUIN_MOVES_B(*p)>rel_move)
{
//Move direction B
(*p)=(-1*(move_number+1))+((*p)&63);
(*p)=(-1*(rel_move+1))+((*p)&63);
return;
}
move_number-=penguin_copy&7;
penguin_copy=penguin_copy>>3;
if((penguin_copy&7)>move_number)
rel_move-=PENGUIN_MOVES_B(*p);
if(PENGUIN_MOVES_C(*p)>rel_move)
{
//Move direction C
(*p)=(-8*(move_number+1))+((*p)&63);
(*p)=(-8*(rel_move+1))+((*p)&63);
return;
}
move_number-=penguin_copy&7;
penguin_copy=penguin_copy>>3;
if((penguin_copy&7)>move_number)
rel_move-=PENGUIN_MOVES_C(*p);
if(PENGUIN_MOVES_D(*p)>rel_move)
{
//Move direction D
(*p)=(-7*(move_number+1))+((*p)&63);
(*p)=(-7*(rel_move+1))+((*p)&63);
return;
}
move_number-=penguin_copy&7;
penguin_copy=penguin_copy>>3;
if((penguin_copy&7)>move_number)
rel_move-=PENGUIN_MOVES_D(*p);
if(PENGUIN_MOVES_E(*p)>rel_move)
{
//Move direction E
(*p)=(1*(move_number+1))+((*p)&63);
(*p)=(1*(rel_move+1))+((*p)&63);
return;
}
move_number-=penguin_copy&7;
penguin_copy=penguin_copy>>3;
rel_move-=PENGUIN_MOVES_E(*p);
//Move direction F
(*p)=(8*(move_number+1))+((*p)&63);
(*p)=(8*(rel_move+1))+((*p)&63);
}
/* Create bitboard of obstacles: 1 if there is an obstacle, 0 if the penguin can
(*p)=pos;//Reset the penguin to all zeros except the position
inti=pos;
uint32_tnbmoves=0;
uint32_tnbmoves=0;//Nb of moves in one direction
uint32_ttotal_moves=0;
//Direction A
...
...
@@ -335,68 +259,74 @@ namespace game
//Play the mth move in the possible moves list.
voidpenguin::play(uint16_tm)
{
//CAN WE PLAY?
// We check if we can effectively play: if yes, the move is parsed and player, otherwise we do nothing (the move can be whatever, we won't look at it, so the player actually skip the turn)