ChesSkelet /tseske'let/

ChesSkelet development

General aspects

The first and most obvious question is: why Z80 and ZX Spectrum? Well, if you analize it, it is a clear mistake, but take into account that I was not planning to write any chess game. For a rough comparison Z80 instruction set is around 1268 instructions, while x86 processor would have around 3683 instructions available. If you look at the registers, using 16, 32 or 64 bye registers becomes an immediate advantage. In the best case, you could have the whole board stored in a 64-byte register. x86 family is much more flexible on both aspects. The amount of addressable memory is noy key in this case. Therefore, it would seem more appropriate to choose a more modern processor, like Olivier Poudade or Oscar Toledo did for their chess implementations. Later, looking at it more positively, I thought that going for the ZX Spectrum would be a nice tribute to ZX81 1K Chess.

The heart fothe program: although the code does not do any recursive tree search, it has a piece of code that implements what I call 1.5 ply depth. 1st ply covers all computer moves, and 2nd ply would mean that all potential responses from the human side can be analized too. 1st ply is covered by the code, and in parallel, the program generates a bitboard with all squares attacked by the opponent (it does not know which opponent's piece is attacking the potential destination square, though). Therefore, it's able to take all those attacked squares into consideration. As I see it, it sits somewhere between 1 and 2 ply search, so that's why I call it 1.5 plies depth.

If you ask me, the most difficult part to write in such short space is the candidate move list generation (genlis in my code). The algorithm is very tricky and it's very difficult to cover all possibilities. I still have a small issue with attacked squares and pawn moves, as you can see in the code.

How it works

At program start, the screen is set to be used. And then, the program is basically a simple loop, where many sections are shared for both human and computer moves.

  • Common part: common code for both sides after producing a move from any side,
  • Programming approach

    Disclaimer: this section requires some assembly skills for detailed explanations. However, the concepts are mostly explained using non-programming terms.

    There are some Z80 features not needed for my chess implementation, like interrupts or In/Out port usage, so there is not much I can bring in on that area. However, I have several interesting findings:

    Basic stuff I missed in Z80 assembler