X-Git-Url: http://winboard.nl/cgi-bin?p=bonanza.git;a=blobdiff_plain;f=csa.c;h=f1f04793f0109f6ac1bf953301ba4c7472d95215;hp=cbf1bf6f67e62e39bf647ba96705c95c89844d66;hb=9643e6faeeedc4db50b7aaf27c650d4e9093092a;hpb=f6f230d5a10864715c8ec866aec516a27535b17d diff --git a/csa.c b/csa.c index cbf1bf6..f1f0479 100644 --- a/csa.c +++ b/csa.c @@ -462,7 +462,13 @@ read_board_rep1( const char *str_line, min_posi_t *pmin_posi ) 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 ) @@ -472,6 +478,18 @@ read_board_rep1( const char *str_line, min_posi_t *pmin_posi ) 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'; @@ -481,12 +499,24 @@ read_board_rep1( const char *str_line, min_posi_t *pmin_posi ) 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; }