Fix Shatranj game-end messages
authorH.G. Muller <h.g.muller@hccnet.nl>
Sat, 16 Jan 2010 13:09:58 +0000 (14:09 +0100)
committerH.G. Muller <h.g.muller@hccnet.nl>
Sat, 16 Jan 2010 13:09:58 +0000 (14:09 +0100)
Because stalemate was tested before the conditionally included shatranj
bare-king code, it was not effective. Furthermore, the stalemate code
was still claiming a draw. Now ShaMax has its own stalemate code, put
after the bare-king test.

fairymax.c

index 92bf8a9..4db818e 100644 (file)
@@ -319,10 +319,31 @@ int PrintResult(int s)
         }\r
         K=I;\r
         cnt = D(s,-I,I,Q,O,LL|4*S,3);\r
+#ifdef SHATRANJ\r
+        if(pl[s]==1 && pl[16-s]==1) {\r
+                printf("1/2-1/2 {Insufficient mating material}\n");\r
+                return 4;\r
+        }\r
+        if(pl[s]<=1 && pl[16-s]>1) {\r
+                if (s == BLACK)\r
+                        printf("0-1 {Bare King}\n");\r
+                else\r
+                        printf("1-0 {Bare King}\n");\r
+                return 5;\r
+        }\r
+        if(cnt>-I+1 && K==0 && L==0) {\r
+                if (s == WHITE)\r
+                        printf("0-1 {Stalemate}\n");\r
+                else\r
+                        printf("1-0 {Stalemate}\n");\r
+                return 2;\r
+        }\r
+#else\r
         if(cnt>-I+1 && K==0 && L==0) {\r
                 printf("1/2-1/2 {Stalemate}\n");\r
                 return 2;\r
         }\r
+#endif\r
         if(cnt==-I+1) {\r
                 if (s == WHITE)\r
                         printf("0-1 {Black mates}\n");\r
@@ -334,19 +355,6 @@ int PrintResult(int s)
                 printf("1/2-1/2 {Draw by fifty move rule}\n");\r
                 return 4;\r
         }\r
-#ifdef SHATRANJ\r
-        if(pl[s]==1 && pl[16-s]==1) {\r
-                printf("1/2-1/2 {Insufficient mating material}\n");\r
-                return 4;\r
-        }\r
-        if(pl[s]<=1 && pl[16-s]>1) {\r
-                if (s == BLACK)\r
-                        printf("0-1 {Bare King}\n");\r
-                else\r
-                        printf("1-0 {Bare King}\n");\r
-                return 5;\r
-        }\r
-#endif\r
         return 0;\r
 }\r
 \r