Table of Contents
Fetching ...

Complete Implementation of WXF Chinese Chess Rules

Daniel Tan, Neftali Watkinson Medina

TL;DR

This work tackles the complexity of repetition outcomes under World Xiangqi Federation (WXF) rules in Xiangqi, where repetitions can yield win, loss, or draw. It presents a complete algorithm that covers all 110 WXF diagrams, supported by data structures for position history, protected pieces, chasing detection, and a multi-class repetition verdict, augmented with speedups designed for alpha-beta negamax engines. The main contributions include 100% accuracy on the diagram set, a measurable playing-strength gain (+10 Elo after retraining NNUE-style evaluation), and practical applicability as an online referee or AI agent. The results demonstrate that a fully correct repetition-rule implementation is feasible without sacrificing performance, enabling more reliable online play and more robust self-learning Xiangqi engines.

Abstract

Unlike repetitions in Western Chess where all repetitions are draws, repetitions in Chinese Chess could result in a win, draw, or loss depending on the kind of repetition being made by both players. One of the biggest hurdles facing Chinese Chess application development is a proper system for judging games correctly. This paper introduces a complete algorithm for ruling the WXF rules correctly in all 110 example cases found in the WXF manual. We introduce several novel optimizations for speeding up the repetition handling without compromising the program correctness. This algorithm is usable in engines, and we saw a total increase in playing strength by +10 point rating increase, or an increased 5% winrate when integrating this approach into our prototype engine.

Complete Implementation of WXF Chinese Chess Rules

TL;DR

This work tackles the complexity of repetition outcomes under World Xiangqi Federation (WXF) rules in Xiangqi, where repetitions can yield win, loss, or draw. It presents a complete algorithm that covers all 110 WXF diagrams, supported by data structures for position history, protected pieces, chasing detection, and a multi-class repetition verdict, augmented with speedups designed for alpha-beta negamax engines. The main contributions include 100% accuracy on the diagram set, a measurable playing-strength gain (+10 Elo after retraining NNUE-style evaluation), and practical applicability as an online referee or AI agent. The results demonstrate that a fully correct repetition-rule implementation is feasible without sacrificing performance, enabling more reliable online play and more robust self-learning Xiangqi engines.

Abstract

Unlike repetitions in Western Chess where all repetitions are draws, repetitions in Chinese Chess could result in a win, draw, or loss depending on the kind of repetition being made by both players. One of the biggest hurdles facing Chinese Chess application development is a proper system for judging games correctly. This paper introduces a complete algorithm for ruling the WXF rules correctly in all 110 example cases found in the WXF manual. We introduce several novel optimizations for speeding up the repetition handling without compromising the program correctness. This algorithm is usable in engines, and we saw a total increase in playing strength by +10 point rating increase, or an increased 5% winrate when integrating this approach into our prototype engine.

Paper Structure

This paper contains 22 sections, 8 figures, 10 algorithms.

Figures (8)

  • Figure 1: The red rook is perpetually checking the black king R2+1, K6+1, R2-1, K6-1, R2+1, K6+1, R2-1...red loses if he continues to check the king.
  • Figure 2: The red rook is perpetually chasing the unprotected black cannon R2=1, C9=8, R1=2, C8=9 ...red loses if he continues to chase the cannon.
  • Figure 3: Both players perpetually check each other simultaneously R5+1, C5=6, R5=4, C6=5, R4=5, C5=6...this repetition leads to a draw
  • Figure 4: Both players make the repetition c8=3, R2=7, c3=8, R7=2... The black cannon repeatedly attempts to perpetually kill (attempting to checkmate) the red king. The red rook perpetually chases the black cannon. Red will lose by repetition if he continues repeating moves.
  • Figure 5: Diagram 40 from WXF manual: The red cannon attacks the black chariot and protects the red knight. The black chariot is not considered attacking the red knight, and moving the black advisor to make the red knight undefended is not considered a chase.
  • ...and 3 more figures