X-Git-Url: http://winboard.nl/cgi-bin?p=capablanca.git;a=blobdiff_plain;f=lasker-2.2.3%2Fsrc%2Fgameproc.c;h=295aed6e3ee19b6ee43f7e322a97d7db8c0ee9d1;hp=53147a8b836d2b26fd54013826e5dcf1282c7520;hb=c214e749e3e62f654061433589f3bcb7cd1aed14;hpb=d5de5c406540b053c30e9732ae6c7b93c594bf27 diff --git a/lasker-2.2.3/src/gameproc.c b/lasker-2.2.3/src/gameproc.c index 53147a8..295aed6 100644 --- a/lasker-2.2.3/src/gameproc.c +++ b/lasker-2.2.3/src/gameproc.c @@ -144,6 +144,11 @@ void game_ended(int g, int winner, int why) strcpy(EndSymbol, "Bar"); rate_change = 1; break; + case END_PERPETUAL: + sprintf(tmp, "%s perpetually checking} %s", NameOfLoser, winSymbol); + strcpy(EndSymbol, "Per"); + rate_change = 1; + break; case END_RESIGN: sprintf(tmp, "%s resigns} %s", NameOfLoser, winSymbol); strcpy(EndSymbol, "Res"); @@ -525,7 +530,7 @@ void process_move(int p, char *command) { struct player *pp = &player_globals.parray[p]; struct game *gg; - int g, result, len, i; + int g, result, len, i, f; struct move_t move; unsigned now = 0; @@ -561,9 +566,9 @@ void process_move(int p, char *command) } pp->promote = NOPIECE; // [HGM] this seemed to be uninitialized, which caused spurious promotion in Shogi if ((len = strlen(command)) > 1) { - if (command[len - 2] == '=') { + if (command[len - 2] == '=' || gg->game_state.drops == 2 && command[len - 2] == '/') { // [HGM] encode gating as promotion printf("promo '%s'\n", command); - switch (tolower(command[strlen(command) - 1])) { + switch (tolower(command[len - 1])) { case 'n': pp->promote = KNIGHT; break; @@ -608,7 +613,19 @@ printf("promo '%s'\n", command); case 'g': pp->promote = MASTODON; break; + case 'l': + pp->promote = LIEUTENANT; + break; + case 'k': + pp->promote = KING; + break; // Shogi promotions + case 'h': + pp->promote = DRAGONHORSE; + break; + case 'd': + pp->promote = DRAGONKING; + break; case '^': case '+': pp->promote = GOLD; @@ -870,6 +887,26 @@ static int Check50MoveRule (int p, int g) return 0; } +static int perp_check(struct game g, int first, int third) +{ + struct game_state_t gs = g.game_state; // current position, both first and last of loop + int half_move, no_perp = 0; +printf("perp %d %d\n",first,third); + for(half_move=first+1; half_move= game_globals.garray[g].game_state.lastIrreversable - 1; move_num--) { pos = GetFENpos (g, move_num); - if (strlen(pos1) == strlen(pos) && !strcmp(pos1, pos)) - flag1++; - if (strlen(pos2) == strlen(pos) && !strcmp(pos2, pos)) - flag2++; -printf("%2d. %d-%d %s %s %s\n", move_num, flag1, flag2, pos1,pos2,pos); + if (!(turn - move_num & 1) && strlen(pos1) == strlen(pos) && !strcmp(pos1, pos)) + flag1++ == 2 && (s1 = move_num); + if ( (turn - move_num & 1) && strlen(pos2) == strlen(pos) && !strcmp(pos2, pos)) + flag2++ == 2 && (s2 = move_num); // remember start of last two loops +printf("%2d. %d-%d '%s' '%s' '%s'\n", move_num, flag1, flag2, pos1,pos2,pos); } if (flag1 >= 3 || flag2 >= 3) { if ((pend = find_pend(pp->opponent, p, PEND_DRAW)) != NULL) { delete_pending(pend); decline_withdraw_offers(p, -1, -1,DO_DECLINE); } - game_ended(g, (game_globals.garray[g].white == p) ? BLACK : WHITE, END_REPETITION); + if(game_globals.garray[g].game_state.palace) { // [HGM] in Xiangqi we have to test for perpetuals to determine the outcome + if(flag2 >= 3) result = perp_check(game_globals.garray[g], s2, numPly); + else result = perp_check(game_globals.garray[g], s1, numPly - (pos2[0] != 0)); + if(result == END_NOTENDED) { + pprintf(p, "Perpetuals can be claimed only during the turn of the winner\n"); + return 1; + } + game_ended(g, (numPly&1) ? BLACK : WHITE, result); // stm wins + return 1; + } + game_ended(g, (game_globals.garray[g].white == p) ? BLACK : WHITE, result); return 1; } else return 0;