
#Autoplay in hiarcs chess explorer code
I wrote a function to verify the code generates correct legal moves in a variety of positions. But I don’t want to fall into the trap of premature optimization. I haven’t examined the code using a profiler, so perhaps the speed can be improved some.
#Autoplay in hiarcs chess explorer generator
This includes pseudo-legal move creation, move legality testing (does move expose own king to check), incremental update of Zobrist position keys, and check detection (does move check enemy king), which isn’t strictly required for a move generator but will be used by the search function to prevent reductions of moves that give check. MadChess 2.0 Beta generates moves at 3.6M per second, a 4x speedup. MadChess 1.x could generate moves at 850K per second. I’m satisfied with the speed of the move generator. Undoing a move is as simple as decrementing an index. Playing a move involves copying the Squares array (a fast memory operation), then updating Position data structures. I’m using a copy-make technique to play moves, instead of the make-unmake technique used by MadChess 1.x. Moves are encoded into an unsigned integer. Each Position has an integer array of Squares. I’m writing the code in C# with a mailbox board representation, similar to MadChess 1.x.

I ran a gauntlet tournament, pitting MadChess 2.0 Beta against weak chess engines. No tapered evaluation, no passed pawn bonus, no piece mobility, no king safety, no reductions or pruning of moves, etc. Evaluation is limited to material and middlegame piece square tables. I’ve implemented an alpha / beta negamax search with aspiration windows and a capture / check evasion quiescence search. MadChess 2.0 Beta can play a timed game of chess. I’ve reached an important milestone in the development of my new chess engine.
