null move and zugzwang detection

Discussion of chess software programming and technical issues.

Moderator: Ras

benstoker
Posts: 342
Joined: Tue Jan 19, 2010 2:05 am

null move and zugzwang detection

Post by benstoker »

As a blind hacker I was fooling around with the zugzwang detection code in ivanhoe in evaluation.c and mobility.c, which was added [by NASA's engineers according to V.D.] beginning with version 53.

Then, around the block at that other forum the following zz position was posted:

1Q6/8/8/2pK3p/8/5N1q/1P4pp/5Rbk w - - 0 1

The correct move is 2. Rb1 as follows: 1.Qxh2+ Qxh2 2.Rb1 c4 3.Kc6 h4 4.Kb7 h3 . . . [note the white king dance]

Houdini 1.03 finds this almost immediately. stockfish 1.8 doesn't find it and they say rybka doesn't find it either.

Even though ivanhoe 53 has added "zugzwang detection", 53 fails to find this also. But wait ...

Enter my hack job:

Code: Select all

--- ../IvanHoe-Beta-999953-Beta/evaluation.c	2010-07-16 09:22:00.000000000 -0500
+++ evaluation.c	2010-08-02 12:27:09.000000000 -0500
@@ -354,7 +354,7 @@
   typePawnEval PAWN_INFO[1];
   int ch;
 #ifdef ZUGZWANG_DETECT
-  boolean wzug = TRUE, bzug = TRUE;
+  boolean wzug = FALSE, bzug = FALSE;
 #endif
 
   PAWN_POINTER = PawnHash + (POSITION->DYN->PAWN_HASH & (PawnHashSize - 1));
@@ -633,7 +633,7 @@
       T = A & wSafeMob;
 #ifdef ZUGZWANG_DETECT
       if (A & ~wBitboardOcc)
-	wzug = FALSE;
+	wzug = TRUE;
 #endif
       POSITION->DYN->wAtt |= A;
       if (A & bKatt)
@@ -669,7 +669,7 @@
       A = AttR (b);
 #ifdef ZUGZWANG_DETECT
       if (A & ~wBitboardOcc)
-	wzug = FALSE;
+	wzug = TRUE;
 #endif
       POSITION->DYN->wAtt |= A;
       if (bBitboardK & ORTHO[b])
@@ -777,7 +777,7 @@
       A = AttB (b);
 #ifdef ZUGZWANG_DETECT
       if (A & ~wBitboardOcc)
-	wzug = FALSE;
+	wzug = TRUE;
 #endif
       POSITION->DYN->wAtt |= A;
       if (bBitboardK & DIAG[b])
@@ -853,7 +853,7 @@
       A = AttN[b];
 #ifdef ZUGZWANG_DETECT
       if (A & ~wBitboardOcc)
-	wzug = FALSE;
+	wzug = TRUE;
 #endif
       POSITION->DYN->wAtt |= A;
       if (A & (bKatt | bBitboardK))
@@ -942,7 +942,7 @@
       A = AttB | AttR;
 #ifdef ZUGZWANG_DETECT
       if (A & ~bBitboardOcc)
-	bzug = FALSE;
+	bzug = TRUE;
 #endif
       T = A & bSafeMob;
       POSITION->DYN->bAtt |= A;
@@ -981,7 +981,7 @@
       A = AttR (b);
 #ifdef ZUGZWANG_DETECT
       if (A & ~bBitboardOcc)
-	bzug = FALSE;
+	bzug = TRUE;
 #endif
       POSITION->DYN->bAtt |= A;
       if (wBitboardK & ORTHO[b])
@@ -1089,7 +1089,7 @@
       A = AttB (b);
 #ifdef ZUGZWANG_DETECT
       if (A & ~bBitboardOcc)
-	bzug = FALSE;
+	bzug = TRUE;
 #endif
       POSITION->DYN->bAtt |= A;
       if (wBitboardK & DIAG[b])
@@ -1167,7 +1167,7 @@
       A = AttN[b];
 #ifdef ZUGZWANG_DETECT
       if (A & ~bBitboardOcc)
-	bzug = FALSE;
+	bzug = TRUE;
 #endif
       POSITION->DYN->bAtt |= A;
       if (A & (wKatt | wBitboardK))
And mobility.c

Code: Select all

--- ../IvanHoe-Beta-999953-Beta/mobility.c	2010-07-16 09:22:00.000000000 -0500
+++ mobility.c	2010-08-02 12:28:53.000000000 -0500
@@ -6,7 +6,7 @@
   uint64 U, A, T, AttB, AttR;
   int b;
 #ifdef ZUGZWANG_DETECT
-  boolean wzug = TRUE, bzug = TRUE;
+  boolean wzug = FALSE, bzug = FALSE;
 #endif
   POSITION->DYN->wXray = 0;
   POSITION->DYN->bXray = 0;
@@ -28,7 +28,7 @@
       A = AttN[b];
 #ifdef ZUGZWANG_DETECT
       if (A & ~wBitboardOcc)
-	wzug = FALSE;
+	wzug = TRUE;
 #endif
       POSITION->DYN->wAtt |= A;
       if (A & bBitboardK)
@@ -40,7 +40,7 @@
       A = AttB (b);
 #ifdef ZUGZWANG_DETECT
       if (A & ~wBitboardOcc)
-	wzug = FALSE;
+	wzug = TRUE;
 #endif
       POSITION->DYN->wAtt |= A;
       if (A & bBitboardK)
@@ -59,7 +59,7 @@
       A = AttR (b);
 #ifdef ZUGZWANG_DETECT
       if (A & ~wBitboardOcc)
-	wzug = FALSE;
+	wzug = TRUE;
 #endif
       POSITION->DYN->wAtt |= A;
       if (A & bBitboardK)
@@ -80,7 +80,7 @@
       A = AttB | AttR;
 #ifdef ZUGZWANG_DETECT
       if (A & ~wBitboardOcc)
-	wzug = FALSE;
+	wzug = TRUE;
 #endif
       POSITION->DYN->wAtt |= A;
       if (A & bBitboardK)
@@ -106,7 +106,7 @@
       A = AttN[b];
 #ifdef ZUGZWANG_DETECT
       if (A & ~bBitboardOcc)
-	bzug = FALSE;
+	bzug = TRUE;
 #endif
       POSITION->DYN->bAtt |= A;
       if (A & wBitboardK)
@@ -118,7 +118,7 @@
       A = AttB (b);
 #ifdef ZUGZWANG_DETECT
       if (A & ~bBitboardOcc)
-	bzug = FALSE;
+	bzug = TRUE;
 #endif
       POSITION->DYN->bAtt |= A;
       if (A & wBitboardK)
@@ -137,7 +137,7 @@
       A = AttR (b);
 #ifdef ZUGZWANG_DETECT
       if (A & ~bBitboardOcc)
-	bzug = FALSE;
+	bzug = TRUE;
 #endif
       POSITION->DYN->bAtt |= A;
       if (A & wBitboardK)
@@ -158,7 +158,7 @@
       A = AttB | AttR;
 #ifdef ZUGZWANG_DETECT
       if (A & ~bBitboardOcc)
-	bzug = FALSE;
+	bzug = TRUE;
 #endif
       POSITION->DYN->bAtt |= A;
       if (A & wBitboardK)

which simply switches wzug true to false and false to true as indicated. With this hack ivanhoe 53 immediately finds the zz and others that were posted:

3Q4/3p4/P2p4/N2b4/8/4P3/5p1p/5Kbk w - - 0 1

and

5q1k/5P1p/Q7/5n1p/6P1/7K/8/8 w - - 0 1

Robert Houdart responds that my hack kills null move and that this is the reason it finds the zz, but at great cost to normal play. As indicated, it is possible to switch off this zz detection code completely at compile time.

Why, then, does the true/false switcheroo hack kill null move, but switching off the code completely via #define ZUGZWANG_DETECT FALSE apparently does not kill null move.

Finally, wouldn't it be possible to simply add a condition that only turns this hack on, if in the endgame?
jhaglund
Posts: 173
Joined: Sun May 11, 2008 7:43 am

Re: null move and zugzwang detection

Post by jhaglund »

Finally, wouldn't it be possible to simply add a condition that only turns this hack on, if in the endgame?
Definately possible. :)
mhalstern
Posts: 484
Joined: Wed Nov 18, 2009 1:09 am

Re: null move and zugzwang detection

Post by mhalstern »

Who is V.D?
UncombedCoconut
Posts: 319
Joined: Fri Dec 18, 2009 11:40 am
Location: Naperville, IL

Re: null move and zugzwang detection

Post by UncombedCoconut »

mhalstern wrote:Who is V.D?
He's referring to Vincent Diepeveen, and probably this comment.