X-Git-Url: http://winboard.nl/cgi-bin?a=blobdiff_plain;f=hachu.c;h=b6d3786b1af7bda38570d6b3c4ac4a8acae7701f;hb=24ab76e88481f6e0445bc220845be691435bd755;hp=38ae201ec9874cc4b61d5adc4cf7f9d770a7365f;hpb=675b3eccdfeb513418480daf5e4b01a202bea1f0;p=hachu.git diff --git a/hachu.c b/hachu.c index 38ae201..b6d3786 100644 --- a/hachu.c +++ b/hachu.c @@ -11,7 +11,7 @@ // promotions by pieces with Lion power stepping in & out the zone in same turn // promotion on capture -#define VERSION "0.1beta" +#define VERSION "0.6beta" #define PATH level==0 || path[0] == 0xc4028 && (level==1 /*|| path[1] == 0x75967 && (level == 2 || path[2] == 0x3400b && (level == 3))*/) //define PATH 0 @@ -40,7 +40,7 @@ #define BSIZE BWMAX*BHMAX #define ZONE zone -#define ONE (currentVariant == V_SHO || currentVariant == V_CHESS) +#define ONE (currentVariant == V_SHO || currentVariant == V_CHESS || currentVariant == V_SHATRANJ || currentVariant == V_MAKRUK) #define BLACK 0 #define WHITE 1 @@ -91,11 +91,13 @@ typedef struct { char fireMask; } UndoInfo; -char *array; -int bWidth, bHeight, bsize, zone, currentVariant; -int stm, xstm, hashKeyH, hashKeyL, framePtr, msp, nonCapts, rootEval, retMSP, retFirst, retDep, pvPtr, level, cnt50, chuFlag=1, tenFlag, mobilityScore; -int nodes, startTime, tlim1, tlim2; -Move retMove, moveStack[10000], path[100], repStack[300], pv[1000]; +char *array, fenArray[4000], *reason; +int bWidth, bHeight, bsize, zone, currentVariant, chuFlag, tenFlag, chessFlag, repDraws; +int stm, xstm, hashKeyH, hashKeyL, framePtr, msp, nonCapts, rootEval, retMSP, retFirst, retDep, pvPtr, level, cnt50, mobilityScore; +int nodes, startTime, tlim1, tlim2, repCnt, comp; +Move retMove, moveStack[10000], path[100], repStack[300], pv[1000], repeatMove[300]; + + int maxDepth; // used by search #define X 36 /* slider */ #define R 37 /* jump capture */ @@ -324,6 +326,26 @@ PieceDesc chessPieces[] = { { NULL } // sentinel }; +PieceDesc shatranjPieces[] = { + {"FK", "", 15, { 0,1,0,1,0,1,0,1 } }, + {"R", "", 50, { X,0,X,0,X,0,X,0 } }, + {"B", "", 9, { 0,J,0,J,0,J,0,J } }, + {"N", "", 30, { N,N,N,N,N,N,N,N } }, + {"K", "", 28, { 1,1,1,1,1,1,1,1 } }, + {"P", "FK", 8, { M,C,0,0,0,0,0,C } }, + { NULL } // sentinel +}; + +PieceDesc makrukPieces[] = { + {"SM","", 15, { 0,1,0,1,0,1,0,1 } }, + {"R", "", 50, { X,0,X,0,X,0,X,0 } }, + {"S", "", 20, { 1,1,0,1,0,1,0,1 } }, // silver + {"N", "", 30, { N,N,N,N,N,N,N,N } }, + {"K", "", 28, { 1,1,1,1,1,1,1,1 } }, + {"P", "SM", 8, { M,C,0,0,0,0,0,C } }, + { NULL } // sentinel +}; + char chuArray[] = "L:FLCSGK:DEGSC:FLL/:RV.B.:BT:KN:PH:BT.B.:RV/:SM:VMR:DH:DK:LN:FK:DK:DHR:VM:SM/PPPPPPPPPPPP/...:GB....:GB..." "/............/............/" "...:gb....:gb.../pppppppppppp/:sm:vmr:dh:dk:fk:ln:dk:dhr:vm:sm/:rv.b.:bt:ph:kn:bt.b.:rv/l:flcsg:dekgsc:fll"; @@ -337,6 +359,8 @@ char tenArray[] = "LN:FLICSGK:DEGSCI:FLNL/:RV.:CS:CS.:BT:KN:LN:FK:PH:BT.:CS:CS.: ":ss:vsb:dh:dk:wb:fi:fe:lh:fi:wb:dk:dhb:vs:ss/:rv.:cs:cs.:bt:ph:fk:ln:kn:bt.:cs:cs.:rv/ln:flicsg:dekgsci:flnl"; char shoArray[] = "LNSGKGSNL/.B..:DE..R./PPPPPPPPP/........./........./........./ppppppppp/.r..:de..b./lnsgkgsnl"; char chessArray[] = "RNBQKBNR/PPPPPPPP/......../......../......../......../pppppppp/rnbqkbnr"; +char shatArray[]= "RNBK:FKBNR/PPPPPPPP/......../......../......../......../pppppppp/rnbk:fkbnr"; +char thaiArray[]= "RNSK:SMSNR/......../PPPPPPPP/......../......../pppppppp/......../rnsk:smsnr"; typedef struct { int boardWidth, boardFiles, boardRanks, zoneDepth, varNr; // board sizes @@ -344,7 +368,7 @@ typedef struct { char *array; // initial position } VariantDesc; -typedef enum { V_CHESS, V_SHO, V_CHU, V_DAI, V_TENJIKU, V_DADA, V_MAKA, V_TAI, V_KYOKU } Variant; +typedef enum { V_CHESS, V_SHO, V_CHU, V_DAI, V_TENJIKU, V_DADA, V_MAKA, V_TAI, V_KYOKU, V_SHATRANJ, V_MAKRUK } Variant; VariantDesc variants[] = { { 16, 8, 8, 1, V_CHESS, "normal", chessArray }, // FIDE @@ -352,6 +376,9 @@ VariantDesc variants[] = { { 24, 12, 12, 4, V_CHU, "chu", chuArray }, // Chu { 30, 15, 15, 5, V_DAI, "dai", daiArray }, // Dai { 32, 16, 16, 5, V_TENJIKU, "tenjiku", tenArray }, // Tenjiku + { 16, 8, 8, 1, V_SHATRANJ,"shatranj",shatArray}, // Shatranj + { 16, 8, 8, 3, V_MAKRUK, "makruk", thaiArray}, // Makruk + // { 0, 0, 0, 0, 0 }, // sentinel { 34, 17, 17, 0, V_DADA, "dada", chuArray }, // Dai Dai { 38, 19, 19, 0, V_MAKA, "maka", chuArray }, // Maka Dai Dai @@ -532,6 +559,10 @@ LookUp (char *name, int var) return ListLookUp(name, chuPieces); case V_CHESS: // FIDE return ListLookUp(name, chessPieces); + case V_SHATRANJ: // Shatranj + return ListLookUp(name, shatranjPieces); + case V_MAKRUK: // Makruk + return ListLookUp(name, makrukPieces); } return NULL; } @@ -626,6 +657,7 @@ Compactify (int stm) } } for(i=stm+2; i= i) p[j].promo += 2; } if(royal[stm] >= i) royal[stm] += 2; - if(p[i].value == (currentVariant == V_SHO ? 410 : 280) ) royal[stm] = i; + if(p[i].value == (currentVariant == V_SHO ? 410 : 280) ) royal[stm] = i, p[i].pst = 0; p[i].qval = (currentVariant == V_TENJIKU ? list->ranking : 0); // jump-capture hierarchy return i; } @@ -670,11 +702,13 @@ SetUp(char *array, int var) char c, *q, name[3]; PieceDesc *p1, *p2; last[WHITE] = 1; last[BLACK] = 0; - if(var == V_CHESS) // add dummy Crown Princes + if(var == V_CHESS || var == V_SHATRANJ || var == V_MAKRUK) // add dummy Crown Princes p[AddPiece(WHITE, LookUp("CP", V_CHU))].pos = p[AddPiece(BLACK, LookUp("CP", V_CHU))].pos = ABSENT; for(i=0; ; i++) { //printf("next rank: %s\n", array); for(j = BW*i; ; j++) { + int pflag=0; + if(*array == '+') pflag++, array++; c = name[0] = *array++; if(!c) goto eos; if(c == '.') continue; @@ -687,9 +721,11 @@ SetUp(char *array, int var) if(name[1]) name[1] += 'A' - 'a'; } else color = WHITE; p1 = LookUp(name, var); + if(!p1) printf("tellusererror Unknown piece '%s' in setup\n", name), exit(-1); + if(pflag && p1->promoted) p1 = LookUp(p1->promoted, var); // use promoted piece instead n = AddPiece(color, p1); p[n].pos = j; - if(p1->promoted[0]) { + if(p1->promoted[0] && !pflag) { p2 = LookUp(p1->promoted, var); m = AddPiece(color, p2); if(m <= n) n += 2; @@ -738,6 +774,8 @@ Init (int var) bsize = bWidth*bHeight; chuFlag = (currentVariant == V_CHU); tenFlag = (currentVariant == V_TENJIKU); + chessFlag = (currentVariant == V_CHESS); + repDraws = (currentVariant == V_CHESS || currentVariant == V_SHATRANJ || currentVariant == V_MAKRUK); for(i= -1; i<9; i++) { // board steps in linear coordinates kStep[i] = STEP(direction[i&7].x, direction[i&7].y); // King @@ -789,7 +827,8 @@ Init (int var) // piece-square tables for(i=0; i= S && p[attacker].range[i] != J) { // has Knight jump in our direction + if(p[attacker].range[i] <= L && p[attacker].range[i] >= S || p[attacker].range[i] == N) { // has Knight jump in our direction NewCapture(x, sqr + victimValue, p[attacker].promoFlag); // plain jump (as in N) if(p[attacker].range[i] < N) { // Lion power; generate double captures over two possible intermediates int v = kStep[i]; // leftish path @@ -1522,7 +1575,7 @@ if(PATH) /*pboard(board),pmap(attacks, BLACK),*/printf("search(%d) {%d,%d} eval= nodes++; pv[pvPtr++] = 0; // start empty PV, directly behind PV of parent - firstMove = curMove = sorted = msp += 20; // leave 20 empty slots in front of move list + firstMove = curMove = sorted = msp += 50; // leave 50 empty slots in front of move list tb.fireMask = phase = 0; iterDep=1; replyDep = (depth < 1 ? depth : 1) - 1; do { if(flag && depth>= 0) printf("iter %d:%d\n", depth,iterDep),fflush(stdout); @@ -1540,7 +1593,7 @@ if(flag && depth>= 0) printf("phase=%d: first/curr/last = %d / %d / %d\n", phase #if 0 if(curEval >= beta) { stm ^= WHITE; - score = -Search(-beta, -iterAlpha, difEval, depth-3, promoSuppress & SQUARE, ABSENT); + score = -Search(-beta, -iterAlpha, -difEval, depth-3, promoSuppress & SQUARE, ABSENT); stm ^= WHITE; if(score >= beta) { msp = oldMSP; retDep += 3; return score + (score < curEval); } } @@ -1611,7 +1664,7 @@ if(PATH) printf("%d:%2d:%2d msp=%d\n",level,depth,iterDep,msp); // MOVE EXTRACTION extractMove: if(flag & depth >= 0) printf("%2d:%d extract %d/%d\n", depth, iterDep, curMove, msp); - if(curMove < sorted) { + if(curMove > sorted) { move = moveStack[sorted=j=curMove]; for(i=curMove+1; i move) move = moveStack[j=i]; // search move with highest priority @@ -1629,8 +1682,10 @@ if(flag & depth >= 0) printf("%2d:%d found %d/%d %08x %s\n", depth, iterDep, cur if(flag & depth >= 0) printf("%2d:%d made %d/%d %s\n", depth, iterDep, curMove, msp, MoveToText(moveStack[curMove], 0)); for(i=2; i<=cnt50; i+=2) if(repStack[level-i+200] == hashKeyH) { + if(repDraws) { score = 0; goto repetition; } moveStack[curMove] = 0; // erase forbidden move - score = -INF; goto repetition; + if(!level) repeatMove[repCnt++] = move & 0xFFFFFF; // remember outlawed move + score = -INF; moveStack[curMove] = 0; goto repetition; } repStack[level+200] = hashKeyH; @@ -1649,7 +1704,11 @@ MapFromScratch(attacks); // for as long as incremental update does not work. if(promoSuppress & PROMOTE) score = -INF; // non-Lion captures Lion after opponent did same defer |= PROMOTE; // if we started, flag he cannot do it in reply } - if(score == -INF) { moveStack[curMove] = 0; goto abortMove; } // zap illegal moves + if(score == -INF) { + if(level == 1) repeatMove[repCnt++] = move & 0xFFFFFF | (p[tb.piece].value == 10*LVAL ? 3<<24 : 1 << 24); + moveStack[curMove] = 0; // zap illegal moves + goto abortMove; + } } #if 1 score = -Search(-beta, -iterAlpha, -difEval - tb.booty, replyDep, promoSuppress & ~PROMOTE, defer); @@ -1702,7 +1761,9 @@ if(PATH) printf("%d:%2d:%d %3d %6x %-10s %6d %6d\n", level, depth, iterDep, curM int i; // WB thinking output printf("%d %d %d %d", iterDep, bestScore, (GetTickCount() - startTime)/10, nodes); for(i=0; pv[i]; i++) printf(" %s", MoveToText(pv[i], 0)); - printf("\n"); fflush(stdout); + if(iterDep == 1) printf(" { root eval = %4.2f dif = %4.2f; abs = %4.2f}", curEval/100., difEval/100., PSTest()/100.); + printf("\n"); + fflush(stdout); } if(GetTickCount() - startTime > tlim1) break; // do not start iteration we can (most likely) not finish } @@ -1789,14 +1850,12 @@ pmoves(int start, int end) #define INVALID 0 // some parameter of your engine - #define MAXMOVES 500 /* maximum game length */ - #define MAXPLY 60 /* maximum search depth */ + #define MAXMOVES 2000 /* maximum game length */ + #define MAXPLY 20 /* maximum search depth */ #define OFF 0 #define ON 1 -#define DEFAULT_FEN "" - typedef Move MOVE; int moveNr; // part of game state; incremented by MakeMove @@ -1841,13 +1900,56 @@ UnMake2 (MOVE move) sup2 = sup1; sup1 = sup0; } +char fenNames[] = "RV....DKDEFL..DHGB......SMLNKN..FK....BT..VM..PH...."; // pairs of char +char fenPromo[] = "WLDHSMSECPB R HFDE....WHFB..LNG ..DKVMFS..FO..FK...."; // pairs of char + +char * +Convert (char *fen) +{ + char *p = fenArray, *q, *rows[36], tmp[4000]; + int n=0; + printf("# convert FEN '%s'\n", fen); + q = strchr(fen, ' '); if(q) *q = 0; q = fen; + do { rows[n++] = q; q = strchr(q, '/'); if(!q) break; *q++ = 0; } while(1); + *tmp = 0; + while(--n >= 0) { strcat(tmp, rows[n]); if(n) strcat(tmp, "/"); } + fen = tmp; + printf("# flipped FEN '%s'\n", fen); + while(*fen) { + if(*fen == ' ') { *p = 0; break; } + if(n=atoi(fen)) fen++; // digits read + if(n > 9) fen++; // double digit + while(n-- > 0) *p++ = '.'; // expand to empty squares + if(isalpha(*fen)) { + char *table = fenNames; + n = *fen > 'Z' ? 'a' - 'A' : 0; + if((currentVariant == V_CHESS || currentVariant == V_SHATRANJ || currentVariant == V_MAKRUK) && *fen - n == 'N' // In Chess N is Knight, not Lion + || table[2* (*fen - 'A' - n)] == '.') *p++ = *fen; else { + *p++ = ':'; + *p++ = table[2* (*fen - 'A' - n)] + n; + *p++ = table[2* (*fen - 'A' - n)+1] + n; + } + } else *p++ = *fen; + fen++; + } + printf("# converted FEN '%s'\n", fenArray); + return fenArray; +} + int Setup2 (char *fen) { + int stm = WHITE; + if(fen) { + char *q = strchr(fen, '\n'); + if(q) *q = 0; + if(q = strchr(fen, ' ')) stm = (q[1] == 'b' ? BLACK : WHITE); // fen contains color field + if(strchr(fen, '.') || strchr(fen, ':')) array = fen; else array = Convert(fen); + } SetUp(array, currentVariant); sup0 = sup1 = sup2 = ABSENT; - rootEval = cnt50 = hashKeyH = hashKeyL = 0; - return WHITE; + rootEval = cnt50 = hashKeyH = hashKeyL = moveNr = 0; + return stm; } void @@ -1860,6 +1962,7 @@ MoveToText (MOVE move, int multiLine) { static char buf[50]; int f = move>>SQLEN & SQUARE, g = f, t = move & SQUARE; + char *promoChar = ""; if(f == t) { sprintf(buf, "@@@@"); return buf; } // null-move notation in WB protocol buf[0] = '\0'; if(t >= SPECIAL) { // kludgy! Print as side effect non-standard WB command to remove victims from double-capture (breaks hint command!) @@ -1875,7 +1978,8 @@ MoveToText (MOVE move, int multiLine) } t = g + toList[t - SPECIAL]; } - sprintf(buf+strlen(buf), "%c%d%c%d%s", f%BW+'a', f/BW+ONE, t%BW+'a', t/BW+ONE, move & PROMOTE ? "+" : ""); + if(move & PROMOTE) promoChar = currentVariant == V_MAKRUK ? "m" : repDraws ? "q" : "+"; + sprintf(buf+strlen(buf), "%c%d%c%d%s", f%BW+'a', f/BW+ONE, t%BW+'a', t/BW+ONE, promoChar); return buf; } @@ -1909,10 +2013,10 @@ ParseMove (char *moveText) t2 = SPECIAL + 8*i + j; } ret = f<=retMSP) { // no exact match if(deferred) { // but maybe non-sensical deferral int flags = p[board[f]].promoFlag; @@ -1932,8 +2037,17 @@ printf("# deferral of %d\n", deferred); if(!(flags & promoBoard[f])) moveStack[i] |= DEFER; // came from outside zone, so essential deferral } } - if(i >= retMSP) - for(i=retFirst; i= retMSP) { + for(i=retFirst; i= retMSP ? INVALID : moveStack[i]); } @@ -1949,7 +2063,7 @@ MapFromScratch(attacks); //pmap(attacks, WHITE); //pmap(attacks, BLACK); //flag=1; - postThinking--; + postThinking--; repCnt = 0; Search(-INF-1, INF+1, 0, 1, sup1 & ~PROMOTE, sup2); postThinking++; flag=0; @@ -1998,17 +2112,18 @@ flag=0; int SearchBestMove (int stm, int timeLeft, int mps, int timeControl, int inc, int timePerMove, MOVE *move, MOVE *ponderMove) { - int score, targetTime, movesLeft = 50; + int score, targetTime, movesLeft = BW*BH/4 + 20; if(mps) movesLeft = mps - (moveNr>>1)%mps; targetTime = timeLeft*10 / (movesLeft + 2) + 1000 * inc; + if(moveNr < 30) targetTime *= 0.5 + moveNr/60.; // speedup in opening if(timePerMove > 0) targetTime = timeLeft * 5; startTime = GetTickCount(); tlim1 = 0.2*targetTime; tlim2 = 1.9*targetTime; nodes = 0; MapFromScratch(attacks); - retMove = INVALID; - score = Search(-INF-1, INF+1, rootEval, 20, sup1, sup2); + retMove = INVALID; repCnt = 0; + score = Search(-INF-1, INF+1, rootEval, maxDepth, sup1, sup2); *move = retMove; *ponderMove = INVALID; return score; @@ -2022,7 +2137,7 @@ PonderUntilInput (int stm) int TakeBack(int n) { // reset the game and then replay it to the desired point int last, stm; - stm = Setup2(NULL); + Init(currentVariant); stm = Setup2(NULL); printf("# setup done");fflush(stdout); last = moveNr - n; if(last < 0) last = 0; for(moveNr=0; moveNr 0 && stm == WHITE || score < 0 && stm == BLACK) printf("1-0\n"); - else printf("0-1\n"); + char tail[100]; + if(reason) sprintf(tail, " {%s}", reason); else *tail = 0; + if(score == 0) printf("1/2-1/2%s\n", tail); + if(score > 0 && stm == WHITE || score < 0 && stm == BLACK) printf("1-0%s\n", tail); + else printf("0-1%s\n", tail); } main() @@ -2041,9 +2158,8 @@ printf("# setup done");fflush(stdout); int engineSide=NONE; // side played by engine int timeLeft; // timeleft on engine's clock int mps, timeControl, inc, timePerMove; // time-control parameters, to be used by Search - int maxDepth; // used by search MOVE move, ponderMove; - int i, score; + int i, score, curVarNr; char inBuf[8000], command[80]; Init(V_CHU); // Chu @@ -2054,6 +2170,7 @@ printf("# setup done");fflush(stdout); if(stm == engineSide) { // if it is the engine's turn to move, set it thinking, and let it move +pboard(board); score = SearchBestMove(stm, timeLeft, mps, timeControl, inc, timePerMove, &move, &ponderMove); if(move == INVALID) { // game apparently ended @@ -2069,7 +2186,8 @@ printf("# setup done");fflush(stdout); if(kcapt) { // print King capture before claiming GenCapts(k, 0); printf("move %s\n", MoveToText(moveStack[msp-1], 1)); - } + reason = "king capture"; + } else reason = "resign"; engineSide = NONE; // so stop playing PrintResult(stm, score); } else { @@ -2099,8 +2217,6 @@ printf("# setup done");fflush(stdout); // wait for input, and read it until we have collected a complete line for(i = 0; (inBuf[i] = getchar()) != '\n'; i++); inBuf[i+1] = 0; -pboard(board); -pmoves(retFirst, retMSP); // extract the first word sscanf(inBuf, "%s", command); @@ -2122,7 +2238,7 @@ printf("in: %s\n", command); } if(!strcmp(command, "protover")){ printf("feature ping=1 setboard=1 colors=0 usermove=1 memory=1 debug=1 sigint=0 sigterm=0\n"); - printf("feature variants=\"normal,chu,dai,tenjiku,12x12+0_fairy,9x9+0_shogi\"\n"); + printf("feature variants=\"normal,shatranj,makruk,chu,dai,tenjiku,12x12+0_fairy,9x9+0_shogi\"\n"); printf("feature myname=\"HaChu " VERSION "\" highlight=1\n"); printf("feature option=\"Resign -check 0\"\n"); // example of an engine-defined option printf("feature option=\"Contempt -spin 0 -200 200\"\n"); // and another one @@ -2135,11 +2251,10 @@ printf("in: %s\n", command); continue; } if(!strcmp(command, "variant")) { - for(i=0; i<5; i++) { + for(i=0; i<7; i++) { sscanf(inBuf+8, "%s", command); if(!strcmp(variants[i].name, command)) { -printf("var %d\n",i); - Init(i); stm = Setup2(NULL); break; + Init(curVarNr = i); stm = Setup2(NULL); break; } } continue; @@ -2149,8 +2264,11 @@ printf("var %d\n",i); if(!strcmp(command, "memory")) { SetMemorySize(atoi(inBuf+7)); continue; } if(!strcmp(command, "ping")) { printf("pong%s", inBuf+4); continue; } // if(!strcmp(command, "")) { sscanf(inBuf, " %d", &); continue; } - if(!strcmp(command, "new")) { engineSide = BLACK; Init(V_CHESS); stm = Setup2(DEFAULT_FEN); maxDepth = MAXPLY; randomize = OFF; continue; } - if(!strcmp(command, "setboard")){ engineSide = NONE; stm = Setup2(inBuf+9); continue; } + if(!strcmp(command, "new")) { + engineSide = BLACK; Init(V_CHESS); stm = Setup2(NULL); maxDepth = MAXPLY; randomize = OFF; curVarNr = comp = 0; + continue; + } + if(!strcmp(command, "setboard")){ engineSide = NONE; Init(curVarNr); stm = Setup2(inBuf+9); continue; } if(!strcmp(command, "easy")) { ponder = OFF; continue; } if(!strcmp(command, "hard")) { ponder = ON; continue; } if(!strcmp(command, "undo")) { stm = TakeBack(1); continue; } @@ -2171,7 +2289,7 @@ printf("var %d\n",i); if(!strcmp(command, "l")) { pplist(); continue; } // ignored commands: if(!strcmp(command, "xboard")) { continue; } - if(!strcmp(command, "computer")){ continue; } + if(!strcmp(command, "computer")){ comp = 1; continue; } if(!strcmp(command, "name")) { continue; } if(!strcmp(command, "ics")) { continue; } if(!strcmp(command, "accepted")){ continue; } @@ -2181,8 +2299,11 @@ printf("var %d\n",i); if(!strcmp(command, "")) { continue; } if(!strcmp(command, "usermove")){ int move = ParseMove(inBuf+9); - if(move == INVALID) printf("Illegal move\n"); - else { +pboard(board); + if(move == INVALID) { + if(reason) printf("Illegal move {%s}\n", reason); else printf("%s\n", reason="Illegal move"); + if(comp) PrintResult(stm, -INF); // against computer: claim + } else { stm = MakeMove2(stm, move); ponderMove = INVALID; gameMove[moveNr++] = move; // remember game