To bitboard.
Bitboards aren't only very efficient for the moves generator, but also are really efficient in the evaluation because you have a lot of important information already stored on them, and a fast way (bitwise operators) to combine them to get extra info (passed pawns, doubled pawns, etc).
As a summary, bitboards representation provide an efficient framework to get info from the position on the board.
How to implement bitboards?.. and some more questions
Moderators: hgm, Rebel, chrisw
-
- Posts: 238
- Joined: Tue Jul 12, 2011 1:31 pm
Re: How to implement bitboards?.. and some more questions
Two first meanings of the dutch word "leren":
1. leren [vc] (learn, larn, acquire) acquire or gain knowledge or skills.
2. leren [v] (teach, learn, instruct) impart skills or knowledge to.
1. leren [vc] (learn, larn, acquire) acquire or gain knowledge or skills.
2. leren [v] (teach, learn, instruct) impart skills or knowledge to.
-
- Posts: 7218
- Joined: Mon May 27, 2013 10:31 am
Re: How to implement bitboards?.. and some more questions
I know nothing about it.
[
Even if I would have a bitboard with all possible moves for a piece I don't know how I can iterate over these moves efficiently. Could be it is described many times but I haven't found it.
Maybe such a bitboard is useless for that purpose. So perhaps one has to go back and test some predefined bits starting from a location in a bitboard and test if it is occupied or not ?
]
[
Even if I would have a bitboard with all possible moves for a piece I don't know how I can iterate over these moves efficiently. Could be it is described many times but I haven't found it.
Maybe such a bitboard is useless for that purpose. So perhaps one has to go back and test some predefined bits starting from a location in a bitboard and test if it is occupied or not ?
]
-
- Posts: 2204
- Joined: Sat Jan 18, 2014 10:24 am
- Location: Andorra
Re: How to implement bitboards?.. and some more questions
Doing something with the set bits of a bitboard:
Code: Select all
while (BitScanForward(&indexbit, bitboardvar)) {
bitboardvar &= bitboardvar - 1; //unset the bit
//do something with indexbit, for example put in an array
}
Daniel José - http://www.andscacs.com
-
- Posts: 6442
- Joined: Tue Jan 09, 2007 12:31 am
- Location: PA USA
- Full name: Louis Zulli
Re: How to implement bitboards?.. and some more questions
Since you are a beginner, I feel you should start with an array-based board representation (of your own design) and see if you can write a correct move-generator.zullil wrote:Eventually.vittyvirus wrote:Can anyone give me one word answer for this: To bitboard or not to bitboard?
My fear is, that in your rush to "create" the next 3000+ engine, you will end up "borrowing" a lot of code without gaining any real understanding of what it means to write a chess program.
So save bitboards for version 2. Just my 2¢, but I'm not even a programmer.
-
- Posts: 2204
- Joined: Sat Jan 18, 2014 10:24 am
- Location: Andorra
Re: How to implement bitboards?.. and some more questions
+1zullil wrote: Since you are a beginner, I feel you should start with an array-based board representation (of your own design) and see if you can write a correct move-generator.
My fear is, that in your rush to "create" the next 3000+ engine, you will end up "borrowing" a lot of code without gaining any real understanding of what it means to write a chess program.
So save bitboards for version 2. Just my 2¢, but I'm not even a programmer.
With Andscacs I started doing a complete working engine with nothing that I did not understand or I was not used to.
Daniel José - http://www.andscacs.com
-
- Posts: 646
- Joined: Wed Jun 18, 2014 2:30 pm
- Full name: Fahad Syed
Re: How to implement bitboards?.. and some more questions
That's what I was upto; to implement bitboards in my next version or after move generator. But I thought I'd have to work a lot if I implement it later. I've written board generator for Knight moves (that's pretty easy) and I am writing code to do/undo a move (to do is easy but to ujdo is ...). As advised by you guyz, I'm doing it completely on my own.