Previous   Next   Download

HaQiKi D is (optionally) included in the WinBoard install obtainable from WinBoard forum.

It is also included in the WinBoard for Xiangqi package .

HaQiKi D

A native WinBoard Xiangqi engine

HaQiKi D is my atempt at building a strong Xiangqi engine. I started to create it from scratch in March 2009, so its capabilities are still limited. The name doesn't really mean anything; it was chosen for its pronounciaton (which, with mixed Dutch and Chinese pronounciation rules is 'Hah-tsee-kee-day'), and to make name collission unlikely.

HaQiKi D is based on a search using all standard techniques.

14x20 Mailbox board & Piece List
Alpha-Beta Search
Iterative Deepening
Null-Move Pruning
Check Extension
Hash Table with Depth-Preferred and Always-Replace Slot
Killer Heuristic
MVV/LVA move sorting of captures
Pruning of Bad Captures in Quiescence Search
Non-Captures Sorted by History Heuristic
Late-Move Reductions
Piece-Square Tables
Non-Linear King-Safety Evaluation

Evaluation

Evaluation was more of a problem. As I don't play Xiangqi myself, I had little feel for what the game was about, and what should be considered good squares for the various pieces. Observing engine-engine games, in particular how HaQiKi D was slaughtered by the stronger half of the UCCI engines, did suggest to me that Xiangqi is all about King Safety. In addition, there were some important strategic patterns that even a un-initiated novice like me could recognize as immediately losing, such as a Cannon directly facing a King boxed in by its Advisors, and Cannons pinned by Rooks on other (unprotectable) Rooks along b- and h-file. Blocking the forward moves of its own Horses also seemed a common mistake.

Even piece values is not a subject about which there is consensus in Xiangqi. Most engines seem to use H = C = 1/2 R, although it seems obvious from theortical considerations that a Cannon should go down in value compared to the Horse if the board gets more empty. (The Horse is blocked by other pieces, but the Cannon depends on them for making captures.) Initial self-play test starting from positions with a material imbalance suggest that a Cannon in the opening is significantly more valuable than a Horse, while a Rook is far stronger than even two Cannons, even approaching the value of 3 Horses. The relative value of Horse and Cannon should invert somewhere during the game, as in the end-game a Horse seems about equivalent to the combination of a Cannon and an Advisor (based on the strength of the fortress that they can break down with various combinations of attacking material). So HaQiKi D uses a value of the Cannon that decreases as the board gets more empty, implemented by a material table.

The material table also implements a very important other aspect, unique to Xiangqi, namely the existense of purely defensive pieces, which cannot cross into the other half of the board, and thus can never be used to attack the enemy King. such pieces derive their value only from the fact that there are enemy attackers to defend against, and their totalled value can never exceed that of the opponent's attack force. This means they have to be scaled down in value when the opponent hardly has any attack force left. This is implemented by not putting a value on the defensive pieces itself, but applying a reduction to the value of one side's offensive material based on the type and number of the opponent's defending pieces.

King Safety

HaQiKi D uses multiplicative piece-square tables for evaluating King Safety: the danger a piece of a given type repesents for one side's fortress is tabulated as a function of is location, increasing as it gets closer to the fortress. Similarly, defensive pieces neutralize part of this danger, by contributing a negative tabulated value when they are close to their own side's fortress. But the net danger is then used as argument of a highly non-linear function to obtain an evaluation score, so that adding an attacker or defender to a fortress that is near the point of collapsing results in a much higher score than doing the same for a fortress that is quite well defended. Due to this, pieces are drawn towards the fortress that is in most peril, preventing misallocation of material in futile attack when they were badly needed in defense.

Previous   Next