Home

LaMoSca v0.04

Analysis on more than one level

Objective

In this version of the program we start completing the check on the legality of the generated moves, by verifying that the king is not left in check. For this check, besides the moves for the current position, the moves for the next position are generated as well, so that we can verify that the king is not among the destination squares of the opponent's moves.

For the development of the program as a whole, this two-level analysis is the basis for searching for the best moves through several levels of moves and replies.

The code

StackIn this version the stack holds two levels of moves: the list of moves for the side to play and, for each of them, the list of the opponent's possible replies. The start address of the stack and the bounds of each of the two lists are stored in pointers.

While the first list stays the same until the side to move changes, the second list is generated again from scratch whenever the current move changes.

To complete the support for the commands that WinBoard sends to the engine, a syntax check is also added on the opponent's side for special moves such as castling and promotions, moves that the program itself does not generate yet.

Running the program

Running the program with logging enabled, you can see that the usual sequence of moves is generated for the opening:

Livello 1: b8a6 b8c6 g8f6 g8h6 a7a6 a7a5 b7b6 b7b5 c7c6 c7c5 d7d6 d7d5 e7e6 e7e5 f7f6 f7f5 g7g6 g7g5 h7h6 h7h5

If the move "b8c6" is chosen (at random) for the program, the sequence of possible replies is generated:

Livello 2: e4e5 a2a3 a2a4 b2b3 b2b4 c2c3 c2c4 d2d3 d2d4 f2f3 f2f4 g2g3 g2g4 h2h3 h2h4 b1a3 b1c3 d1e2 d1f3 d1g4 d1h5 e1e2 f1e2 f1d3 f1c4 f1b5 f1a6 g1f3 g1h3 g1e2

("Livello" is Italian for "level".) Since the king is not on any destination square, the level 1 move is valid.

Download

LaMoSca04.zip (6.39 k)

To be completed

  • generation of castling, promotions and en passant captures;
  • detection of drawn positions;
  • analysis of the opponent's replies.

To do

  • evaluation of positions.

Links


Back Index Next