New free tool : Bitboards Helper

Discussion of chess software programming and technical issues.

Moderators: hgm, Rebel, chrisw

User avatar
JuLieN
Posts: 2949
Joined: Mon May 05, 2008 12:16 pm
Location: Bordeaux (France)
Full name: Julien Marcel

New free tool : Bitboards Helper

Post by JuLieN »

I am currently in the process of rewriting Prédateur into a bitboards engine. I seized this opportunity to rewrite it in C++ as well.

I was very surprised to see that, contrary to Delphi and FreePascal, C++ has no representation of binary numbers, which doesn't help when you manipulate bitboards.

So I put together in twenty minutes a crude tool to help me in the process by letting me edit bitboards and convert them into hex and dec representations.

As it might be of use to other programmers, and as I don't remember I ever saw such a tool, I decided to put it in the public domain. Here it is.

Image

(The large window is due to the fact that I designed it on OSX, where the default police was bigger).
Bitboards Helper is a small and crude tool designed to help chess engines programmers with bitboards.

You can:
- edit each individual bit of the board
- edit a whole rank or column
- clear/set/invert the whole board

The corresponding value in binary, hexadecimal and decimal notations is updated in real time.

This tool is free of charge and may be freely distributed, providing you keep this readme file intact and in the archive.

Feel free to contact me for any suggestion of improvement at jul_marcel at hotmail dot com.

/Julien MARCEL

History:

2011-05-11 : First version
You can download it here: http://julien.marcel.free.fr/public/BbHelper.rar
"The only good bug is a dead bug." (Don Dailey)
[Blog: http://tinyurl.com/predateur ] [Facebook: http://tinyurl.com/fbpredateur ] [MacEngines: http://tinyurl.com/macengines ]
User avatar
Giorgio Medeot
Posts: 52
Joined: Fri Jan 29, 2010 2:01 pm
Location: Ivrea, Italy

Re: New free tool : Bitboards Helper

Post by Giorgio Medeot »

Thank you very much, Julien,
this will be very useful... when I started writing my own chess engine I too felt the need of such a tool, and I ended up with a quick hack on an excel sheet (yes, I'm a really lazy man ;) )

Cheers,
  • Giorgio
Edit: Oh, well, it seems I will have to beat my laziness, in the end, as I put the LSB on a8... :D
bob
Posts: 20943
Joined: Mon Feb 27, 2006 7:30 pm
Location: Birmingham, AL

Re: New free tool : Bitboards Helper

Post by bob »

Giorgio Medeot wrote:Thank you very much, Julien,
this will be very useful... when I started writing my own chess engine I too felt the need of such a tool, and I ended up with a quick hack on an excel sheet (yes, I'm a really lazy man ;) )

Cheers,
  • Giorgio
Edit: Oh, well, it seems I will have to beat my laziness, in the end, as I put the LSB on a8... :D
While that seems counter-intuitive, it is not a fatal flaw. Only critical thing is to use lsb = 0, msb = 63, which matches Intel BSF/BSR numbering. I used a1=0, h8=63, because it made sense a1=0, b1=1, etc. But it has a draw-back, that when you display a bitboard, it is reversed left-to-right. Because the rightmost bit doesn't align with the rightmost square. You get to do some "mental gymnastics" to visualize the board when you dump a hex value.

For understandability, a8=0, h1=63 is easier to visualize.
User avatar
Giorgio Medeot
Posts: 52
Joined: Fri Jan 29, 2010 2:01 pm
Location: Ivrea, Italy

Re: New free tool : Bitboards Helper

Post by Giorgio Medeot »

bob wrote:For understandability, a8=0, h1=63 is easier to visualize.
Yes, that is why I chose to do so: it was easier to visualize the bitboard, looking at the binary representation. The only thing that has to be taken care of, is to correctly translates the coordinates of the board, everything else is just mirrored and works the same way.
Then, it is true that I can not copy/paste code from anywhere, as most engines use a different convention, but that is not a problem for me. I chose to write everything my own way, right from the start, just for the fun of it! :)
User avatar
sje
Posts: 4675
Joined: Mon Mar 13, 2006 7:43 pm

Re: New free tool : Bitboards Helper

Post by sje »

That looks like a very useful tool, particularly for those getting started with bitboards.

Two ideas:

1) The buttons on the board display could use color instead of 0/1 digit labels. Say, dark gray for on/1 and light gray for off/0. OR maybe use both digit and color at the same time.

2) Have three bitboard displays and an operator button array. The user can set the entries in the first two bitboards, select an operator button (or/and/xor/comp-and/shift/etc.), and then see the result in the third bitboard.
User avatar
JuLieN
Posts: 2949
Joined: Mon May 05, 2008 12:16 pm
Location: Bordeaux (France)
Full name: Julien Marcel

Re: New free tool : Bitboards Helper

Post by JuLieN »

Thanks for your comments and suggestions, guys. I'll come back in the next few days with an improved tool.
"The only good bug is a dead bug." (Don Dailey)
[Blog: http://tinyurl.com/predateur ] [Facebook: http://tinyurl.com/fbpredateur ] [MacEngines: http://tinyurl.com/macengines ]
User avatar
sje
Posts: 4675
Joined: Mon Mar 13, 2006 7:43 pm

Re: New free tool : Bitboards Helper

Post by sje »

Also, although this would require a lot of work, the application could accept a FEN string and allow the user to select bitboard displays of various occupancy and attack bitboards.
Gerd Isenberg
Posts: 2250
Joined: Wed Mar 08, 2006 8:47 pm
Location: Hattingen, Germany

Re: New free tool : Bitboards Helper

Post by Gerd Isenberg »

Nice. Bitboard programmers need such a tool to display bitboards while debugging etc..

My one (called Bibob) is a MFC multiple document interface windows application, supporting clipboard, pasting FEN, hex or decimal strings, ASCCI bitboards etc, and binary operators between windows containing bitboards, and unary ops on the window itself.

Image
bob
Posts: 20943
Joined: Mon Feb 27, 2006 7:30 pm
Location: Birmingham, AL

Re: New free tool : Bitboards Helper

Post by bob »

Giorgio Medeot wrote:
bob wrote:For understandability, a8=0, h1=63 is easier to visualize.
Yes, that is why I chose to do so: it was easier to visualize the bitboard, looking at the binary representation. The only thing that has to be taken care of, is to correctly translates the coordinates of the board, everything else is just mirrored and works the same way.
Then, it is true that I can not copy/paste code from anywhere, as most engines use a different convention, but that is not a problem for me. I chose to write everything my own way, right from the start, just for the fun of it! :)
h1=0/a1=7 might also be OK, since the rightmost 8 bits are 1st rank, etc. I didn't do it because simple parsing is more natural for a1=0, with

square = (rank - '1') * 8 + file - 'a'

where file = 'a' to 'h' and rank = '1' to '8'
User avatar
Giorgio Medeot
Posts: 52
Joined: Fri Jan 29, 2010 2:01 pm
Location: Ivrea, Italy

Re: New free tool : Bitboards Helper

Post by Giorgio Medeot »

Doh!, sorry I had half brain disconnected... :) Actually I meant h1=0/a8=63, so that I can read the binary representation of the bitboard as if it was a FEN string. That is the leftmost 8 digits are the eighth rank of the board and the rightmost 8 digits are the first rank, as you say.
Mmmh, too much work today... :)