Computer Chess Club Archives


Search

Terms

Messages

Subject: Re: Does anybody know the algorithm for generation of all possible moves ?

Author: leonid

Date: 18:28:16 02/07/00

Go up one level in this thread


On February 06, 2000 at 12:17:50, James Robertson wrote:

>On February 06, 2000 at 08:08:36, Marek Mahdal wrote:
>
>>I need a algorithm, that generates all possible moves in a position. Is there
>>anybody, who can help me ???
>
>As far as I know everybody uses something similar:
>
>a) scan the entire board finding pieces
>b) once you find a pice, generate moves for it and add them to the move list.
>c) take care of extras (castling, ep, etc)
>
>I don't know if I would call this an algorigthm, since everybody does it so
>differently, but this is basically how moves are generated.
>
>James

I am not sure that my explantion will be that useful but will do it anyway.

I find the moves this way:

1) Scanning the board for all the pieces for given color. List of pieces goes in
special chain. Positions of both kings goes in two special variables.

2) After the positions of both kings all important data about legality for moves
of "our color" and possibility to check the "enemy king" is saved.

3) Piece after piece is taken from the "chain of pieces" and all the legal moves
are found for it. Legality of the moves are found after the data about "our
king". Moves that will put to the check of "enemy king" (this is found after the
previous data already found about the "enemy king") goes in special chain for
legal moves. All legal moves that will not check the "enemy king" goes into
special chain.

4) All legal moves at the end goes in  one single chain. Moves that will check
the "enemy king" goes first.

Only later, already in each ply logic, generated legal moves will be aligned in
the most efficent way, after special data about this special ply.

Leonid.



This page took 0 seconds to execute

Last modified: Thu, 15 Apr 21 08:11:13 -0700

Current Computer Chess Club Forums at Talkchess. This site by Sean Mintz.