Writing a chess program in xx steps

Discussion of chess software programming and technical issues.

Moderators: hgm, Rebel, chrisw

sluijten
Posts: 44
Joined: Wed Apr 13, 2011 12:43 pm

Writing a chess program in xx steps

Post by sluijten »

I started a website on writing a bitboard engine, step-by-step.
Think of a bitboard version of TCSP ;-), with Winboard support.
Having a busy full-time dayjob, and more hobbies, this is going to be a long-term project (months, maybe years).
http://www.sluijten.com/winglet/
Jorge Garcia
Posts: 61
Joined: Thu Oct 22, 2009 1:50 am
Location: Barcelona Spain

Re: Writing a chess program in xx steps

Post by Jorge Garcia »

ok, good news. Very interesting idea.
I am going to follow your blog.
Bye
--------------------------------------------------
Jorge García de Andrés
http://dynchess.blogspot.com.es
http://www.bitacoradelasalud.blogspot.com.es
http://www.mytechit.blogspot.com.es
Mark
Posts: 216
Joined: Thu Mar 09, 2006 9:54 pm

Re: Writing a chess program in xx steps

Post by Mark »

sluijten wrote:I started a website on writing a bitboard engine, step-by-step.
Think of a bitboard version of TCSP ;-), with Winboard support.
Having a busy full-time dayjob, and more hobbies, this is going to be a long-term project (months, maybe years).
http://www.sluijten.com/winglet/
Thanks, looking forward to following this!
elcabesa
Posts: 855
Joined: Sun May 23, 2010 1:32 pm

Re: Writing a chess program in xx steps

Post by elcabesa »

i'm just reading it and finding some good idea :)
sluijten
Posts: 44
Joined: Wed Apr 13, 2011 12:43 pm

Re: Writing a chess program in xx steps

Post by sluijten »

winglet has a board, can display it on the console window, you can set up a position manually,
or read a FEN string from a file.
Some real chess stuff is about to start: move generation.
ericlangedijk

Re: Writing a chess program in xx steps

Post by ericlangedijk »

Nice! It will probably guide me through the magics...
Thank you for publishing this.
ericlangedijk

Re: Writing a chess program in xx steps

Post by ericlangedijk »

I think the comment:
// conversion from 64 board squares to the 8 corresponding positions in the GEN_SLIDING_ATTACKS array: MIN((8-RANKS[square]),(FILES[square]-1))

is copied from the algorithm above with the other diagonals.

MIN((8-RANKS[square]),(FILES[square]-1))
must be (i think)
MIN((RANKS[square]),(FILES[square]-1))

I think i'll try to write a more "human readable" version of this calculation :)

My reading of C is not so good I can understand this line of code:...

Code: Select all

if &#40;GEN_SLIDING_ATTACKS&#91;&#40;RANKS&#91;square&#93;-1&#41; < &#40;FILES&#91;square&#93;-1&#41; ? &#40;RANKS&#91;square&#93;-1&#41; &#58; &#40;FILES&#91;square&#93;-1&#41;&#93;&#91;state6Bit&#93; & CHARBITSET&#91;attackbit&#93;)
What does it mean? I had to read the comment to understand it.

Code: Select all

       //  DIAGA1H8_ATTACKS attacks &#40;BISHOPS and QUEENS&#41;&#58;
       for &#40;square = 0; square < 64; square++)
       &#123;
              for &#40;state6Bit = 0; state6Bit < 64; state6Bit++)
              &#123;
                     DIAGA1H8_ATTACKS&#91;square&#93;&#91;state6Bit&#93; = 0x0;
                     for &#40;attackbit = 0; attackbit < 8; attackbit++) // from LSB to MSB
                     &#123;
                           //  conversion from 64 board squares to the 8 corresponding positions in the GEN_SLIDING_ATTACKS array&#58; MIN&#40;&#40;8-RANKS&#91;square&#93;),&#40;FILES&#91;square&#93;-1&#41;)
                           if &#40;GEN_SLIDING_ATTACKS&#91;&#40;RANKS&#91;square&#93;-1&#41; < &#40;FILES&#91;square&#93;-1&#41; ? &#40;RANKS&#91;square&#93;-1&#41; &#58; &#40;FILES&#91;square&#93;-1&#41;&#93;&#91;state6Bit&#93; & CHARBITSET&#91;attackbit&#93;)
                           &#123;
                                  // the bit is set, so we need to update FILE_ATTACKS accordingly&#58;
                                  // conversion of square/attackbit to the corresponding 64 board file and rank&#58;
                                  diaga1h8 = FILES&#91;square&#93; - RANKS&#91;square&#93;; // from -7 to 7, longest diagonal = 0
                                  if &#40;diaga1h8 < 0&#41;
                                  &#123;
                                    file = attackbit + 1;
                                    rank = file - diaga1h8;
                                  &#125;
                                  else
                                  &#123;
                                    rank = attackbit + 1;
                                    file = diaga1h8 + rank;
                                  &#125;
                                  if (&#40;file > 0&#41; && &#40;file < 9&#41; && &#40;rank > 0&#41; && &#40;rank < 9&#41;)
                                  &#123;
                                         DIAGA1H8_ATTACKS&#91;square&#93;&#91;state6Bit&#93; |=  BITSET&#91;BOARDINDEX&#91;file&#93;&#91;rank&#93;&#93;;
                                  &#125;
                           &#125;
                     &#125;
              &#125;
       &#125;
sluijten
Posts: 44
Joined: Wed Apr 13, 2011 12:43 pm

Re: Writing a chess program in xx steps

Post by sluijten »

Current functionality of winglet is:
read a FEN string from a file & setting up the board manually
bitboard move generator
evaluation function
alpha-beta pvs search
mate, draw and repetition detection (using hash keys)
iterative deepening and move ordering

Next on the list will be:
quiescence and SEE
Null move pruning
Time control and running test suites
Connecting to Winboard
User avatar
lucasart
Posts: 3232
Joined: Mon May 31, 2010 1:29 pm
Full name: lucasart

Re: Writing a chess program in xx steps

Post by lucasart »

sluijten wrote:Current functionality of winglet is:
read a FEN string from a file & setting up the board manually
bitboard move generator
evaluation function
alpha-beta pvs search
mate, draw and repetition detection (using hash keys)
iterative deepening and move ordering

Next on the list will be:
quiescence and SEE
Null move pruning
Time control and running test suites
Connecting to Winboard
Don't forget to put lots of assert, and to check that your perft values are correct. This part can be a real nightmare, but you cannot skip it :(
Good luck!