Make assert exits dependent on DEBUG switch
authorH.G.Muller <hgm@hgm-xboard.(none)>
Mon, 15 May 2017 09:36:28 +0000 (11:36 +0200)
committerH.G.Muller <hgm@hgm-xboard.(none)>
Mon, 15 May 2017 09:36:28 +0000 (11:36 +0200)
The fatal assertion violations are now only occurring in a compile that
has defined the DEBUG macro; normally action is taken to prevent the fault
the error condition would ordinarily cause.

dropper.c

index c05fd91..6aa164d 100644 (file)
--- a/dropper.c
+++ b/dropper.c
@@ -9,6 +9,8 @@
 #include <stdlib.h>
 #include <string.h>
 
+#define DEBUG 0
+
 #define LMR 2
 
 #define ON  1
@@ -1116,7 +1118,7 @@ Search (int stm, int alpha, int beta, StackFrame *ff, int depth, int reduction,
 
     // legality
     int earlyGen = (ff->toPiece == stm+31); // King was moved
-if(ply > 90) Dump("maxply");
+    if(ply > 90) { if(DEBUG) Dump("maxply"); ff->depth = 0; return -ff->newEval+150; }
     f.xking = location[stm+31]; // opponent King, as stm not yet toggled
     if(!earlyGen && ff->mutation > 0) { // if other piece was moved (not dropped!), abort with +INF score if it was pinned
        if(Pinned(stm, ff->fromSqr, f.xking)) return INF;
@@ -1155,10 +1157,10 @@ if(PATH)printf("      Hit, d=%d, checker = %x\n",entry->depth,f.checker);
            }
        }
        hashMove = entry->move;
-if(hashMove && board[hashMove>>8&255] == 0) {char s[100];sprintf(s,"bad hash move %16llx: %s\n", f.hashKey, MoveToText(hashMove)); Dump(s); }
        hit = 1;
        p = board[hashMove>>8&255];
        if(hashMove && ((p & stm) == 0 || p == -1)) {
+           if(DEBUG) printf("telluser bad hash move %16llx: %s\n", f.hashKey, MoveToText(hashMove));
            hashMove = 0; f.checker = CK_UNKNOWN;
        }
     } else hit = hashMove = 0, f.checker = CK_UNKNOWN;
@@ -1227,7 +1229,7 @@ if(hashMove && board[hashMove>>8&255] == 0) {char s[100];sprintf(s,"bad hash mov
     // move generation
     if(!earlyGen) { // generate moves if we had not done so yet
        if(MoveGen(stm, &m, f.rights)) { // impossible (except for hash collision giving wrong in-check status)
-           Dump("King capture");
+           if(DEBUG) Dump("King capture"); ff->depth = MAXPLY; moveSP = oldSP; return INF;
        }
        if(f.checkDist && maxDepth <= 1) ipMask = SafeIP(&f);
     }