From: H.G. Muller Date: Wed, 30 Jun 2010 08:41:25 +0000 (+0200) Subject: Ignore checks in 50-move count for Xiangqi X-Git-Url: http://winboard.nl/cgi-bin?a=commitdiff_plain;h=ee20915c04987acfee544c7fa37b856a791d3960;p=xboard.git Ignore checks in 50-move count for Xiangqi Both checks and evasions are discounted; this is only done after the naive counting exceeds the maximum, so during most of the game it causes no CPU load. --- diff --git a/backend.c b/backend.c index 742bf03..2df9b7d 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 */