From fe7f9a6e90036f2d656a1d3cc4ef197748ef2d75 Mon Sep 17 00:00:00 2001 From: H.G. Muller Date: Sat, 16 Jan 2010 14:09:58 +0100 Subject: [PATCH] Fix Shatranj game-end messages 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 | 34 +++++++++++++++++++++------------- 1 files changed, 21 insertions(+), 13 deletions(-) diff --git a/fairymax.c b/fairymax.c index 92bf8a9..4db818e 100644 --- a/fairymax.c +++ b/fairymax.c @@ -319,10 +319,31 @@ int PrintResult(int s) } K=I; cnt = D(s,-I,I,Q,O,LL|4*S,3); +#ifdef SHATRANJ + if(pl[s]==1 && pl[16-s]==1) { + printf("1/2-1/2 {Insufficient mating material}\n"); + return 4; + } + if(pl[s]<=1 && pl[16-s]>1) { + if (s == BLACK) + printf("0-1 {Bare King}\n"); + else + printf("1-0 {Bare King}\n"); + return 5; + } + if(cnt>-I+1 && K==0 && L==0) { + if (s == WHITE) + printf("0-1 {Stalemate}\n"); + else + printf("1-0 {Stalemate}\n"); + return 2; + } +#else if(cnt>-I+1 && K==0 && L==0) { printf("1/2-1/2 {Stalemate}\n"); return 2; } +#endif if(cnt==-I+1) { if (s == WHITE) printf("0-1 {Black mates}\n"); @@ -334,19 +355,6 @@ int PrintResult(int s) printf("1/2-1/2 {Draw by fifty move rule}\n"); return 4; } -#ifdef SHATRANJ - if(pl[s]==1 && pl[16-s]==1) { - printf("1/2-1/2 {Insufficient mating material}\n"); - return 4; - } - if(pl[s]<=1 && pl[16-s]>1) { - if (s == BLACK) - printf("0-1 {Bare King}\n"); - else - printf("1-0 {Bare King}\n"); - return 5; - } -#endif return 0; } -- 1.7.0.4