Bitboards and Java

Discussion of chess software programming and technical issues.

Moderators: hgm, Rebel, chrisw

Fguy64
Posts: 814
Joined: Sat May 09, 2009 4:51 pm
Location: Toronto

Bitboards and Java

Post by Fguy64 »

I am trying to decide which programming language to use for my chess project. I am leaning towards Java because that is the language I know best.

This from the Chess Programming Wiki...

"Java has no unsigned long data type that is e.g. used by bitboards. Thus developers have to handle the bits slightly differently."

How different is "differently"? The CPW doesn't go into details
mkchan
Posts: 88
Joined: Thu Oct 06, 2016 9:17 pm
Location: India

Re: Bitboards and Java

Post by mkchan »

Fguy64 wrote:I am trying to decide which programming language to use for my chess project. I am leaning towards Java because that is the language I know best.

This from the Chess Programming Wiki...

"Java has no unsigned long data type that is e.g. used by bitboards. Thus developers have to handle the bits slightly differently."

How different is "differently"? The CPW doesn't go into details
I think the only thing you'll have to handle differently is the bit shifting. You want to use `>>>` for unsigned (logical) right shifting so your bitboard doesn't get populated with 1s from the most significant bit end if it originally was set.

Not sure if anything else is different.
Philipp Bach
Posts: 4
Joined: Thu Jan 01, 2015 12:21 pm

Re: Bitboards and Java

Post by Philipp Bach »

Yup, you should be fine if you just use >>> instead of >>.
In case you're interested you can check out my java chess engine (WIP):
https://github.com/etherblood/Chess/tre ... /src/chess
Fguy64
Posts: 814
Joined: Sat May 09, 2009 4:51 pm
Location: Toronto

Re: Bitboards and Java

Post by Fguy64 »

Philipp Bach wrote:Yup, you should be fine if you just use >>> instead of >>.
In case you're interested you can check out my java chess engine (WIP):
https://github.com/etherblood/Chess/tre ... /src/chess
Thanks. I'll bookmark your java engine for future reference.

My engine is a long way off. I need to brush up on my Java first. It'll probably be a couple of months before I get started on my program. I hope to eventually have more than just an engine. PGN Database, FICS client etc. This will be a long term project
Gerd Isenberg
Posts: 2250
Joined: Wed Mar 08, 2006 8:47 pm
Location: Hattingen, Germany

Re: Bitboards and Java

Post by Gerd Isenberg »

Fguy64 wrote:I am trying to decide which programming language to use for my chess project. I am leaning towards Java because that is the language I know best.

This from the Chess Programming Wiki...

"Java has no unsigned long data type that is e.g. used by bitboards. Thus developers have to handle the bits slightly differently."

How different is "differently"? The CPW doesn't go into details
yep, unsigned right shift is the issue - since otherwise arithmetical shift right would fill in the most significant sign bit instead of zero. CPW should be more clear now.
sandermvdb
Posts: 160
Joined: Sat Jan 28, 2017 1:29 pm
Location: The Netherlands

Re: Bitboards and Java

Post by sandermvdb »

Another thing to keep in mind is that if you want to check if any value within the bitboard is set, you should not use > 0 but != 0.