From 6b60ddf69ce961d41a579a258444f653729e5c95 Mon Sep 17 00:00:00 2001 From: H.G. Muller Date: Sun, 24 Feb 2013 11:47:08 +0100 Subject: [PATCH] Fix crash in double-push, and make it subject to chessFlag Passed squares in NewNonCapt are used as array index, and should not be mutilated with flags! As the M (=non-capt only) move type is now also used in Shatranj, make the double-push subject to a new chessFlag. --- hachu.c | 9 +++++---- 1 files changed, 5 insertions(+), 4 deletions(-) diff --git a/hachu.c b/hachu.c index 9bc797c..173aae9 100644 --- a/hachu.c +++ b/hachu.c @@ -92,8 +92,8 @@ typedef struct { } UndoInfo; char *array, fenArray[4000], *reason; -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 bWidth, bHeight, bsize, zone, currentVariant, chuFlag, tenFlag, chessFlag; +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]; @@ -760,6 +760,7 @@ Init (int var) bsize = bWidth*bHeight; chuFlag = (currentVariant == V_CHU); tenFlag = (currentVariant == V_TENJIKU); + chessFlag = (currentVariant == V_CHESS); for(i= -1; i<9; i++) { // board steps in linear coordinates kStep[i] = STEP(direction[i&7].x, direction[i&7].y); // King @@ -945,8 +946,8 @@ GenNonCapts (int promoSuppress) } } else if(r == M) { // FIDE Pawn; check double-move - if(!NewNonCapture(x, x+v, pFlag) && promoBoard[x-v]) - NewNonCapture(x, x+2*v+DEFER, pFlag); // use promoSuppress flag as e.p. flag + if(!NewNonCapture(x, x+v, pFlag) && chessFlag && promoBoard[x-v]) + NewNonCapture(x, x+2*v, pFlag), moveStack[msp-1] |= DEFER; // use promoSuppress flag as e.p. flag } continue; } -- 1.7.0.4