Author: Axel Grüttner
Date: 08:19:45 02/20/03
Go up one level in this thread
On February 20, 2003 at 08:45:06, Filip Tvrzsky wrote:
>On February 20, 2003 at 08:10:47, Axel Grüttner wrote:
>
>>I´m programming my first Move Generator using a 10x12 Board.
>>
>>1)The main structure is somthing like this:
>>
>>for(i=A1;i<=H8; i++){
>> switch(BOARD[i]){
>> case KNIGHT: ...(make moves)
>> case PAWN : ...
>> ...}
>>}
>>is this construct ok? or are there any better models which are simply to
>>implement?
>>
>
>Major improvement here is to use the list of pieces containing their placing on
>the board. Than you don't have to search whole board (64 arrays) but only this
>list (16 pieces at most).
You mean an array[16] for each color with the positions of the pieces?
something like: pos_white[16]={A1, B1, ..., A2, B2, ..., H2} for the starting
position?
Isn´t it possible/faster to use instead of an array two global 64-Bit-Bitboards
to mark the pieces of each color?
>
>>2)First I used for KNIGHT moves a offset-array Koffset={-21,-19,..., 21}
>> and implemented it :
>>case KNIGHT: {
>> for(j=0; j<8; j++){
>> if(BOARD[i+Koffset[j]]==EMPTY)
>> _make move_
>>}
>>
>>But testing with 8 seperate IF´s
>> case KNIGHT: {
>> if(BOARD[i-21]==EMPTY){_make move_}
>> if(BOARD[i-12]==EMPTY){_make move_}
>> ...
>> if(BOARD[i+21]==EMPTY){_make move_} }
>>and without such an Offset-array was much faster. is this because of the LOOP,
>>or because of everlasting dereferencing the offset
>>
>
>You need to have the lookup table Knight_moves[square][12] containing directly
>the list of all possible moves for each square. The last element of all lists is
>some arbitrary value which is different from all your legal square indexes,
>let's name it END. Your code is going to be like this:
> for (unsigned char* pTo = &Knight_moves[From].To[0]; *pTo != END; pTo++)
> { make_move(From, *pTo); }
>Mote that pTo is a pointer!
Why the "12" (km[square][12]) in you lookup table? the maximum moves a knight
can made is eight. i think i didn´t understand the functionality of this
construct. can you describe it a bit more precisly?
axel
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.