Computer Chess Club Archives


Search

Terms

Messages

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

Author: leonid

Date: 17:02:17 02/09/00

Go up one level in this thread


On February 09, 2000 at 19:09:39, Heiner Marxen wrote:

>On February 09, 2000 at 18:17:59, leonid wrote:
>
>>On February 09, 2000 at 16:19:32, Heiner Marxen wrote:
>>
>
>[snip]
>>>>Maybe here you use the bitboard where they could be very helpful. For me three
>>>>kings moves will ask as much time as generation of all the moves (not for king)
>>>>and verification of their legality. I make my count in approximate way. One
>>>>kings move take almost the same time (and logic resemble very much) as
>>>>recollection of the data for legality of all not king moves. Second cheking for
>>>>legality of the kings move will take as much time as the logic need to recognize
>>>>what move will check the opposit king. And the last kings move will take as much
>>>>time as generation of all the not king moves that must be check later for
>>>>legality.
>>>
>>>
>>>Here, my approach (Chest) is quite different.  I do not use bit boards,
>>>but Chest has always actual attack information within each square.
>>>The attacks are a set of pieces (at most 32), not a set of squares (64).
>>
>>
>>Feel me lost.
>
>I will try to explain.
>As all no-bit-borders, I have 8x8 squares as part of the board, each indicating
>whether that square is empty, or what piece sits there.

What is exactly "no-bit-borders"? I ask this not only because this passage is
not clear to me but because it make me think about some board indication that
one programmer explained me. After his way (he said that many do the same) chess
board is indicated not by simple 64 bytes array (like I do) but by some still by
some additional data that say you that you are "out of picture".

In my logic one byte in chessboard array says all things that I need: color,
busy-empty, piece.

>(actually, it is not 8x8, but 16x24 for me)
>Like many others, I also have an additional array listing the pieces
>on the board in a more compact manner: each entry indicates, on which square
>that piece is.
>
>Now I have two ways to code a set of pieces:
>- via the set of square indexes: this is a bit board, 64 bit wide.
>- via a set of piece array indexes.  Each side can have at most 16 pieces,
>  together 32.  I.e. a 32 bit wide word can code such a set.

100% different way for me.

>Attacks can't originate from empty squares, so a set of pieces can
>accurately code a set of attacks.  So I use the latter method,
>and get away with 32-bit words.
>
>>>To always have them, execution of a move must update this attack info,
>>>what make it an expensive operation, but for me it pays off:
>>
>>In my logic when the moves are generated all the information is found on the
>>spot. This make the move generator logic (I have two logics in my chess game)
>>independent and help somehow in preventing the propagation of possible bugs
>>during the game.


All above sound to me like new and different.


>>>- whether a king may legally step to some target square is a simple test:
>>>  the attacks to that square must not contain any opposing piece.
>>>  No search for the bad guys: they already spread their effect into all
>>>  possible targets.  (Exact details are a bit more complex)
>>>- Whether or not there is a pin, can also be very cheap with attack information.
>>>  First, of course, there must be a geometric relation between the pinned
>>>  piece and its king.  That can be done by simple test on the square indexes,
>>>  or a table lookup.  When there is such a relationship, there must also
>>>  be an opponents attack in the square of the pinned piece.  And that attack
>>>  must be from a B, R or Q.
>>
>>
>>In my logic (I am afraid that I understand partially your explanation) checking
>>the legality of the kings move is very simple. Just look in all direction and
>>find if the king is not under the fire. When logic look to recollect the data
>>about the legality of future non kings moves it goes the same way. Only this
>>time it look not only if the king is under the direct fire but find also where
>>king is protected by friendly pieces.


>Sure, it is simple.  But you have to search the board to find out.
>I have shifted this work into the make_move function, and when I think
>about the legality of a king move, the collected data is already there.

But probably this collected data you find (before finding the moves that are not
kings moves) before generating the moves for given position. If it is so, we do
the same.


>>1) If king is under more that one fire. No use to look for the moves of not king
>>itself. Go directly to look for the kings move.
>>
>>2) King under the one fire. Use the data during the generation of the moves of
>>not king in order of entering into certain square. When the friendly piece will
>>enter there king will be under protection, or its personal offender will die
>>instantly.
>>
>>3) If king is not under direct fire and there are no "human shield", you are
>>free to generate not verified non kings moves.
>>
>>This how it is done in my logic.
>
>Sure, that is the basic way to do it.  Nothing wrong with it.
>Effectively I do the exact same logic.
>I just like to prepare those searches over the board, which just collect
>attack information.


Yes, and you recollect all those information from scrach before each call to the
move generator. If it is so, we are more that close. Otherwise (and this
happened often), resemblance is only superficial.

And man, when you sleep? At this time in your country it is early morning.
Difference should be around 6 o'clock.

Leonid.


>Heiner



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.