X-Git-Url: http://hgm.nubati.net/cgi-bin/gitweb.cgi?p=xboard.git;a=blobdiff_plain;f=backend.c;h=2df9b7dea0b8a694be57cd3e2f8c920059be58d8;hp=742bf03ccf2aa17a34d8ebb0713de5e984af610d;hb=ee20915c04987acfee544c7fa37b856a791d3960;hpb=be541ab4c266fefbe1e4a573d64e34068e41ff42;ds=sidebyside diff --git a/backend.c b/backend.c index 742bf03c..2df9b7de 100644 --- a/backend.c +++ b/backend.c @@ -6897,6 +6897,17 @@ Adjudicate(ChessProgramState *cps) if( count == backwardMostMove ) count -= initialRulePlies; count = forwardMostMove - count; + if(gameInfo.variant == VariantXiangqi && ( count >= 100 || count >= 2*appData.ruleMoves ) ) { + // adjust reversible move counter for checks in Xiangqi + int i = forwardMostMove - count, inCheck = 0, lastCheck; + if(i < backwardMostMove) i = backwardMostMove; + while(i <= forwardMostMove) { + lastCheck = inCheck; // check evasion does not count + inCheck = (MateTest(boards[i], PosFlags(i)) == MT_CHECK); + if(inCheck || lastCheck) count--; // check does not count + i++; + } + } if( count >= 100) boards[forwardMostMove][EP_STATUS] = EP_RULE_DRAW; /* this is used to judge if draw claims are legal */