Bit Board Orientation

Discussion of chess software programming and technical issues.

Moderators: hgm, Rebel, chrisw

Tord
Posts: 31
Joined: Tue Feb 27, 2018 11:29 am

Re: Bit Board Orientation

Post by Tord »

I use a8=0, a7=1, ..., h1=7, b8=8, ..., h1=63. It's convenient to use "file-major" rather than "rank-major" indexing, because it makes generating pawn captures a little easier (you don't have to worry about wraparounds from the a to the h file when shifting the pawn bitboards).
User avatar
mvanthoor
Posts: 1784
Joined: Wed Jul 03, 2019 4:42 pm
Location: Netherlands
Full name: Marcel Vanthoor

Re: Bit Board Orientation

Post by mvanthoor »

Tord wrote: Tue Oct 06, 2020 11:12 am I use a8=0, a7=1, ..., h1=7, b8=8, ..., h1=63. It's convenient to use "file-major" rather than "rank-major" indexing, because it makes generating pawn captures a little easier (you don't have to worry about wraparounds from the a to the h file when shifting the pawn bitboards).
Shouldn't that be:
a8 = 0,
a7 = 1,
....
b8 = 8
...
h8=56,
...
h1=63 ?

I assume you have a typo at h1=7, and switched it around with b8 in the list.

That feels hard to visualize... :) I always look at chess from white's point of view, be it position setup, evaluation, or when analyzing on the computer.

Even when I'm analyzing a game on the computer I played with black myself, I'm still analyzing from white's point of view. I really dislike the black viewpoint when looking at a chessboard in 2D and NOT playing black myself at that time. (Diagrams, computer screen, or even when represented in code with anything else but A1 = 0) . I can -do- it, but it costs mental effort to turn everything 'right side up' all the time. The only time I'll use the black point of view (and have no problems with it) is when -playing- black myself.
Author of Rustic, an engine written in Rust.
Releases | Code | Docs | Progress | CCRL
Dann Corbit
Posts: 12541
Joined: Wed Mar 08, 2006 8:57 pm
Location: Redmond, WA USA

Re: Bit Board Orientation

Post by Dann Corbit »

For me, it is worse than that.
All these years of computer chess make it uncomfortable for me to play with a chessboard and chessmen.
I would MUCH rather have a 2-d display like Winboard produces
Taking ideas is not a vice, it is a virtue. We have another word for this. It is called learning.
But sharing ideas is an even greater virtue. We have another word for this. It is called teaching.
Tord
Posts: 31
Joined: Tue Feb 27, 2018 11:29 am

Re: Bit Board Orientation

Post by Tord »

mvanthoor wrote: Tue Oct 06, 2020 12:29 pm
Tord wrote: Tue Oct 06, 2020 11:12 am I use a8=0, a7=1, ..., h1=7, b8=8, ..., h1=63. It's convenient to use "file-major" rather than "rank-major" indexing, because it makes generating pawn captures a little easier (you don't have to worry about wraparounds from the a to the h file when shifting the pawn bitboards).
Shouldn't that be:
a8 = 0,
a7 = 1,
....
b8 = 8
...
h8=56,
...
h1=63 ?

I assume you have a typo at h1=7, and switched it around with b8 in the list.
You are right. I meant a1=7, of course.
That feels hard to visualize... :)
Not a problem at all. I visualize the board pretty much exactly the same way you and everybody else do, I believe. The square indexing scheme is a low-level implementation detail that isn't visible anywhere in the high-level parts of the code. In those parts of the code where visualization matters at all, the square indices are invisible.
Aleks Peshkov
Posts: 892
Joined: Sun Nov 19, 2006 9:16 pm
Location: Russia

Re: Bit Board Orientation

Post by Aleks Peshkov »

My coordinates are relative to each side. A8 = 0 for White, A1 = 0 for Black.
It seems complex but it simplifies many calculations to make them true color independent.