Writing a chess program in xx steps

Discussion of chess software programming and technical issues.

Moderators: hgm, Harvey Williamson, bob

Forum rules
This textbox is used to restore diagrams posted with the [d] tag before the upgrade.
Post Reply
sluijten
Posts: 44
Joined: Wed Apr 13, 2011 10:43 am
Contact:

Writing a chess program in xx steps

Post by sluijten » Mon Apr 18, 2011 2:07 pm

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: 59
Joined: Wed Oct 21, 2009 11:50 pm
Location: Barcelona Spain

Re: Writing a chess program in xx steps

Post by Jorge Garcia » Mon Apr 18, 2011 5:06 pm

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: 215
Joined: Thu Mar 09, 2006 8:54 pm

Re: Writing a chess program in xx steps

Post by Mark » Tue Apr 19, 2011 2:15 pm

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: 677
Joined: Sun May 23, 2010 11:32 am
Contact:

Re: Writing a chess program in xx steps

Post by elcabesa » Fri Apr 22, 2011 8:33 am

i'm just reading it and finding some good idea :)

sluijten
Posts: 44
Joined: Wed Apr 13, 2011 10:43 am
Contact:

Re: Writing a chess program in xx steps

Post by sluijten » Sun Apr 24, 2011 2:52 pm

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 » Fri May 27, 2011 5:42 pm

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 » Thu Jun 02, 2011 9:50 pm

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 10:43 am
Contact:

Re: Writing a chess program in xx steps

Post by sluijten » Thu Jun 23, 2011 2:22 pm

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: 2957
Joined: Mon May 31, 2010 11:29 am
Contact:

Re: Writing a chess program in xx steps

Post by lucasart » Mon Jul 04, 2011 10:43 pm

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!

Post Reply