Computer Chess Club Archives


Search

Terms

Messages

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

Author: KarinsDad

Date: 09:36:33 02/08/00

Go up one level in this thread


On February 08, 2000 at 07:11:10, leonid wrote:

[snip]
>
>All your way to put the logic going is so different that I must one day look
>into it. In this moment I am not in programming. In my logic I do not
>differenciate the capture against "empty moves". This is done only after the
>generation of all the moves for given position. Exception is only one ply where
>I have special move generator that find only "capture".


Yes, I do not differentiate either.


>
>Probably you use some efficent way where you can generate one move at once and
>immidiately try it.


No, I do not do this yet. But it sounds like a good idea. I actually do
something worse than most everyone else. Instead of generating all moves and
then checking for illegality at the point in time that the move is checked (and
hence, if you get a cutoff, you have not checked for illegality on a bunch of
moves that were not even used), I prevent the creation of illegal moves in move
generation.

I do this in a sophisticated manner. I back away from the king in all directions
(using the bitboards) until I come to the next piece. If it of the same color, I
then continue on the same row, column, or diagonal until I come to the next
piece. If it is of a different color and is a rook or queen (for rows and
columns) or a bishop or queen (for diagonals), I then eliminate certain types of
moves for the piece that was pinned. For example, a pinned bishop on a diagonal
can still move towards and away from the king, but not into the other
directions.

I do this before generating any moves, hence, each piece has directions of moves
which are allowed. All directions are allowed for non-pinned pieces, but only
certain directions are allowed for pinned pieces.

Note: the problem with this approach is that you have to do special things for
EP moves. I wait until all moves are generated and then see if any were EP. If
so, then I go through special code to see if the EP taking pawn is pinned or the
combination of the EP taking and the EP taken pawns are pinned (i.e. you could
have a horizontal pin of both pawns where both pawns would be removed from the
row if the EP was allowed, but that would expose a king to check).

And what is worse than this, I sort the moves before returning them. Actually, I
sort them as each is generated and the sort is quick, but I'm sure this makes
some of the programmers shudder.


 I never could see how to do this beside one ply. I am forced
>to find all the moves for the ply in order to aline that later in best way
>possible. After all, general data needed to recognize the legality of each move
>is found in advance for entire ply. From where is the strange result - less
>efficent is my logic (forced to see more moves for each ply) better the nodes
>per second rate it provide.
>
>Leonid.

KarinsDad :)



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.