ChessUSA.com TalkChess.com
Hosted by Your Move Chess & Games
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Project help required: Bitboard Fruit 2.1
Post new topic    TalkChess.com Forum Index -> Computer Chess Club: Programming and Technical Discussions Flat
View previous topic :: View next topic  
Author Message
Sven Schüle



Joined: 15 May 2008
Posts: 2276
Location: Berlin, Germany

PostPost subject: Re: Project help required: Bitboard Fruit 2.1    Posted: Sat May 12, 2012 5:21 pm Reply to topic Reply with quote

ZirconiumX wrote:
My main problem is that I don't have much of a choice in the matter...

I can either:

  • Update the bitboards at the same time as the mailbox array is updated - which is what I am doing at the moment.
  • Poll the board twice - which is slower than what I want considering most go commands follow a position command.
  • Something else - which is awkward because the A8-H1 mapping (LSR(?)) is how FEN works...


I have been attempting to use LSF mapping (a1=0, h8=63), but as stated, FEN seems to use LSR (which I think means I XOR by 56 (?))

Matthew:out

Think straight forward. The original board_from_fen() function is built as follows, reduced to what is relevant here:
Code:
void board_from_fen(board_t * board, const char fen[]) {
   board_clear(board);
   // some initialization ...
   for (rank = Rank8; rank >= Rank1; rank--) {
      for (file = FileA; file <= FileH;) {
         if (found digit N) {
            for (i = 0; i < N; i++) {
               set SQUARE_MAKE(file, rank) to EMPTY;
               file++;
            }
         } else {
            add a piece on SQUARE_MAKE(file, rank);
            file++;
         }
      }
   }
}

I would do exactly the same also with bitboards. Start by fixing the board_clear() implementation, this must leave the board in an empty state. All piece bitboards, colour bitboards, and your "occupied" bitboard must be zero, and your "empty" bitboard must have all bits set to 1. I think this is not the case with your current version - I downloaded yesterday last time. I even think there is a bug in the code initializing your bitboards in board_clear(), it looks like out-of-bound access.

Now, how to update the bitboards in board_from_fen(): you already have the square given by SQUARE_MAKE(file, rank), so I would simply take SQUARE_TO_64 of it as your bit position and perform the proper operation: when adding a piece, set the related bit in the piece bitboard, colour bitboard, and "occupied" bitboard, but clear the bit in the "empty" bitboard. When setting a square to EMPTY, clear the bit everywhere but set the bit in the "empty" bitboard. You HAVE to do it that way, since you use your bitboards like that everywhere else in your program (look at move_do.cpp for instance).

At the moment I mentioned move_do.cpp I realized that you also have to fix your bitboard update code there. You are using the 0..255 square in the "1ULL << square" expressions but you have to use "1ULL << SQUARE_TO_64(square)" instead. The result currently is that none of the moves has any effect on the board since all 0..255 square values are >= 64 (A1=68) so that shifting results in a "0".

