char str_piece[3];
int piece, ifile, irank, isquare;
signed char board[nsquare];
+ int add = 0, color = -1;
+ if( *str_line == 'S' ) { // [HGM] setup: allow 'SU' representation that adds pieces in stead of removing them
+ add = 1;
+ for ( isquare = 0; isquare < nsquare; isquare++ ) board[isquare] = empty;
+ pmin_posi->hand_white = pmin_posi->hand_black = 0;
+ } else
memcpy( board, &min_posi_no_handicap.asquare, nsquare );
for ( p = str_line + 2; p[0] != '\0'; p += 4 )
str_error = str_bad_board;
return -2;
}
+ if( add && p[0] == '+' ) // [HGM] setup: change color
+ {
+ color = 1;
+ p -= 3;
+ continue;
+ }
+ if( add && p[0] == '-' )
+ {
+ color = -1;
+ p -= 3;
+ continue;
+ }
str_piece[0] = p[2];
str_piece[1] = p[3];
str_piece[2] = '\0';
ifile = 9 - ifile;
irank = irank - 1;
isquare = irank * nfile + ifile;
+ if ( add && piece != -2 && p[0] == '0' && p[1] == '0' )
+ { // [HGM] setup: holdings
+ static int unit[] = {0, 1, 1<<5, 1<<8, 1<<11, 1<<14, 1<<17, 1<<19};
+ if(piece < 1 || piece > 7) { // only unpromoted in hand!
+ str_error = str_bad_board;
+ return -2;
+ }
+ if(color > 0) pmin_posi->hand_black += unit[piece];
+ else pmin_posi->hand_white += unit[piece];
+ continue;
+ }
if ( piece == -2 || ifile < file1 || ifile > file9 || irank < rank1
- || irank > rank9 || abs(board[isquare]) != piece )
+ || irank > rank9 || abs(board[isquare]) != (add ? empty : piece) )
{
str_error = str_bad_board;
return -2;
}
+ if( add ) board[isquare] = piece*color; else
board[isquare] = empty;
}