X-Git-Url: http://winboard.nl/cgi-bin?p=capablanca.git;a=blobdiff_plain;f=lasker-2.2.3%2Fsrc%2Fboard.c;h=8c9247377a68002308a89b2da702211ca622bb1f;hp=5c974f166445877fb4a60c2c53b8e4ef19d9de7e;hb=ec7b6bb32ba9632cda17b308808ce9ba1e27c090;hpb=fc8a38817986f2ad7a034db0d413762e509a7cac diff --git a/lasker-2.2.3/src/board.c b/lasker-2.2.3/src/board.c index 5c974f1..8c92473 100644 --- a/lasker-2.2.3/src/board.c +++ b/lasker-2.2.3/src/board.c @@ -23,12 +23,12 @@ #include "includes.h" -const char *wpstring[] = {" ", "P", "N", "B", "R", "A", "C", "M", "Q", "E", "B", "Q", "W", "H", "N", "J", "I", "L", - "C", "S", "G", "H", "A", "F", "E", "H", "M", "S", "E", "W", "O", "G", "V", "S", "E", "A", "K"}; -const char *bpstring[] = {" ", "p", "n", "b", "r", "a", "c", "m", "q", "e", "b", "q", "w", "h", "n", "j", "i", "l", - "c", "s", "g", "h", "a", "f", "e", "h", "m", "s", "e", "w", "o", "g", "v", "s", "e", "a", "k"}; +const char *wpstring[] = {" ", "P", "N", "B", "R", "A", "C", "M", "Q", "E", "B", "Q", "W", "H", "N", "D", "H", "L", + "C", "S", "G", "H", "A", "F", "E", "H", "M", "S", "E", "W", "O", "G", "V", "S", "E", "A", "K", "H", "E"}; +const char *bpstring[] = {" ", "p", "n", "b", "r", "a", "c", "m", "q", "e", "b", "q", "w", "h", "n", "d", "h", "l", + "c", "s", "g", "h", "a", "f", "e", "h", "m", "s", "e", "w", "o", "g", "v", "s", "e", "a", "k", "h", "e"}; -int pieceValues[KING+1] = {0, 1, 3, 3, 5, 8, 9, 3, 9, 1, 1, 2, 2, 2, 1, 6, 5, 2, 3, 3, 3, 1, 5, 2, 1, 7, 7, 3, 3, 3, 7, 7, 7, 8, 9, 12, 0}; +int pieceValues[PIECES] = {0, 1, 3, 3, 5, 8, 9, 3, 9, 1, 1, 2, 2, 2, 1, 6, 5, 2, 3, 3, 3, 1, 5, 2, 1, 7, 7, 3, 3, 3, 7, 7, 7, 8, 9, 12, 0, 8, 9}; static const int mach_type = (1<<7) | (1<<8) | (1<<9) | (1<<10) | (1<<11); #define IsMachineStyle(n) (((1<<(n)) & mach_type) != 0) @@ -78,7 +78,7 @@ static void reset_board_vars(struct game_state_t *gs) for (f = 0; f < 2; f++) { for (r = 0; r < BW; r++) gs->ep_possible[f][r] = 0; - for (r = PAWN; r <= KING-1; r++) + for (r = PAWN; r <= PIECES-1; r++) gs->holding[f][r-PAWN] = 0; } gs->wkmoved = gs->wqrmoved = gs->wkrmoved = -1; // [HGM] castle: no rights @@ -103,42 +103,42 @@ void board_standard(struct game_state_t *gs) { int f,r; - for (f = 0; f < BW; f++) - for (r = 0; r < BH; r++) - gs->board[f][r] = NOPIECE; - for (f = 0; f < gs->files; f++) - gs->board[f][gs->ranks-7] = W_PAWN; - for (f = 0; f < gs->files; f++) - gs->board[f][6] = B_PAWN; - gs->board[0][0] = W_ROOK; - gs->board[1][0] = W_KNIGHT; - gs->board[2][0] = W_BISHOP; - gs->board[3][0] = W_QUEEN; - gs->board[gs->files/2][0] = W_KING; - gs->board[gs->files-3][0] = W_BISHOP; - gs->board[gs->files-2][0] = W_KNIGHT; - gs->board[gs->files-1][0] = W_ROOK; - gs->board[0][gs->ranks-1] = B_ROOK; - gs->board[1][gs->ranks-1] = B_KNIGHT; - gs->board[2][gs->ranks-1] = B_BISHOP; - gs->board[3][gs->ranks-1] = B_QUEEN; - gs->board[gs->files/2][gs->ranks-1] = B_KING; - gs->board[gs->files-3][gs->ranks-1] = B_BISHOP; - gs->board[gs->files-2][gs->ranks-1] = B_KNIGHT; - gs->board[gs->files-1][gs->ranks-1] = B_ROOK; + for (f = 0; f < BW; f++) + for (r = 0; r < BH; r++) + gs->board[f][r] = NOPIECE; + for (f = 0; f < gs->files; f++) + gs->board[f][gs->ranks-7] = W_PAWN; + for (f = 0; f < gs->files; f++) + gs->board[f][6] = B_PAWN; + gs->board[0][0] = W_ROOK; + gs->board[1][0] = W_KNIGHT; + gs->board[2][0] = W_BISHOP; + gs->board[3][0] = W_QUEEN; + gs->board[gs->files/2][0] = W_KING; + gs->board[gs->files-3][0] = W_BISHOP; + gs->board[gs->files-2][0] = W_KNIGHT; + gs->board[gs->files-1][0] = W_ROOK; + gs->board[0][gs->ranks-1] = B_ROOK; + gs->board[1][gs->ranks-1] = B_KNIGHT; + gs->board[2][gs->ranks-1] = B_BISHOP; + gs->board[3][gs->ranks-1] = B_QUEEN; + gs->board[gs->files/2][gs->ranks-1] = B_KING; + gs->board[gs->files-3][gs->ranks-1] = B_BISHOP; + gs->board[gs->files-2][gs->ranks-1] = B_KNIGHT; + gs->board[gs->files-1][gs->ranks-1] = B_ROOK; #if 1 - if(gs->files == 10) { - gs->board[6][0] = W_CARDINAL; - gs->board[4][0] = W_MARSHALL; - gs->board[6][gs->ranks-1] = B_CARDINAL; - gs->board[4][gs->ranks-1] = B_MARSHALL; - } - if(gs->royalKnight) { - gs->board[1][0] = W_MAN; - gs->board[gs->files-2][0] = W_MAN; - gs->board[1][gs->ranks-1] = B_MAN; - gs->board[gs->files-2][gs->ranks-1] = B_MAN; - } + if(gs->files == 10) { + gs->board[6][0] = W_CARDINAL; + gs->board[4][0] = W_MARSHALL; + gs->board[6][gs->ranks-1] = B_CARDINAL; + gs->board[4][gs->ranks-1] = B_MARSHALL; + } + if(gs->royalKnight) { + gs->board[1][0] = W_MAN; + gs->board[gs->files-2][0] = W_MAN; + gs->board[1][gs->ranks-1] = B_MAN; + gs->board[gs->files-2][gs->ranks-1] = B_MAN; + } #endif reset_board_vars(gs); @@ -156,9 +156,9 @@ int board_init(int g,struct game_state_t *b, char *category, char *board) int retval = 0; int wval, i, j; - b->files = b->ranks = 8; - b->pawnDblStep = (!category || strcmp(category, "shatranj")); - b->royalKnight = (category && !strcmp(category, "knightmate")); + b->files = b->ranks = 8; + b->pawnDblStep = (!category || strcmp(category, "shatranj")); + b->royalKnight = (category && !strcmp(category, "knightmate")); b->capablancaPieces = 0; b->holdings = 0; b->drops = 0; @@ -168,24 +168,25 @@ int board_init(int g,struct game_state_t *b, char *category, char *board) b->bareKingLoses = 0; b->stalemate = 1; b->promoType = 1; - b->variant[0] = 0; // [HGM] variant: default is normal, if variant name is missing - if (!category || !board || !category[0] || !board[0]) - /* accounts for bughouse too */ - board_standard(b); + b->promoZone = 1; + b->variant[0] = 0; // [HGM] variant: default is normal, if variant name is missing + if (!category || !board || !category[0] || !board[0]) + /* accounts for bughouse too */ + board_standard(b); else { - if(category && category[0]) strcpy(b->variant, category); // [HGM] variant: remember category name + if(category && category[0]) strcpy(b->variant, category); // [HGM] variant: remember category name if (!strcmp(category, "wild") && sscanf(board, "%d", &wval) == 1) { - if(wval >= 1 && wval <= 4) + if(wval >= 1 && wval <= 4) wild_update(b->board, wval); - sprintf(b->variant, "wild/%d", wval); + sprintf(b->variant, "wild/%d", wval); } if (board && !strcmp(board, "0")) - b->setup = 0; // [HGM] variant: any board in the default file "0" is supposed to be implied by the variant + b->setup = 0; // [HGM] variant: any board in the default file "0" is supposed to be implied by the variant - if (!strcmp(category, "knightmate")) { - board_standard(b); - } else if (!strcmp(category, "super")) { + if (!strcmp(category, "knightmate")) { + board_standard(b); + } else if (!strcmp(category, "super")) { board_standard(b); b->holdings = 1; b->promoType = 2; @@ -202,17 +203,17 @@ int board_init(int g,struct game_state_t *b, char *category, char *board) placed = 1; } while(!placed); } - b->setup = 1; - } else if (!strcmp(category, "fischerandom")) { + b->setup = 1; + } else if (!strcmp(category, "fischerandom")) { wild_update(b->board, 22); b->castlingStyle = 2; - b->setup = 1; // [HGM] FRC: even the default is a setup position, for which an initial board has to be printed + b->setup = 1; // [HGM] FRC: even the default is a setup position, for which an initial board has to be printed } else if (!strcmp(category, "caparandom")) { - b->files = 10; + b->files = 10; wild_update(b->board, 46); b->castlingStyle = 2; - b->setup = 1; - } else retval = board_read_file(category, board, b); + b->setup = 1; + } else retval = board_read_file(category, board, b); } if(b->setup && game_globals.garray[g].FENstartPos[0]) // [HGM] use pre-existing start position, if one available FEN_to_board(game_globals.garray[g].FENstartPos, b); // (could be wild board, or shuffle variant) @@ -235,7 +236,7 @@ int board_init(int g,struct game_state_t *b, char *category, char *board) } } } - + MakeFENpos(g, game_globals.garray[g].FENstartPos); return retval; @@ -256,7 +257,7 @@ void board_calc_strength(struct game_state_t *b, int *ws, int *bs) *p += pieceValues[piecetype(b->board[r][f])]; } } - for (r = PAWN; r < KING; r++) { + for (r = PAWN; r < PIECES; r++) { *ws += b->holding[0][r-1] * pieceValues[r]; *bs += b->holding[1][r-1] * pieceValues[r]; } @@ -268,7 +269,7 @@ static char *holding_str(int *holding) int p,i,j; i = 0; - for (p = PAWN; p < KING; p++) { + for (p = PAWN; p < PIECES; p++) { for (j = 0; j < holding[p-1]; j++) { tmp[i++] = wpstring[p][0]; } @@ -349,7 +350,7 @@ char *board_to_string(char *wn, char *bn, int p) { int bh = (b->gameNum >= 0 && game_globals.garray[b->gameNum].link >= 0 - || b->holdings ); // [HGM] zh: make sure holdings are printed + || b->holdings || b->drops == 2); // [HGM] zh: make sure holdings are printed (also in Seirawan) orient = orientation; myTurn = relation; @@ -432,96 +433,96 @@ static int genstyle(struct game_state_t *b, struct move_t *ml, const char *wp[], const char *top, const char *mid, const char *start, const char *end, const char *label,const char *blabel) { - int f, r, count, i; - char tmp[80], mylabel[80], *p, *q, myTop[80], myMid[80]; - int firstR, lastR, firstF, lastF, inc; - int ws, bs, sqrSize = strlen(wp[0]); - - board_calc_strength(b, &ws, &bs); - if (orient == WHITE) { - firstR = b->ranks-1; - firstF = b->files-1; - lastR = lastF = 0; - inc = -1; - } else { - firstR = firstF = 0; - lastR = b->ranks-1; - lastF = b->files-1; - inc = 1; + int f, r, count, i; + char tmp[80], mylabel[80], *p, *q, myTop[80], myMid[80]; + int firstR, lastR, firstF, lastF, inc; + int ws, bs, sqrSize = strlen(wp[0]); + + board_calc_strength(b, &ws, &bs); + if (orient == WHITE) { + firstR = b->ranks-1; + firstF = b->files-1; + lastR = lastF = 0; + inc = -1; + } else { + firstR = firstF = 0; + lastR = b->ranks-1; + lastF = b->files-1; + inc = 1; } strcpy(myTop, top); strcpy(myMid, mid); - Enlarge(myTop, sqrSize, b->files); - Enlarge(myMid, sqrSize, b->files); - strcat(bstring, myTop); - for (f = firstR, count = b->ranks-1; f != lastR + inc; f += inc, count--) { - sprintf(tmp, " %d %s", f + (b->ranks < 10), start); - strcat(bstring, tmp); - for (r = lastF; r != firstF - inc; r = r - inc) { - if (square_color(r, f) == WHITE) - strcat(bstring, wsqr); - else - strcat(bstring, bsqr); - if (piecetype(b->board[r][f]) == NOPIECE) { - if (square_color(r, f) == WHITE) - strcat(bstring, bp[0]); - else - strcat(bstring, wp[0]); + Enlarge(myTop, sqrSize, b->files); + Enlarge(myMid, sqrSize, b->files); + strcat(bstring, myTop); + for (f = firstR, count = b->ranks-1; f != lastR + inc; f += inc, count--) { + sprintf(tmp, " %d %s", f + (b->ranks < 10), start); + strcat(bstring, tmp); + for (r = lastF; r != firstF - inc; r = r - inc) { + if (square_color(r, f) == WHITE) + strcat(bstring, wsqr); + else + strcat(bstring, bsqr); + if (piecetype(b->board[r][f]) == NOPIECE) { + if (square_color(r, f) == WHITE) + strcat(bstring, bp[0]); + else + strcat(bstring, wp[0]); } else { int piece = piecetype(b->board[r][f]); -// if(piece > QUEEN) piece = ELEPHANT + (piece == KING); // All fairies become elephants in ascii styles - if (colorval(b->board[r][f]) == WHITE) - strcat(bstring, wp[piece]); - else - strcat(bstring, bp[piece]); - } - } - sprintf(tmp, "%s", end); - strcat(bstring, tmp); - switch (count) { - case 7: - sprintf(tmp, " Move # : %d (%s)", b->moveNum, CString(b->onMove)); - strcat(bstring, tmp); - break; - case 6: -/* if ((b->moveNum > 1) || (b->onMove == BLACK)) { */ -/* The change from the above line to the one below is a kludge by hersco. */ - if (game_globals.garray[b->gameNum].numHalfMoves > 0) { -/* loon: think this fixes the crashing ascii board on takeback bug */ - sprintf(tmp, " %s Moves : '%s'", CString(CToggle(b->onMove)), - move_and_time(&ml[game_globals.garray[b->gameNum].numHalfMoves - 1])); - strcat(bstring, tmp); - } - break; - case 5: - break; - case 4: - sprintf(tmp, " Black Clock : %s", tenth_str(((bTime > 0) ? bTime : 0), 1)); - strcat(bstring, tmp); - break; - case 3: - sprintf(tmp, " White Clock : %s", tenth_str(((wTime > 0) ? wTime : 0), 1)); - strcat(bstring, tmp); - break; - case 2: - sprintf(tmp, " Black Strength : %d", bs); - strcat(bstring, tmp); - break; - case 1: - sprintf(tmp, " White Strength : %d", ws); - strcat(bstring, tmp); - break; - case 0: - break; - } - strcat(bstring, "\n"); - if (count != 0) - strcat(bstring, myMid); - else - strcat(bstring, myTop); - } +// if(piece > QUEEN) piece = ELEPHANT + (piece == KING); // All fairies become elephants in ascii styles + if (colorval(b->board[r][f]) == WHITE) + strcat(bstring, wp[piece]); + else + strcat(bstring, bp[piece]); + } + } + sprintf(tmp, "%s", end); + strcat(bstring, tmp); + switch (count) { + case 7: + sprintf(tmp, " Move # : %d (%s)", b->moveNum, CString(b->onMove)); + strcat(bstring, tmp); + break; + case 6: +/* if ((b->moveNum > 1) || (b->onMove == BLACK)) { */ +/* The change from the above line to the one below is a kludge by hersco. */ + if (game_globals.garray[b->gameNum].numHalfMoves > 0) { +/* loon: think this fixes the crashing ascii board on takeback bug */ + sprintf(tmp, " %s Moves : '%s'", CString(CToggle(b->onMove)), + move_and_time(&ml[game_globals.garray[b->gameNum].numHalfMoves - 1])); + strcat(bstring, tmp); + } + break; + case 5: + break; + case 4: + sprintf(tmp, " Black Clock : %s", tenth_str(((bTime > 0) ? bTime : 0), 1)); + strcat(bstring, tmp); + break; + case 3: + sprintf(tmp, " White Clock : %s", tenth_str(((wTime > 0) ? wTime : 0), 1)); + strcat(bstring, tmp); + break; + case 2: + sprintf(tmp, " Black Strength : %d", bs); + strcat(bstring, tmp); + break; + case 1: + sprintf(tmp, " White Strength : %d", ws); + strcat(bstring, tmp); + break; + case 0: + break; + } + strcat(bstring, "\n"); + if (count != 0) + strcat(bstring, myMid); + else + strcat(bstring, myTop); + } q = mylabel; i = 0; - if (orient == WHITE) { + if (orient == WHITE) { p = label; while(*p) { switch(*p) { @@ -546,439 +547,440 @@ static int genstyle(struct game_state_t *b, struct move_t *ml, const char *wp[], *q++ = *p++ + b->files - 12; if(++i >= b->files) { *q++ = '\n'; *q++ = 0; } } - } - } + } + } *q++ = 0; - strcat(bstring, mylabel); - return 0; + strcat(bstring, mylabel); + return 0; } -/* Experimental ANSI board for colour representation */ -static int style13(struct game_state_t *b, struct move_t *ml) -{ - static const char *wp[] = {" ", "\033[37m\033[1m P ", "\033[37m\033[1m N ", "\033[37m\033[1m B ", "\033[37m\033[1m R ", "\033[37m\033[1m A ", "\033[37m\033[1m C ", "\033[37m\033[1m M ", "\033[37m\033[1m Q ", "\033[37m\033[1m E ", "\033[37m\033[1m K "}; - static const char *bp[] = {" ", "\033[21m\033[37m P ", "\033[21m\033[37m N ", "\033[21m\033[37m B ", "\033[21m\033[37m R ", "\033[21m\033[37m A ", "\033[21m\033[37m C ", "\033[21m\033[37m M ", "\033[21m\033[37m Q ", "\033[21m\033[37m E ", "\033[21m\033[37m K "}; - static const char *wsqr = "\033[40m"; - static const char *bsqr = "\033[45m"; - static const char *top = "\t+------------------------+\n"; - static const char *mid = ""; - static const char *start = "|"; - static const char *end = "\033[0m|"; - static const char *label = "\t a b c d e f g h i j k l\n"; - static const char *blabel = "\t l k j i h g f e d c b a\n"; -return 0; - return genstyle(b, ml, wp, bp, wsqr, bsqr, top, mid, start, end, label, blabel); -} - -/* Standard ICS */ -static int style1(struct game_state_t *b, struct move_t *ml) -{ +/* Experimental ANSI board for colour representation */ +static int style13(struct game_state_t *b, struct move_t *ml) +{ + static const char *wp[] = {" ", "\033[37m\033[1m P ", "\033[37m\033[1m N ", "\033[37m\033[1m B ", "\033[37m\033[1m R ", "\033[37m\033[1m A ", "\033[37m\033[1m C ", "\033[37m\033[1m M ", "\033[37m\033[1m Q ", "\033[37m\033[1m E ", "\033[37m\033[1m K "}; + static const char *bp[] = {" ", "\033[21m\033[37m P ", "\033[21m\033[37m N ", "\033[21m\033[37m B ", "\033[21m\033[37m R ", "\033[21m\033[37m A ", "\033[21m\033[37m C ", "\033[21m\033[37m M ", "\033[21m\033[37m Q ", "\033[21m\033[37m E ", "\033[21m\033[37m K "}; + static const char *wsqr = "\033[40m"; + static const char *bsqr = "\033[45m"; + static const char *top = "\t+------------------------+\n"; + static const char *mid = ""; + static const char *start = "|"; + static const char *end = "\033[0m|"; + static const char *label = "\t a b c d e f g h i j k l\n"; + static const char *blabel = "\t l k j i h g f e d c b a\n"; +return 0; + return genstyle(b, ml, wp, bp, wsqr, bsqr, top, mid, start, end, label, blabel); +} + +/* Standard ICS */ +static int style1(struct game_state_t *b, struct move_t *ml) +{ static const char *wp[] = {" |", " P |", " N |", " B |", " R |", " A |", " C |", " M |", " Q |", " E |", " B |", " Q |", - " W |", " H |", " N |", " J |", " I |", " L |", " C |", " S |", " G |", " H |", " A |", " F |", - " E |", " H |", " M |", " S |", " E |", " W |", " O |", " G |", " V |", " S |", " E |", " A |", " K |"}; + " W |", " H |", " N |", " D |", " H |", " L |", " C |", " S |", " G |", " H |", " A |", " F |", + " E |", " H |", " M |", " S |", " E |", " W |", " O |", " G |", " V |", " S |", " E |", " A |", " K |", " H |", " E |"}; static const char *bp[] = {" |", " *P|", " *N|", " *B|", " *R|", " *A|", " *C|", " *M|", " *Q|", " *E|", " *B|", " *Q|", - " *W|", " *H|", " *N|", " *J|", " *I|", " *L|", " *C|", " *S|", " *G|", " *H|", " *A|", " *F|", - " *E|", " *H|", " *M|", " *S|", " *E|", " *W|", " *O|", " *G|", " *V|", " *S|", " *E|", " *A|", " *K|"}; - static char *wsqr = ""; - static char *bsqr = ""; - static char *top = "\t---------------------------------\n"; - static char *mid = "\t|---+---+---+---+---+---+---+---|\n"; - static char *start = "|"; - static char *end = ""; - static char *label = "\t a b c d e f g h i j k l\n"; - static char *blabel = "\t l k j i h g f e d c b a\n"; - - return genstyle(b, ml, wp, bp, wsqr, bsqr, top, mid, start, end, label, blabel); -} - -/* USA-Today Sports Center-style board */ -static int style2(struct game_state_t *b, struct move_t *ml) -{ + " *W|", " *H|", " *N|", " *D|", " *H|", " *L|", " *C|", " *S|", " *G|", " *H|", " *A|", " *F|", + " *E|", " *H|", " *M|", " *S|", " *E|", " *W|", " *O|", " *G|", " *V|", " *S|", " *E|", " *A|", " *K|", " *H|", " *E|"}; + static char *wsqr = ""; + static char *bsqr = ""; + static char *top = "\t---------------------------------\n"; + static char *mid = "\t|---+---+---+---+---+---+---+---|\n"; + static char *start = "|"; + static char *end = ""; + static char *label = "\t a b c d e f g h i j k l\n"; + static char *blabel = "\t l k j i h g f e d c b a\n"; + + return genstyle(b, ml, wp, bp, wsqr, bsqr, top, mid, start, end, label, blabel); +} + +/* USA-Today Sports Center-style board */ +static int style2(struct game_state_t *b, struct move_t *ml) +{ static const char *wp[] = {"- ", "P ", "N ", "B ", "R ", "A ", "C ", "M ", "Q ", "E ", "B ", "Q ", - "W ", "H ", "N ", "J ", "I ", "L ", "C ", "S ", "G ", "H ", "A ", "F ", - "E ", "H ", "M ", "S ", "E ", "W ", "O ", "G ", "V ", "S ", "E ", "A ", "K "}; + "W ", "H ", "N ", "D ", "H ", "L ", "C ", "S ", "G ", "H ", "A ", "F ", + "E ", "H ", "M ", "S ", "E ", "W ", "O ", "G ", "V ", "S ", "E ", "A ", "K ", "H ", "E "}; static const char *bp[] = {"+ ", "p' ", "n' ", "b' ", "r' ", "a' ", "c' ", "m' ", "q' ", "e' ", "b' ", "q' ", - "w' ", "h' ", "n' ", "j' ", "i' ", "l' ", "c' ", "s' ", "g' ", "h' ", "a' ", "f' ", - "e' ", "h' ", "m' ", "s' ", "e' ", "w' ", "o' ", "g' ", "v' ", "s' ", "e' ", "a' ", "k' "}; - static char *wsqr = ""; - static char *bsqr = ""; - static char *top = ""; - static char *mid = ""; - static char *start = ""; - static char *end = ""; - static char *label = "\ta b c d e f g h i j k l\n"; - static char *blabel = "\tl k j i h g f e d c b a\n"; - - return genstyle(b, ml, wp, bp, wsqr, bsqr, top, mid, start, end, label, blabel); -} - -/* Experimental vt-100 ANSI board for dark backgrounds */ -static int style3(struct game_state_t *b, struct move_t *ml) -{ + "w' ", "h' ", "n' ", "d' ", "h' ", "l' ", "c' ", "s' ", "g' ", "h' ", "a' ", "f' ", + "e' ", "h' ", "m' ", "s' ", "e' ", "w' ", "o' ", "g' ", "v' ", "s' ", "e' ", "a' ", "k' ", "h' ", "e' "}; + static char *wsqr = ""; + static char *bsqr = ""; + static char *top = ""; + static char *mid = ""; + static char *start = ""; + static char *end = ""; + static char *label = "\ta b c d e f g h i j k l\n"; + static char *blabel = "\tl k j i h g f e d c b a\n"; + + return genstyle(b, ml, wp, bp, wsqr, bsqr, top, mid, start, end, label, blabel); +} + +/* Experimental vt-100 ANSI board for dark backgrounds */ +static int style3(struct game_state_t *b, struct move_t *ml) +{ static const char *wp[] = {" ", " P ", " N ", " B ", " R ", " A ", " C ", " M ", " Q ", " E ", " B ", " Q ", - " W ", " H ", " N ", " J ", " I ", " L ", " C ", " S ", " G ", " H ", " A ", " F ", - " E ", " H ", " M ", " S ", " E ", " W ", " O ", " G ", " V ", " S ", " E ", " A ", " K "}; + " W ", " H ", " N ", " D ", " H ", " L ", " C ", " S ", " G ", " H ", " A ", " F ", + " E ", " H ", " M ", " S ", " E ", " W ", " O ", " G ", " V ", " S ", " E ", " A ", " K ", " H ", " E "}; static const char *bp[] = {" ", " *P", " *N", " *B", " *R", " *A", " *C", " *M", " *Q", " *E", " *B", " *Q", - " *W", " *H", " *N", " *J", " *I", " *L", " *C", " *S", " *G", " *H", " *A", " *F", - " *E", " *H", " *M", " *S", " *E", " *W", " *O", " *G", " *V", " *S", " *E", " *A", " *K"}; - static char *wsqr = "\033[0m"; - static char *bsqr = "\033[7m"; - static char *top = "\t+------------------------+\n"; - static char *mid = ""; - static char *start = "|"; - static char *end = "\033[0m|"; - static char *label = "\t a b c d e f g h i j k l\n"; - static char *blabel = "\t l k j i h g f e d c b a\n"; - - return genstyle(b, ml, wp, bp, wsqr, bsqr, top, mid, start, end, label, blabel); -} - -/* Experimental vt-100 ANSI board for light backgrounds */ -static int style4(struct game_state_t *b, struct move_t *ml) -{ + " *W", " *H", " *N", " *D", " *H", " *L", " *C", " *S", " *G", " *H", " *A", " *F", + " *E", " *H", " *M", " *S", " *E", " *W", " *O", " *G", " *V", " *S", " *E", " *A", " *K", " *H", " *E"}; + static char *wsqr = "\033[0m"; + static char *bsqr = "\033[7m"; + static char *top = "\t+------------------------+\n"; + static char *mid = ""; + static char *start = "|"; + static char *end = "\033[0m|"; + static char *label = "\t a b c d e f g h i j k l\n"; + static char *blabel = "\t l k j i h g f e d c b a\n"; + + return genstyle(b, ml, wp, bp, wsqr, bsqr, top, mid, start, end, label, blabel); +} + +/* Experimental vt-100 ANSI board for light backgrounds */ +static int style4(struct game_state_t *b, struct move_t *ml) +{ static const char *wp[] = {" ", " P ", " N ", " B ", " R ", " A ", " C ", " M ", " Q ", " E ", " B ", " Q ", - " W ", " H ", " N ", " J ", " I ", " L ", " C ", " S ", " G ", " H ", " A ", " F ", - " E ", " H ", " M ", " S ", " E ", " W ", " O ", " G ", " V ", " S ", " E ", " A ", " K "}; + " W ", " H ", " N ", " D ", " H ", " L ", " C ", " S ", " G ", " H ", " A ", " F ", + " E ", " H ", " M ", " S ", " E ", " W ", " O ", " G ", " V ", " S ", " E ", " A ", " K ", " H ", " E "}; static const char *bp[] = {" ", " *P", " *N", " *B", " *R", " *A", " *C", " *M", " *Q", " *E", " *B", " *Q", - " *W", " *H", " *N", " *J", " *I", " *L", " *C", " *S", " *G", " *H", " *A", " *F", - " *E", " *H", " *M", " *S", " *E", " *W", " *O", " *G", " *V", " *S", " *E", " *A", " *K"}; - static char *wsqr = "\033[7m"; - static char *bsqr = "\033[0m"; - static char *top = "\t+------------------------+\n"; - static char *mid = ""; - static char *start = "|"; - static char *end = "\033[0m|"; - static char *label = "\t a b c d e f g h i j k l\n"; - static char *blabel = "\t l k j i h g f e d c b a\n"; - - return genstyle(b, ml, wp, bp, wsqr, bsqr, top, mid, start, end, label, blabel); -} - -/* Style suggested by ajpierce@med.unc.edu */ -static int style5(struct game_state_t *b, struct move_t *ml) -{ + " *W", " *H", " *N", " *D", " *H", " *L", " *C", " *S", " *G", " *H", " *A", " *F", + " *E", " *H", " *M", " *S", " *E", " *W", " *O", " *G", " *V", " *S", " *E", " *A", " *K", " *H", " *E"}; + static char *wsqr = "\033[7m"; + static char *bsqr = "\033[0m"; + static char *top = "\t+------------------------+\n"; + static char *mid = ""; + static char *start = "|"; + static char *end = "\033[0m|"; + static char *label = "\t a b c d e f g h i j k l\n"; + static char *blabel = "\t l k j i h g f e d c b a\n"; + + return genstyle(b, ml, wp, bp, wsqr, bsqr, top, mid, start, end, label, blabel); +} + +/* Style suggested by ajpierce@med.unc.edu */ +static int style5(struct game_state_t *b, struct move_t *ml) +{ static const char *wp[] = {" ", " o ", " :N:", " ", " |R|", " (A)", " [C]", " :M:", " {Q}", " !E!", - " ", " {Q}", " .W.", " :H:", " :N:", " ", " |I|", " |L|", + " ", " {Q}", " .W.", " :H:", " :N:", " ", " |D|", " |L|", " |C|", " !S!", " :G:", " :H:", " {A}", " {F}", " !E!", " (H)", " [M]", " :S:", - " !E!", " |W|", " *O*", " {G}", " :V:", " (S)", " [E]", " &A&", " =K="}; + " !E!", " |W|", " *O*", " {G}", " :V:", " (S)", " [E]", " &A&", " =K=", " (H)", " [E]"}; static const char *bp[] = {" ", " p ", " :n:", " ", " |r|", " (a)", " [c]", " :m:", " {q}", " !e!", - " ", " {q}", " .w.", " :h:", " :n:", " ", " |i|", " |l|", + " ", " {q}", " .w.", " :h:", " :n:", " ", " |d|", " |l|", " |c|", " !s!", " :g:", " :h:", " {a}", " {f}", " !e!", " (h)", " [m]", " :s:", - " !e!", " |w|", " *o*", " {g}", " :v:", " (s)", " [e]", " &a&", " =k="}; - static char *wsqr = ""; - static char *bsqr = ""; - static char *top = " . . . . . . . . .\n"; - static char *mid = " . . . . . . . . .\n"; - static char *start = ""; - static char *end = ""; - static char *label = "\t a b c d e f g h i j k l\n"; - static char *blabel = "\t l k j i h g f e d c b a\n"; - - return genstyle(b, ml, wp, bp, wsqr, bsqr, top, mid, start, end, label, blabel); -} - -/* Email Board suggested by Thomas Fought (tlf@rsch.oclc.org) */ -static int style6(struct game_state_t *b, struct move_t *ml) -{ + " !e!", " |w|", " *o*", " {g}", " :v:", " (s)", " [e]", " &a&", " =k=", " (f)", " [e]"}; + static char *wsqr = ""; + static char *bsqr = ""; + static char *top = " . . . . . . . . .\n"; + static char *mid = " . . . . . . . . .\n"; + static char *start = ""; + static char *end = ""; + static char *label = "\t a b c d e f g h i j k l\n"; + static char *blabel = "\t l k j i h g f e d c b a\n"; + + return genstyle(b, ml, wp, bp, wsqr, bsqr, top, mid, start, end, label, blabel); +} + +/* Email Board suggested by Thomas Fought (tlf@rsch.oclc.org) */ +static int style6(struct game_state_t *b, struct move_t *ml) +{ static const char *wp[] = {" |", " wp |", " WN |", " WB |", " WR |", " WA |", " WC |", " WM |", " WQ |", - " WE |", " WB |", " WQ |", " WW |", " WH |", " WN |", " WJ |", " WI |", " WL |", + " WE |", " WB |", " WQ |", " WW |", " WH |", " WN |", " WD |", " WH |", " WL |", " WC |", " WS |", " WG |", " WH |", " WA |", " WF |", " WE |", " WH |", " WM |", - " WS |", " WE |", " WW |", " WO |", " WG |", " WV |", " WS |", " WE |", " WA |", " WK |"}; + " WS |", " WE |", " WW |", " WO |", " WG |", " WV |", " WS |", " WE |", " WA |", " WK |", " WH |", " WE |"}; static const char *bp[] = {" |", " bp |", " BN |", " BB |", " BR |", " BA |", " BC |", " BM |", " BQ |", - " BE |", " BB |", " BQ |", " BW |", " BH |", " BN |", " BJ |", " BI |", " BL |", + " BE |", " BB |", " BQ |", " BW |", " BH |", " BN |", " BD |", " BH |", " BL |", " BC |", " BS |", " BG |", " BH |", " BA |", " BF |", " BE |", " BH |", " BM |", - " BS |", " BE |", " BW |", " BO |", " BG |", " BV |", " BS |", " BE |", " BA |", " BK |"}; - static char *wsqr = ""; - static char *bsqr = ""; - static char *top = "\t-----------------------------------------\n"; - static char *mid = "\t-----------------------------------------\n"; - static char *start = "|"; - static char *end = ""; - static char *label = "\t A B C D E F G H I J K L\n"; - static char *blabel = "\t L K J I H G F E D C B A\n"; - - return genstyle(b, ml, wp, bp, wsqr, bsqr, top, mid, start, end, label, blabel); -} - -/* Miniature board */ -static int style7(struct game_state_t *b, struct move_t *ml) -{ - static const char *wp[] = {" ", " P", " N", " B", " R", " A", " C", " M", " Q", " E", " B", " Q", " W", " H", " N", " J", " I", " L", - " C", " S", " G", " H", " A", " F", " E", " H", " M", " S", " E", " W", " O", " G", " V", " S", " E", " A", " K"}; - static const char *bp[] = {" -", " p", " n", " b", " r", " a", " c", " m", " q", " e", " b", " q", " w", " h", " n", " j", " i", " l", - " c", " s", " g", " h", " a", " f", " e", " h", " m", " s", " e", " w", " o", " g", " v", " s", " e", " a", " k"}; - static char *wsqr = ""; - static char *bsqr = ""; - static char *top = "\t:::::::::::::::::::::\n"; - static char *mid = ""; - static char *start = ".."; - static char *end = " .."; - static char *label = "\t a b c d e f g h i j k l\n"; - static char *blabel = "\t l k j i h g f e d c b a\n"; - - return genstyle(b, ml, wp, bp, wsqr, bsqr, top, mid, start, end, label, blabel); -} - -/* ICS interface maker board-- raw data dump */ -static int style8(struct game_state_t *b, struct move_t *ml) -{ - char tmp[160]; - int f, r; - int ws, bs; - - board_calc_strength(b, &ws, &bs); - sprintf(tmp, "#@#%03d%-16s%s%-16s%s", b->gameNum + 1, - game_globals.garray[b->gameNum].white_name, - (orient == WHITE) ? "*" : ":", - game_globals.garray[b->gameNum].black_name, - (orient == WHITE) ? ":" : "*"); - strcat(bstring, tmp); - for (r = 0; r < b->ranks; r++) { - for (f = 0; f < b->files; f++) { - if (b->board[f][r] == NOPIECE) { - strcat(bstring, " "); - } else { - if (colorval(b->board[f][r]) == WHITE) - strcat(bstring, wpstring[piecetype(b->board[f][r])]); - else - strcat(bstring, bpstring[piecetype(b->board[f][r])]); - } - } - } - sprintf(tmp, "%03d%s%02d%02d%05d%05d%-7s(%s)@#@\n", - game_globals.garray[b->gameNum].numHalfMoves / 2 + 1, - (b->onMove == WHITE) ? "W" : "B", - ws, - bs, - (wTime + 5) / 10, - (bTime + 5) / 10, - game_globals.garray[b->gameNum].numHalfMoves ? - ml[game_globals.garray[b->gameNum].numHalfMoves - 1].algString : - "none", - game_globals.garray[b->gameNum].numHalfMoves ? - tenth_str(ml[game_globals.garray[b->gameNum].numHalfMoves - 1].tookTime, 0) : - "0:00"); - strcat(bstring, tmp); - return 0; -} - -/* last 2 moves only (previous non-verbose mode) */ -static int style9(struct game_state_t *b, struct move_t *ml) -{ - int i, count; - char tmp[160]; - int startmove; - - sprintf(tmp, "\nMove %-23s%s\n", - game_globals.garray[b->gameNum].white_name, - game_globals.garray[b->gameNum].black_name); - strcat(bstring, tmp); - sprintf(tmp, "---- -------------- --------------\n"); - strcat(bstring, tmp); - startmove = ((game_globals.garray[b->gameNum].numHalfMoves - 3) / 2) * 2; - if (startmove < 0) - startmove = 0; - for (i = startmove, count = 0; - i < game_globals.garray[b->gameNum].numHalfMoves && count < 4; - i++, count++) { - if (!(i & 0x01)) { - sprintf(tmp, " %2d ", i / 2 + 1); - strcat(bstring, tmp); - } - sprintf(tmp, "%-23s", move_and_time(&ml[i])); - strcat(bstring, tmp); - if (i & 0x01) - strcat(bstring, "\n"); - } - if (i & 0x01) - strcat(bstring, "\n"); - return 0; -} - -/* Sleator's 'new and improved' raw dump format... */ -static int style10(struct game_state_t *b, struct move_t *ml) -{ - int f, r; - char tmp[160]; - int ws, bs; - - board_calc_strength(b, &ws, &bs); - sprintf(tmp, "<10>\n"); - strcat(bstring, tmp); - for (r = b->ranks-1; r >= 0; r--) { - strcat(bstring, "|"); - for (f = 0; f < b->files; f++) { - if (b->board[f][r] == NOPIECE) { - strcat(bstring, " "); - } else { - if (colorval(b->board[f][r]) == WHITE) - strcat(bstring, wpstring[piecetype(b->board[f][r])]); - else - strcat(bstring, bpstring[piecetype(b->board[f][r])]); - } - } - strcat(bstring, "|\n"); - } - strcat(bstring, (b->onMove == WHITE) ? "W " : "B "); - if (game_globals.garray[b->gameNum].numHalfMoves) { - sprintf(tmp, "%d ", - ml[game_globals.garray[b->gameNum].numHalfMoves - 1].doublePawn); - } else { - sprintf(tmp, "-1 "); - } - strcat(bstring, tmp); - sprintf(tmp, "%d %d %d %d %d\n", - (b->wkmoved >= 0 && b->wkrmoved >= 0), // [HGM] castle: inverted the logic, both must have rights - (b->wkmoved >= 0 && b->wqrmoved >= 0), - (b->bkmoved >= 0 && b->bkrmoved >= 0), - (b->bkmoved >= 0 && b->bqrmoved >= 0), - (game_globals.garray[b->gameNum].numHalfMoves - ((b->lastIrreversable == -1) ? 0 : - b->lastIrreversable))); - strcat(bstring, tmp); - sprintf(tmp, "%d %s %s %d %d %d %d %d %d %d %d %s (%s) %s %d\n", - b->gameNum, - game_globals.garray[b->gameNum].white_name, - game_globals.garray[b->gameNum].black_name, - myTurn, - game_globals.garray[b->gameNum].wInitTime / 600, - game_globals.garray[b->gameNum].wIncrement / 10, - ws, - bs, - (wTime + 5) / 10, - (bTime + 5) / 10, - game_globals.garray[b->gameNum].numHalfMoves / 2 + 1, - game_globals.garray[b->gameNum].numHalfMoves ? - ml[game_globals.garray[b->gameNum].numHalfMoves - 1].moveString : - "none", - game_globals.garray[b->gameNum].numHalfMoves ? - tenth_str(ml[game_globals.garray[b->gameNum].numHalfMoves - 1].tookTime, 0) : - "0:00", - game_globals.garray[b->gameNum].numHalfMoves ? - ml[game_globals.garray[b->gameNum].numHalfMoves - 1].algString : - "none", - (orient == WHITE) ? 0 : 1); - strcat(bstring, tmp); - sprintf(tmp, ">10<\n"); - strcat(bstring, tmp); - return 0; -} - -/* Same as 8, but with verbose moves ("P/e3-e4", instead of "e4") */ -static int style11(struct game_state_t *b, struct move_t *ml) -{ - char tmp[160]; - int f, r; - int ws, bs; - - board_calc_strength(b, &ws, &bs); - sprintf(tmp, "#@#%03d%-16s%s%-16s%s", b->gameNum, - game_globals.garray[b->gameNum].white_name, - (orient == WHITE) ? "*" : ":", - game_globals.garray[b->gameNum].black_name, - (orient == WHITE) ? ":" : "*"); - strcat(bstring, tmp); - for (r = 0; r < b->ranks; r++) { - for (f = 0; f < b->files; f++) { - if (b->board[f][r] == NOPIECE) { - strcat(bstring, " "); - } else { - if (colorval(b->board[f][r]) == WHITE) - strcat(bstring, wpstring[piecetype(b->board[f][r])]); - else - strcat(bstring, bpstring[piecetype(b->board[f][r])]); - } - } - } - sprintf(tmp, "%03d%s%02d%02d%05d%05d%-7s(%s)@#@\n", - game_globals.garray[b->gameNum].numHalfMoves / 2 + 1, - (b->onMove == WHITE) ? "W" : "B", - ws, - bs, - (wTime + 5) / 10, - (bTime + 5) / 10, - game_globals.garray[b->gameNum].numHalfMoves ? - ml[game_globals.garray[b->gameNum].numHalfMoves - 1].moveString : - "none", - game_globals.garray[b->gameNum].numHalfMoves ? - tenth_str(ml[game_globals.garray[b->gameNum].numHalfMoves - 1].tookTime, 0) : - "0:00"); - strcat(bstring, tmp); - return 0; -} - - -int kludgeFlag = 0; -/* Similar to style 10. See the "style12" help file for information */ -static int style12(struct game_state_t *b, struct move_t *ml) -{ - int f, r; - char tmp[160]; // [HGM] 80 caused problems with long login names + " BS |", " BE |", " BW |", " BO |", " BG |", " BV |", " BS |", " BE |", " BA |", " BK |", " BH |", " BE |"}; + static char *wsqr = ""; + static char *bsqr = ""; + static char *top = "\t-----------------------------------------\n"; + + static char *mid = "\t-----------------------------------------\n"; + static char *start = "|"; + static char *end = ""; + static char *label = "\t A B C D E F G H I J K L\n"; + static char *blabel = "\t L K J I H G F E D C B A\n"; + + return genstyle(b, ml, wp, bp, wsqr, bsqr, top, mid, start, end, label, blabel); +} + +/* Miniature board */ +static int style7(struct game_state_t *b, struct move_t *ml) +{ + static const char *wp[] = {" ", " P", " N", " B", " R", " A", " C", " M", " Q", " E", " B", " Q", " W", " H", " N", " D", " H", " L", + " C", " S", " G", " H", " A", " F", " E", " H", " M", " S", " E", " W", " O", " G", " V", " S", " E", " A", " K", " H", " E"}; + static const char *bp[] = {" -", " p", " n", " b", " r", " a", " c", " m", " q", " e", " b", " q", " w", " h", " n", " d", " h", " l", + " c", " s", " g", " h", " a", " f", " e", " h", " m", " s", " e", " w", " o", " g", " v", " s", " e", " a", " k", " h", " e"}; + static char *wsqr = ""; + static char *bsqr = ""; + static char *top = "\t:::::::::::::::::::::\n"; + static char *mid = ""; + static char *start = ".."; + static char *end = " .."; + static char *label = "\t a b c d e f g h i j k l\n"; + static char *blabel = "\t l k j i h g f e d c b a\n"; + + return genstyle(b, ml, wp, bp, wsqr, bsqr, top, mid, start, end, label, blabel); +} + +/* ICS interface maker board-- raw data dump */ +static int style8(struct game_state_t *b, struct move_t *ml) +{ + char tmp[160]; + int f, r; + int ws, bs; + + board_calc_strength(b, &ws, &bs); + sprintf(tmp, "#@#%03d%-16s%s%-16s%s", b->gameNum + 1, + game_globals.garray[b->gameNum].white_name, + (orient == WHITE) ? "*" : ":", + game_globals.garray[b->gameNum].black_name, + (orient == WHITE) ? ":" : "*"); + strcat(bstring, tmp); + for (r = 0; r < b->ranks; r++) { + for (f = 0; f < b->files; f++) { + if (b->board[f][r] == NOPIECE) { + strcat(bstring, " "); + } else { + if (colorval(b->board[f][r]) == WHITE) + strcat(bstring, wpstring[piecetype(b->board[f][r])]); + else + strcat(bstring, bpstring[piecetype(b->board[f][r])]); + } + } + } + sprintf(tmp, "%03d%s%02d%02d%05d%05d%-7s(%s)@#@\n", + game_globals.garray[b->gameNum].numHalfMoves / 2 + 1, + (b->onMove == WHITE) ? "W" : "B", + ws, + bs, + (wTime + 5) / 10, + (bTime + 5) / 10, + game_globals.garray[b->gameNum].numHalfMoves ? + ml[game_globals.garray[b->gameNum].numHalfMoves - 1].algString : + "none", + game_globals.garray[b->gameNum].numHalfMoves ? + tenth_str(ml[game_globals.garray[b->gameNum].numHalfMoves - 1].tookTime, 0) : + "0:00"); + strcat(bstring, tmp); + return 0; +} + +/* last 2 moves only (previous non-verbose mode) */ +static int style9(struct game_state_t *b, struct move_t *ml) +{ + int i, count; + char tmp[160]; + int startmove; + + sprintf(tmp, "\nMove %-23s%s\n", + game_globals.garray[b->gameNum].white_name, + game_globals.garray[b->gameNum].black_name); + strcat(bstring, tmp); + sprintf(tmp, "---- -------------- --------------\n"); + strcat(bstring, tmp); + startmove = ((game_globals.garray[b->gameNum].numHalfMoves - 3) / 2) * 2; + if (startmove < 0) + startmove = 0; + for (i = startmove, count = 0; + i < game_globals.garray[b->gameNum].numHalfMoves && count < 4; + i++, count++) { + if (!(i & 0x01)) { + sprintf(tmp, " %2d ", i / 2 + 1); + strcat(bstring, tmp); + } + sprintf(tmp, "%-23s", move_and_time(&ml[i])); + strcat(bstring, tmp); + if (i & 0x01) + strcat(bstring, "\n"); + } + if (i & 0x01) + strcat(bstring, "\n"); + return 0; +} + +/* Sleator's 'new and improved' raw dump format... */ +static int style10(struct game_state_t *b, struct move_t *ml) +{ + int f, r; + char tmp[160]; + int ws, bs; + + board_calc_strength(b, &ws, &bs); + sprintf(tmp, "<10>\n"); + strcat(bstring, tmp); + for (r = b->ranks-1; r >= 0; r--) { + strcat(bstring, "|"); + for (f = 0; f < b->files; f++) { + if (b->board[f][r] == NOPIECE) { + strcat(bstring, " "); + } else { + if (colorval(b->board[f][r]) == WHITE) + strcat(bstring, wpstring[piecetype(b->board[f][r])]); + else + strcat(bstring, bpstring[piecetype(b->board[f][r])]); + } + } + strcat(bstring, "|\n"); + } + strcat(bstring, (b->onMove == WHITE) ? "W " : "B "); + if (game_globals.garray[b->gameNum].numHalfMoves) { + sprintf(tmp, "%d ", + ml[game_globals.garray[b->gameNum].numHalfMoves - 1].doublePawn); + } else { + sprintf(tmp, "-1 "); + } + strcat(bstring, tmp); + sprintf(tmp, "%d %d %d %d %d\n", + (b->wkmoved >= 0 && b->wkrmoved >= 0), // [HGM] castle: inverted the logic, both must have rights + (b->wkmoved >= 0 && b->wqrmoved >= 0), + (b->bkmoved >= 0 && b->bkrmoved >= 0), + (b->bkmoved >= 0 && b->bqrmoved >= 0), + (game_globals.garray[b->gameNum].numHalfMoves - ((b->lastIrreversable == -1) ? 0 : + b->lastIrreversable))); + strcat(bstring, tmp); + sprintf(tmp, "%d %s %s %d %d %d %d %d %d %d %d %s (%s) %s %d\n", + b->gameNum, + game_globals.garray[b->gameNum].white_name, + game_globals.garray[b->gameNum].black_name, + myTurn, + game_globals.garray[b->gameNum].wInitTime / 600, + game_globals.garray[b->gameNum].wIncrement / 10, + ws, + bs, + (wTime + 5) / 10, + (bTime + 5) / 10, + game_globals.garray[b->gameNum].numHalfMoves / 2 + 1, + game_globals.garray[b->gameNum].numHalfMoves ? + ml[game_globals.garray[b->gameNum].numHalfMoves - 1].moveString : + "none", + game_globals.garray[b->gameNum].numHalfMoves ? + tenth_str(ml[game_globals.garray[b->gameNum].numHalfMoves - 1].tookTime, 0) : + "0:00", + game_globals.garray[b->gameNum].numHalfMoves ? + ml[game_globals.garray[b->gameNum].numHalfMoves - 1].algString : + "none", + (orient == WHITE) ? 0 : 1); + strcat(bstring, tmp); + sprintf(tmp, ">10<\n"); + strcat(bstring, tmp); + return 0; +} + +/* Same as 8, but with verbose moves ("P/e3-e4", instead of "e4") */ +static int style11(struct game_state_t *b, struct move_t *ml) +{ + char tmp[160]; + int f, r; + int ws, bs; + + board_calc_strength(b, &ws, &bs); + sprintf(tmp, "#@#%03d%-16s%s%-16s%s", b->gameNum, + game_globals.garray[b->gameNum].white_name, + (orient == WHITE) ? "*" : ":", + game_globals.garray[b->gameNum].black_name, + (orient == WHITE) ? ":" : "*"); + strcat(bstring, tmp); + for (r = 0; r < b->ranks; r++) { + for (f = 0; f < b->files; f++) { + if (b->board[f][r] == NOPIECE) { + strcat(bstring, " "); + } else { + if (colorval(b->board[f][r]) == WHITE) + strcat(bstring, wpstring[piecetype(b->board[f][r])]); + else + strcat(bstring, bpstring[piecetype(b->board[f][r])]); + } + } + } + sprintf(tmp, "%03d%s%02d%02d%05d%05d%-7s(%s)@#@\n", + game_globals.garray[b->gameNum].numHalfMoves / 2 + 1, + (b->onMove == WHITE) ? "W" : "B", + ws, + bs, + (wTime + 5) / 10, + (bTime + 5) / 10, + game_globals.garray[b->gameNum].numHalfMoves ? + ml[game_globals.garray[b->gameNum].numHalfMoves - 1].moveString : + "none", + game_globals.garray[b->gameNum].numHalfMoves ? + tenth_str(ml[game_globals.garray[b->gameNum].numHalfMoves - 1].tookTime, 0) : + "0:00"); + strcat(bstring, tmp); + return 0; +} + + +int kludgeFlag = 0; +/* Similar to style 10. See the "style12" help file for information */ +static int style12(struct game_state_t *b, struct move_t *ml) +{ + int f, r; + char tmp[160]; // [HGM] 80 caused problems with long login names int ws, bs; int nhm = kludgeFlag ? 0 : game_globals.garray[b->gameNum].numHalfMoves; // [HGM] setup: the number of half moves appeared in this routine an enormous number of times, // and had to be dug out of the game_globals, so that this routine could only be used to print // a board from a game, and not just any board given by an isolated game_state_t. This was very // inconvenient for printing initial boards in move lists of shuffle variants, so I added the - // global kludgeFlag to signal that we want to print an initial position, and force nhm = 0. - - board_calc_strength(b, &ws, &bs); - - sprintf(bstring, "<12> "); - for (r = b->ranks-1; r >= 0; r--) { + // global kludgeFlag to signal that we want to print an initial position, and force nhm = 0. + + board_calc_strength(b, &ws, &bs); + + sprintf(bstring, "<12> "); + for (r = b->ranks-1; r >= 0; r--) { for (f = 0; f < b->files; f++) { - if (b->board[f][r] == NOPIECE) { - strcat(bstring, "-"); - } else { - if (colorval(b->board[f][r]) == WHITE) - strcat(bstring, wpstring[piecetype(b->board[f][r])]); - else - strcat(bstring, bpstring[piecetype(b->board[f][r])]); - } - } - strcat(bstring, " "); + if (b->board[f][r] == NOPIECE) { + strcat(bstring, "-"); + } else { + if (colorval(b->board[f][r]) == WHITE) + strcat(bstring, wpstring[piecetype(b->board[f][r])]); + else + strcat(bstring, bpstring[piecetype(b->board[f][r])]); + } + } + strcat(bstring, " "); + } + + strcat(bstring, (b->onMove == WHITE) ? "W " : "B "); + if (nhm) { + sprintf(tmp, "%d ", + ml[nhm - 1].doublePawn); + } else { + sprintf(tmp, "-1 "); } - - strcat(bstring, (b->onMove == WHITE) ? "W " : "B "); - if (nhm) { - sprintf(tmp, "%d ", - ml[nhm - 1].doublePawn); - } else { - sprintf(tmp, "-1 "); - } - strcat(bstring, tmp); - sprintf(tmp, "%d %d %d %d %d ", - (b->wkmoved >= 0 && b->wkrmoved >= 0), // [HGM] castle: inverted the logic, both must have rights - (b->wkmoved >= 0 && b->wqrmoved >= 0), - (b->bkmoved >= 0 && b->bkrmoved >= 0), - (b->bkmoved >= 0 && b->bqrmoved >= 0), - (nhm - ((b->lastIrreversable == -1) ? 0 : b->lastIrreversable))); strcat(bstring, tmp); - sprintf(tmp, "%d %s %s %d %d %d %d %d %d %d %d %s (%s) %s %d %d\n", - b->gameNum + 1, - game_globals.garray[b->gameNum].white_name, - game_globals.garray[b->gameNum].black_name, - myTurn, - game_globals.garray[b->gameNum].wInitTime / 600, - game_globals.garray[b->gameNum].wIncrement / 10, - ws, - bs, - (wTime / 10), - (bTime / 10), - nhm / 2 + 1, - nhm ? - ml[nhm - 1].moveString : - "none", - nhm ? - tenth_str(ml[nhm - 1].tookTime, 0) : - "0:00", - nhm ? - ml[nhm - 1].algString : - "none", (orient == WHITE) ? 0 : 1, - b->moveNum > 1 ? 1 : 0); /* ticking */ - - strcat(bstring, tmp); - return 0; -} + sprintf(tmp, "%d %d %d %d %d ", + (b->wkmoved >= 0 && b->wkrmoved >= 0), // [HGM] castle: inverted the logic, both must have rights + (b->wkmoved >= 0 && b->wqrmoved >= 0), + (b->bkmoved >= 0 && b->bkrmoved >= 0), + (b->bkmoved >= 0 && b->bqrmoved >= 0), + (nhm - ((b->lastIrreversable == -1) ? 0 : b->lastIrreversable))); + strcat(bstring, tmp); + sprintf(tmp, "%d %s %s %d %d %d %d %d %d %d %d %s (%s) %s %d %d\n", + b->gameNum + 1, + game_globals.garray[b->gameNum].white_name, + game_globals.garray[b->gameNum].black_name, + myTurn, + game_globals.garray[b->gameNum].wInitTime / 600, + game_globals.garray[b->gameNum].wIncrement / 10, + ws, + bs, + (wTime / 10), + (bTime / 10), + nhm / 2 + 1, + nhm ? + ml[nhm - 1].moveString : + "none", + nhm ? + tenth_str(ml[nhm - 1].tookTime, 0) : + "0:00", + nhm ? + ml[nhm - 1].algString : + "none", (orient == WHITE) ? 0 : 1, + b->moveNum > 1 ? 1 : 0); /* ticking */ + + strcat(bstring, tmp); + return 0; +} static int board_read_file(char *category, char *gname, struct game_state_t *gs) { @@ -1022,6 +1024,9 @@ static int board_read_file(char *category, char *gname, struct game_state_t *gs) case 'd': gs->drops = 1; break; + case 'g': + gs->drops = 2; + break; case 'h': gs->holdings = -1; // color-flip holdings break; @@ -1032,6 +1037,13 @@ static int board_read_file(char *category, char *gname, struct game_state_t *gs) gs->promoType = 2; // only promote to captured pieces gs->holdings = 1; // use holdings to hold own captured pieces break; + case 'S': + gs->promoType = 3; // Shogi-type promotions + break; + case 'Z': + gs->promoZone = 3; // for Grand Chess + gs->pawnDblStep = 2; + break; case 'F': gs->castlingStyle = 2; // FRC castling break; @@ -1080,15 +1092,15 @@ static int board_read_file(char *category, char *gname, struct game_state_t *gs) case 'B': onPiece = BISHOP; break; - case 'A': - onPiece = CARDINAL; - break; - case 'C': - onPiece = MARSHALL; - break; - case 'M': - onPiece = MAN; - break; + case 'A': + onPiece = CARDINAL; + break; + case 'C': + onPiece = MARSHALL; + break; + case 'M': + onPiece = MAN; + break; case 'Q': onPiece = QUEEN; break; @@ -1167,41 +1179,48 @@ static int board_read_file(char *category, char *gname, struct game_state_t *gs) case 'K': onPiece = KING; break; - case 'a': - case 'b': - case 'c': - case 'd': - case 'e': - case 'f': - case 'g': - case 'h': - case 'i': - case 'j': - case 'k': - case 'l': - onFile = c - 'a'; - if(onFile >= gs->files) { onFile = -1; break; } - onRank = -1; - break; + case 'D': + onPiece = SELEPHANT; + break; + case 'U': + onPiece = HAWK; + break; + case 'a': + case 'b': + case 'c': + case 'd': + case 'e': + case 'f': + case 'g': + case 'h': + case 'i': + case 'j': + case 'k': + case 'l': + onFile = c - 'a'; + if(onFile >= gs->files) { onFile = -1; break; } + onRank = -1; + break; case '@': - if (onColor >= 0 && onPiece >= 0) // allow placement in holdings + if (onColor >= 0 && onPiece >= 0) // allow placement in holdings gs->holding[onColor == BLACK][onPiece-1]++; - break; - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': - case '0': - onRank = c - '1' + (gs->ranks > 9); - if(onRank < 0 || onRank >= gs->ranks) { onRank = -1; break; } - if (onFile >= 0 && onColor >= 0 && onPiece >= 0) - gs->board[onFile][onRank] = onPiece | onColor; - break; case '#': + break; + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + case '8': + case '9': + case '0': + onRank = c - '1' + (gs->ranks > 9); + if(onRank < 0 || onRank >= gs->ranks) { onRank = -1; break; } + if (onFile >= 0 && onColor >= 0 && onPiece >= 0) + gs->board[onFile][onRank] = onPiece | onColor; + break; + case '#': while (!feof(fp) && c != '\n') c = fgetc(fp); /* Comment line */ case '\n':