Sven
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
Subject Author Date/Time
Project help required: Bitboard Fruit 2.1 Matthew R. Brades Tue May 08, 2012 3:20 pm
      Re: Project help required: Bitboard Fruit 2.1 Robert Hyatt Tue May 08, 2012 3:31 pm
            Re: Project help required: Bitboard Fruit 2.1 Matthew R. Brades Tue May 08, 2012 5:06 pm
                  Re: Project help required: Bitboard Fruit 2.1 Ronald de Man Tue May 08, 2012 6:43 pm
                  Re: Project help required: Bitboard Fruit 2.1 Evert Glebbeek Tue May 08, 2012 8:34 pm
                        Re: Project help required: Bitboard Fruit 2.1 H.G.Muller Tue May 08, 2012 8:41 pm
                  Re: Project help required: Bitboard Fruit 2.1 Sven Schüle Tue May 08, 2012 8:43 pm
                        Re: Project help required: Bitboard Fruit 2.1 Sven Schüle Tue May 08, 2012 10:09 pm
                              Re: Project help required: Bitboard Fruit 2.1 Ronald de Man Tue May 08, 2012 10:15 pm
                                    Re: Project help required: Bitboard Fruit 2.1 Sven Schüle Tue May 08, 2012 10:21 pm
                                          Re: Project help required: Bitboard Fruit 2.1 Ronald de Man Tue May 08, 2012 10:59 pm
                                                Re: Project help required: Bitboard Fruit 2.1 Sven Schüle Wed May 09, 2012 11:33 am
                                                      Re: Project help required: Bitboard Fruit 2.1 Robert Hyatt Sun May 13, 2012 5:11 pm
                                                            Re: Project help required: Bitboard Fruit 2.1 Sven Schüle Sun May 13, 2012 10:13 pm
                                                                  Re: Project help required: Bitboard Fruit 2.1 Robert Hyatt Mon May 14, 2012 2:17 am
                                                                        Re: Project help required: Bitboard Fruit 2.1 Sven Schüle Mon May 14, 2012 10:19 am
                                                                              Re: Project help required: Bitboard Fruit 2.1 H.G.Muller Mon May 14, 2012 10:53 am
                                                                                    Re: Project help required: Bitboard Fruit 2.1 Mincho Georgiev Mon May 14, 2012 12:19 pm
                                                                                    Re: Project help required: Bitboard Fruit 2.1 Sven Schüle Mon May 14, 2012 12:28 pm
                                                                                          Re: Project help required: Bitboard Fruit 2.1 H.G.Muller Mon May 14, 2012 3:10 pm
                                                                                          Re: Project help required: Bitboard Fruit 2.1 Sven Schüle Mon May 14, 2012 4:25 pm
                                                                                          Re: Project help required: Bitboard Fruit 2.1 H.G.Muller Mon May 14, 2012 4:34 pm
                                                                                          Re: Project help required: Bitboard Fruit 2.1 Sven Schüle Mon May 14, 2012 4:46 pm
                                                                                          Re: Project help required: Bitboard Fruit 2.1 H.G.Muller Mon May 14, 2012 5:05 pm
                                                                                          Re: Project help required: Bitboard Fruit 2.1 Sven Schüle Mon May 14, 2012 8:51 pm
                                                                                    Re: Project help required: Bitboard Fruit 2.1 Robert Hyatt Mon May 14, 2012 10:43 pm
                                                                                          Re: Project help required: Bitboard Fruit 2.1 H.G.Muller Tue May 15, 2012 5:41 am
                                                                                          Re: Project help required: Bitboard Fruit 2.1 Matthew R. Brades Tue May 15, 2012 2:45 pm
                                                                                          Re: Project help required: Bitboard Fruit 2.1 Matthew R. Brades Tue May 15, 2012 4:04 pm
                                                                                          Re: Project help required: Bitboard Fruit 2.1 Evert Glebbeek Tue May 15, 2012 4:41 pm
                                                                              Re: Project help required: Bitboard Fruit 2.1 Robert Hyatt Mon May 14, 2012 10:41 pm
                                                                  Re: Project help required: Bitboard Fruit 2.1 Mincho Georgiev Mon May 14, 2012 6:22 am
                                                Re: Project help required: Bitboard Fruit 2.1 Robert Hyatt Sun May 13, 2012 5:09 pm
                        Re: Project help required: Bitboard Fruit 2.1 Ronald de Man Tue May 08, 2012 10:11 pm
                              Re: Project help required: Bitboard Fruit 2.1 Sven Schüle Tue May 08, 2012 10:18 pm
                  Re: Project help required: Bitboard Fruit 2.1 Robert Hyatt Sun May 13, 2012 5:14 pm
                        Re: Project help required: Bitboard Fruit 2.1 H.G.Muller Sun May 13, 2012 6:35 pm
                        Re: Project help required: Bitboard Fruit 2.1 Matthew R. Brades Sun May 13, 2012 8:24 pm
                              Re: Project help required: Bitboard Fruit 2.1 Sven Schüle Sun May 13, 2012 10:22 pm
                              Re: Project help required: Bitboard Fruit 2.1 H.G.Muller Mon May 14, 2012 6:56 am
                        Re: Project help required: Bitboard Fruit 2.1 Sven Schüle Sun May 13, 2012 10:18 pm
      Re: Project help required: Bitboard Fruit 2.1 H.G.Muller Tue May 08, 2012 4:12 pm
      Re: Project help required: Bitboard Fruit 2.1 Lucas Braesch Wed May 09, 2012 5:01 am
      Re: Project help required: Bitboard Fruit 2.1 Lucas Braesch Wed May 09, 2012 5:13 am
            Re: Project help required: Bitboard Fruit 2.1 Sven Schüle Wed May 09, 2012 11:35 am
                  Re: Project help required: Bitboard Fruit 2.1 Matthew R. Brades Wed May 09, 2012 2:50 pm
                        Re: Project help required: Bitboard Fruit 2.1 Matthew R. Brades Wed May 09, 2012 2:57 pm
                              Re: Project help required: Bitboard Fruit 2.1 Sven Schüle Wed May 09, 2012 3:27 pm
                                    Re: Project help required: Bitboard Fruit 2.1 Matthew R. Brades Thu May 10, 2012 1:32 pm
                                          Re: Project help required: Bitboard Fruit 2.1 H.G.Muller Thu May 10, 2012 2:47 pm
                                                Re: Project help required: Bitboard Fruit 2.1 Matthew R. Brades Thu May 10, 2012 3:11 pm
                                                      Re: Project help required: Bitboard Fruit 2.1 Matthew R. Brades Thu May 10, 2012 3:14 pm
                                                            Re: Project help required: Bitboard Fruit 2.1 Sven Schüle Thu May 10, 2012 11:06 pm
                                                                  Re: Project help required: Bitboard Fruit 2.1 Matthew R. Brades Fri May 11, 2012 10:14 am
                                                                        Re: Project help required: Bitboard Fruit 2.1 H.G.Muller Fri May 11, 2012 10:28 am
                                                                        Re: Project help required: Bitboard Fruit 2.1 Lucas Braesch Fri May 11, 2012 11:26 am
                                                                        Re: Project help required: Bitboard Fruit 2.1 Sven Schüle Sat May 12, 2012 2:06 pm
                                                                              Re: Project help required: Bitboard Fruit 2.1 Matthew R. Brades Sat May 12, 2012 3:54 pm
                                                                                    Re: Project help required: Bitboard Fruit 2.1 Evert Glebbeek Sat May 12, 2012 4:20 pm
                                                                                          Re: Project help required: Bitboard Fruit 2.1 Matthew R. Brades Sat May 12, 2012 5:00 pm
                                                                                          Re: Project help required: Bitboard Fruit 2.1 Matthew R. Brades Sat May 12, 2012 5:15 pm
                                                                                          Re: Project help required: Bitboard Fruit 2.1 Sven Schüle Sat May 12, 2012 5:32 pm
                                                                                          Re: Project help required: Bitboard Fruit 2.1 Sven Schüle Sat May 12, 2012 8:54 pm
                                                                                    Re: Project help required: Bitboard Fruit 2.1 Sven Schüle Sat May 12, 2012 5:21 pm
                                                      Re: Project help required: Bitboard Fruit 2.1 H.G.Muller Thu May 10, 2012 3:25 pm
                                          Re: Project help required: Bitboard Fruit 2.1 Matthew R. Brades Thu May 10, 2012 3:06 pm
                                                Re: Project help required: Bitboard Fruit 2.1 Ronald de Man Thu May 10, 2012 6:42 pm
                        Re: Project help required: Bitboard Fruit 2.1 Lucas Braesch Thu May 10, 2012 10:51 am
Post new topic    TalkChess.com Forum Index -> Computer Chess Club: Programming and Technical Discussions

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum




Powered by phpBB © 2001, 2005 phpBB Group
Enhanced with Moby Threads