X-Git-Url: http://winboard.nl/cgi-bin?a=blobdiff_plain;f=backend.c;h=6fac052a5a5d1d4f1e2cc25bd8b60683cbdc335e;hb=b52aafe5fc484a170251d4bb5bad039ffbbda4df;hp=f3f86c61fbf9187ec26146f074b871c58f606955;hpb=efaa4a5dc4478095bca6f9b919a96356508b2a9b;p=xboard.git diff --git a/backend.c b/backend.c index f3f86c6..6fac052 100644 --- a/backend.c +++ b/backend.c @@ -295,6 +295,7 @@ ChessSquare promoSweep = EmptySquare, defaultPromoChoice; int promoDefaultAltered; int keepInfo = 0; /* [HGM] to protect PGN tags in auto-step game analysis */ static int initPing = -1; +static Boolean pieceDefs; /* States for ics_getting_history */ #define H_FALSE 0 @@ -954,7 +955,7 @@ extern Boolean isUCI, hasBook, storeVariant, v1, addToList, useNick; static char resetOptions[] = "-reuse -firstIsUCI false -firstHasOwnBookUCI true -firstTimeOdds 1 " "-firstInitString \"" INIT_STRING "\" -firstComputerString \"" COMPUTER_STRING "\" " - "-firstFeatures \"\" -firstLogo \"\" -firstAccumulateTC 1 " + "-firstFeatures \"\" -firstLogo \"\" -firstAccumulateTC 1 -fd \".\" " "-firstOptions \"\" -firstNPS -1 -fn \"\" -firstScoreAbs false"; void @@ -5680,7 +5681,7 @@ LoadMultiPV (int x, int y, char *buf, int index, int *start, int *end, int pane) } ParsePV(buf+startPV, FALSE, gameMode != AnalyzeMode); *start = startPV; *end = index-1; - extendGame = (gameMode == AnalyzeMode && appData.autoExtend); + extendGame = (gameMode == AnalyzeMode && appData.autoExtend && origIndex - startPV < 5); return TRUE; } @@ -7260,8 +7261,8 @@ Mark (Board board, int flags, ChessMove kind, int rf, int ff, int rt, int ft, VO if(rf == fromY && ff == fromX && (killX < 0 && !(rt == rf && ft == ff) || abs(ft-killX) < 2 && abs(rt-killY) < 2)) (*m)[rt][ft] = 1 + (board[rt][ft] != EmptySquare || kind == WhiteCapturesEnPassant - || kind == BlackCapturesEnPassant) + 3*(kind == FirstLeg && killX < 0); - else if(flags & F_MANDATORY_CAPTURE && board[rt][ft] != EmptySquare) (*m)[rt][ft] = 3; + || kind == BlackCapturesEnPassant) + 3*(kind == FirstLeg && killX < 0), legal[rt][ft] = 1; + else if(flags & F_MANDATORY_CAPTURE && board[rt][ft] != EmptySquare) (*m)[rt][ft] = 3, legal[rt][ft] = 1; } static int hoverSavedValid; @@ -7277,7 +7278,7 @@ MarkTargetSquares (int clear) } else { int capt = 0; if(!appData.markers || !appData.highlightDragging || appData.icsActive && gameInfo.variant < VariantShogi || - !appData.testLegality || gameMode == EditPosition) return; + !appData.testLegality && !pieceDefs || gameMode == EditPosition) return; GenLegal(boards[currentMove], PosFlags(currentMove), Mark, (void*) marker, EmptySquare); if(PosFlags(0) & F_MANDATORY_CAPTURE) { for(x=0; x1) capt++; @@ -7353,7 +7354,7 @@ void ReportClick(char *action, int x, int y) char buf[MSG_SIZ]; // Inform engine of what user does int r, f; if(action[0] == 'l') // mark any target square of a lifted piece as legal to-square, clear markers - for(r=0; r= BOARD_LEFT && fromX < BOARD_RGHT && (x != killX || y != killY) && !sweepSelecting) { if(dragging) DragPieceEnd(xPix, yPix), dragging = 0; DisplayMessage(_("only marked squares are legal"),""); DrawPosition(TRUE, NULL); @@ -8371,10 +8373,10 @@ BitbaseProbe () // probe EGBB if(loaded == 2) return 13; // loading failed before if(loaded == 0) { - loaded = 2; // prepare for failure char *p, *path = strstr(appData.egtFormats, "scorpio:"), buf[MSG_SIZ]; HMODULE lib; PLOAD_EGBB loadBB; + loaded = 2; // prepare for failure if(!path) return 13; // no egbb installed strncpy(buf, path + 8, MSG_SIZ); if(p = strchr(buf, ',')) *p = NULLCHAR; else p = buf + strlen(buf); @@ -8727,7 +8729,7 @@ FakeBookMove: // [HGM] book: we jump here to simulate machine moves after book h if( count & 1 ) { score = -score; /* Flip score for winning side */ } -printf("score=%d count=%d\n",score,count); + if( score > appData.adjudicateLossThreshold ) { break; } @@ -8886,6 +8888,19 @@ printf("score=%d count=%d\n",score,count); startedFromSetupPosition = TRUE; return; } + if(sscanf(message, "piece %s %s", buf2, buf1) == 2) { + ChessSquare piece = WhitePawn; + char *p=buf2; + if(cps != &first || appData.testLegality) return; + if(*p == '+') piece = CHUPROMOTED WhitePawn, p++; + piece += CharToPiece(*p) - WhitePawn; + if(piece < EmptySquare) { + pieceDefs = TRUE; + ASSIGN(pieceDesc[piece], buf1); + if(isupper(*p) && p[1] == '&') { ASSIGN(pieceDesc[WHITE_TO_BLACK piece], buf1); } + } + return; + } /* [HGM] Allow engine to set up a position. Don't ask me why one would * want this, I was asked to put it in, and obliged. */ @@ -9867,6 +9882,7 @@ ApplyMove (int fromX, int fromY, int toX, int toY, int promoChar, Board board) if(gameInfo.variant == VariantBerolina) berolina = EP_BEROLIN_A; oldEP = (signed char)board[EP_STATUS]; board[EP_STATUS] = EP_NONE; + board[EP_FILE] = board[EP_RANK] = 100; if (fromY == DROP_RANK) { /* must be first */ @@ -9901,6 +9917,7 @@ ApplyMove (int fromX, int fromY, int toX, int toY, int promoChar, Board board) if(fromY != toY) // [HGM] Xiangqi sideway Pawn moves should not count as 50-move breakers board[EP_STATUS] = EP_PAWN_MOVE; if( toY-fromY==2) { + board[EP_FILE] = (fromX + toX)/2; board[EP_RANK] = (fromY + toY)/2; if(toX>BOARD_LEFT && board[toY][toX-1] == BlackPawn && gameInfo.variant != VariantBerolina || toX < fromX) board[EP_STATUS] = toX | berolina; @@ -9913,6 +9930,7 @@ ApplyMove (int fromX, int fromY, int toX, int toY, int promoChar, Board board) if(fromY != toY) // [HGM] Xiangqi sideway Pawn moves should not count as 50-move breakers board[EP_STATUS] = EP_PAWN_MOVE; if( toY-fromY== -2) { + board[EP_FILE] = (fromX + toX)/2; board[EP_RANK] = (fromY + toY)/2; if(toX>BOARD_LEFT && board[toY][toX-1] == WhitePawn && gameInfo.variant != VariantBerolina || toX < fromX) board[EP_STATUS] = toX | berolina; @@ -11607,6 +11625,8 @@ Reset (int redraw, int init) fprintf(debugFP, "Reset(%d, %d) from gameMode %d\n", redraw, init, gameMode); } + pieceDefs = FALSE; // [HGM] gen: reset engine-defined piece moves + for(i=0; iposition >= 0) { // selected? LoadGame(f, nItem, "", TRUE); SaveGamePGN2(g); // leaves g open - cnt++; + cnt++; DoEvents(); } lg = (ListGame *) lg->node.succ; } @@ -15887,8 +15925,11 @@ CreateBookEvent () /* Get list size */ for (nItem = 1; nItem <= ((ListGame *) gameList.tailPred)->number; nItem++){ - LoadGame(f, nItem, "", TRUE); - AddGameToBook(TRUE); + if(lg->position >= 0) { + LoadGame(f, nItem, "", TRUE); + AddGameToBook(TRUE); + DoEvents(); + } lg = (ListGame *) lg->node.succ; } @@ -16587,6 +16628,10 @@ EngineDefinedVariant (ChessProgramState *cps, int n) v = StringToVariant(s); if(v == VariantNormal && strcmp(s, "normal") && !strstr(s, "_normal")) v = VariantUnknown; // garbage is recognized as normal if(v == VariantUnknown) { // non-standard variant in list of engine-supported variants + if(!strcmp(s, "tenjiku") || !strcmp(s, "dai") || !strcmp(s, "dada") || // ignore Alien-Edition variants + !strcmp(s, "maka") || !strcmp(s, "tai") || !strcmp(s, "kyoku") || + !strcmp(s, "checkers") || !strcmp(s, "go") || !strcmp(s, "reversi") || + !strcmp(s, "dark") || !strcmp(s, "alien") || !strcmp(s, "multi") || !strcmp(s, "amazons") ) n++; if(--n < 0) safeStrCpy(buf, s, MSG_SIZ); } if(p) *p++ = ',';