From ee20915c04987acfee544c7fa37b856a791d3960 Mon Sep 17 00:00:00 2001 From: H.G. Muller Date: Wed, 30 Jun 2010 10:41:25 +0200 Subject: [PATCH] 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. --- backend.c | 11 +++++++++++ 1 files changed, 11 insertions(+), 0 deletions(-) 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 */ -- 1.7.0.4