From: H.G. Muller Date: Mon, 2 Apr 2012 08:18:37 +0000 (+0200) Subject: Let clicking on header line exclude moves X-Git-Url: http://winboard.nl/cgi-bin?a=commitdiff_plain;h=c1e72af1b98ee0fa2d203eb4b896ab7e099b51d6;p=xboard.git Let clicking on header line exclude moves The exclude header in the Engine-Output window can now be clicked, to toggle the exlusion of the listed move. Clicking on 'none' resets all exclusions, clicking on 'best' excludes the first move of the latest PV. The pseudo-move 'tail' represents all non-listed moves. --- diff --git a/backend.c b/backend.c index e314d42..2ff7c07 100644 --- a/backend.c +++ b/backend.c @@ -222,6 +222,7 @@ int NextTourneyGame P((int nr, int *swap)); int Pairing P((int nr, int nPlayers, int *w, int *b, int *sync)); FILE *WriteTourneyFile P((char *results, FILE *f)); void DisplayTwoMachinesTitle P(()); +static void ExcludeClick P((int index)); #ifdef WIN32 extern void ConsoleCreate(); @@ -5427,8 +5428,8 @@ LoadMultiPV (int x, int y, char *buf, int index, int *start, int *end) *start = *end = 0; return FALSE; } else if(strstr(buf+lineStart, "exclude:") == buf+lineStart) { // exclude moves clicked - DisplayNote("Yes!"); - return; + ExcludeClick(origIndex - lineStart); + return FALSE; } ParsePV(buf+startPV, FALSE, gameMode != AnalyzeMode); *start = startPV; *end = index-1; @@ -6108,25 +6109,32 @@ SendBoard (ChessProgramState *cps, int moveNum) } char exclusionHeader[MSG_SIZ]; -int exCnt, excludePtr, mappedMove = -1; +int exCnt, excludePtr; typedef struct { int ff, fr, tf, tr, pc, mark; } Exclusion; static Exclusion excluTab[200]; static char excludeMap[(BOARD_RANKS*BOARD_FILES*BOARD_RANKS*BOARD_FILES+7)/8]; // [HGM] exclude: bitmap for excluced moves -void +static void +WriteMap (int s) +{ + int j; + for(j=0; j<(BOARD_RANKS*BOARD_FILES*BOARD_RANKS*BOARD_FILES+7)/8; j++) excludeMap[j] = s; + exclusionHeader[19] = s ? '-' : '+'; // update tail state +} + +static void ClearMap () { int j; - mappedMove = -1; - for(j=0; j<(BOARD_RANKS*BOARD_FILES*BOARD_RANKS*BOARD_FILES+7)/8; j++) excludeMap[j] = 0; - safeStrCpy(exclusionHeader, "exclude: none best tail \n", MSG_SIZ); + safeStrCpy(exclusionHeader, "exclude: none best +tail \n", MSG_SIZ); excludePtr = 24; exCnt = 0; + WriteMap(0); } -void -UpdateExcludeHeader (int fromY, int fromX, int toY, int toX, char promoChar, int incl) -{ - char buf[2*MOVE_LEN], *p, c = incl ? '+' : '-'; +static void +UpdateExcludeHeader (int fromY, int fromX, int toY, int toX, char promoChar, char state) +{ // search given move in table of header moves, to know where it is listed (and add if not there), and update state + char buf[2*MOVE_LEN], *p; Exclusion *e = excluTab; int i; for(i=0; i>= 3; + if(state == '*') state = (excludeMap[k] & 1< 18) { // tail + if(exclusionHeader[19] == '-') { // tail was excluded + SendToProgram("include all\n", &first); + WriteMap(0); // clear map completely + // now re-exclude selected moves + for(i=0; i index) { + char *p=exclusionHeader + excluTab[i].mark; // do trust header more than map (promotions!) + ExcludeOneMove(e[i].fr, e[i].ff, e[i].tr, e[i].tf, e[i].pc, *p == '+' ? '-' : '+'); + break; + } + } } ChessSquare @@ -6591,18 +6664,6 @@ UserMoveEvent(int fromX, int fromY, int toX, int toY, int promoChar) return; } - if(doubleClick && (toX == -2 || toY == -2)) { // [HGM] exclude: off-board move means exclude all - int i; // note that drop moves still have holdings coords as from-square at this point - ChessMove moveType; char pc; - for(i=0; i<(BOARD_RANKS*BOARD_FILES*BOARD_RANKS*BOARD_FILES+7)/8; i++) excludeMap[i] = -(toY == -2); - mappedMove = currentMove; - if(toY != -2) { SendToProgram("include all\n", &first); return; } - SendToProgram("exclude all\n", &first); - i = ParseOneMove(lastPV[0], currentMove, &moveType, &fromX, &fromY, &toX, &toY, &pc); - ff=fromX, rf=fromY, ft=toX, rt=toY, promoChar = pc; // make copy that will survive drop encoding - if(!i) return; // kludge: continue with move changed to engine's last-reported best, so it gets included again. - } - if(toX < 0 || toY < 0) return; pdown = boards[currentMove][fromY][fromX]; pup = boards[currentMove][toY][toX]; @@ -6635,18 +6696,9 @@ UserMoveEvent(int fromX, int fromY, int toX, int toY, int promoChar) } if(doubleClick) { // [HGM] exclude: move entered with double-click on from square is for exclusion, not playing - int i=(BOARD_FILES*rf+ff)*BOARD_RANKS*BOARD_FILES + (BOARD_FILES*rt+ft), j; - char buf[MSG_SIZ]; - if(mappedMove != currentMove) ClearMap(); - j = i%8; i >>= 3; - snprintf(buf, MSG_SIZ, "%sclude ", excludeMap[i] & 1<