X-Git-Url: http://winboard.nl/cgi-bin?a=blobdiff_plain;f=backend.c;h=860a1607f73527a81c71e2397d33f7180f45a4d5;hb=c9602f20e9cee39ec2a7dddee3e2c12719c25ef0;hp=5b8dcfa6c2105a2b570cbc441d27295243eb5897;hpb=e1edcbabb63e65d5d47c07a0836dd51d7e01de0e;p=xboard.git diff --git a/backend.c b/backend.c index 5b8dcfa..860a160 100755 --- a/backend.c +++ b/backend.c @@ -607,7 +607,7 @@ InitBackEnd1() ShowThinkingEvent(); // [HGM] thinking: make sure post/nopost state is set according to options GetTimeMark(&programStartTime); - srand(programStartTime.ms); // [HGM] book: makes sure random is unpredictabe to msec level + srandom((programStartTime.ms + 1000*programStartTime.sec)*0x1001001); // [HGM] book: makes sure random is unpredictabe to msec level ClearProgramStats(); programStats.ok_to_send = 1; @@ -1977,7 +1977,7 @@ VariantSwitch(Board board, VariantClass newVariant) case VariantSuper: newHoldingsWidth = 2; gameInfo.holdingsSize = 8; - return; + break; case VariantGothic: case VariantCapablanca: case VariantCapaRandom: @@ -2011,10 +2011,8 @@ VariantSwitch(Board board, VariantClass newVariant) gameInfo.holdingsWidth = newHoldingsWidth; gameInfo.variant = newVariant; InitDrawingSizes(-2, 0); - InitPosition(FALSE); /* this sets up board[0], but also other stuff */ - } else { gameInfo.variant = newVariant; InitPosition(FALSE); } - - DrawPosition(TRUE, boards[currentMove]); + InitPosition(TRUE); /* this sets up board[0], but also other stuff */ + } else { gameInfo.variant = newVariant; InitPosition(TRUE); } } static int loggedOn = FALSE; @@ -2731,7 +2729,7 @@ read_from_ics(isr, closure, data, count, error) moves and soak them up so user can step through them and/or save them. */ - Reset(FALSE, TRUE); + Reset(TRUE, TRUE); gameMode = IcsObserving; ModeHighlight(); ics_gamenum = -1; @@ -3281,7 +3279,13 @@ read_from_ics(isr, closure, data, count, error) * to move the position two files to the right to * create room for them! */ - VariantSwitch(boards[currentMove], VariantCrazyhouse); /* temp guess */ + VariantClass newVariant; + switch(gameInfo.boardWidth) { // base guess on board width + case 9: newVariant = VariantShogi; break; + case 10: newVariant = VariantGreat; break; + default: newVariant = VariantCrazyhouse; break; + } + VariantSwitch(boards[currentMove], newVariant); /* temp guess */ /* Get a move list just to see the header, which will tell us whether this is really bug or zh */ if (ics_getting_history == H_FALSE) { @@ -3297,8 +3301,8 @@ read_from_ics(isr, closure, data, count, error) white_holding[strlen(white_holding)-1] = NULLCHAR; black_holding[strlen(black_holding)-1] = NULLCHAR; /* [HGM] copy holdings to board holdings area */ - CopyHoldings(boards[currentMove], white_holding, WhitePawn); - CopyHoldings(boards[currentMove], black_holding, BlackPawn); + CopyHoldings(boards[forwardMostMove], white_holding, WhitePawn); + CopyHoldings(boards[forwardMostMove], black_holding, BlackPawn); #if ZIPPY if (appData.zippyPlay && first.initDone) { ZippyHoldings(white_holding, black_holding, @@ -3391,6 +3395,7 @@ ParseBoard12(string) char promoChar; int ranks=1, files=0; /* [HGM] ICS80: allow variable board size */ char *bookHit = NULL; // [HGM] book + Boolean weird = FALSE; fromX = fromY = toX = toY = -1; @@ -3406,6 +3411,7 @@ ParseBoard12(string) while(i < 199 && (string[i] != ' ' || string[i+2] != ' ')) { if(string[i] == ' ') { ranks++; files = 0; } else files++; + if(!strchr(" -pnbrqkPNBRQK" , string[i])) weird = TRUE; // test for fairies i++; } for(j = 0; j = gameInfo.holdingsSize) p = 0; - if(--board[p][BOARD_WIDTH-2] == 0) + if(--board[p][BOARD_WIDTH-2] <= 0) board[p][BOARD_WIDTH-1] = EmptySquare; + if((int)board[p][BOARD_WIDTH-2] < 0) + board[p][BOARD_WIDTH-2] = 0; } else { /* black drop */ p -= (int)BlackPawn; + p = PieceToNumber((ChessSquare)p); if(p >= gameInfo.holdingsSize) p = 0; - if(--board[BOARD_HEIGHT-1-p][1] == 0) + if(--board[BOARD_HEIGHT-1-p][1] <= 0) board[BOARD_HEIGHT-1-p][0] = EmptySquare; + if((int)board[BOARD_HEIGHT-1-p][1] < 0) + board[BOARD_HEIGHT-1-p][1] = 0; } } if (captured != EmptySquare && gameInfo.holdingsSize > 0 @@ -7555,7 +7588,6 @@ ApplyMove(fromX, fromY, toX, toY, promoChar, board, castling, ep) board[BOARD_HEIGHT-1-p][0] = WHITE_TO_BLACK captured; } } - } else if (gameInfo.variant == VariantAtomic) { if (captured != EmptySquare) { int y, x; @@ -7933,7 +7965,7 @@ TwoMachinesEventIfReady P((void)) void NextMatchGame P((void)) { - int index; /* [HGM] autoinc: step lod index during match */ + int index; /* [HGM] autoinc: step load index during match */ Reset(FALSE, TRUE); if (*appData.loadGameFile != NULLCHAR) { index = appData.loadGameIndex; @@ -10925,7 +10957,9 @@ TwoMachinesEvent P((void)) strcpy(bookMove, "move "); strcat(bookMove, bookHit); - HandleMachineMove(bookMove, &first); + savedMessage = bookMove; // args for deferred call + savedState = onmove; + ScheduleDelayedEvent(DeferredBookMove, 1); } }