Bitboards and Java

Discussion of chess software programming and technical issues.

Moderators: hgm, Harvey Williamson, bob

Post Reply
Fguy64
Posts: 810
Joined: Sat May 09, 2009 2:51 pm
Location: Toronto
Contact:

Bitboards and Java

Post by Fguy64 » Tue Nov 14, 2017 1:08 pm

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: 65
Joined: Thu Oct 06, 2016 7:17 pm
Location: India
Contact:

Re: Bitboards and Java

Post by mkchan » Tue Nov 14, 2017 1:17 pm

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: 1
Joined: Thu Jan 01, 2015 11:21 am

Re: Bitboards and Java

Post by Philipp Bach » Tue Nov 14, 2017 7:10 pm

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: 810
Joined: Sat May 09, 2009 2:51 pm
Location: Toronto
Contact:

Re: Bitboards and Java

Post by Fguy64 » Tue Nov 14, 2017 7:30 pm

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: 2103
Joined: Wed Mar 08, 2006 7:47 pm
Location: Hattingen, Germany

Re: Bitboards and Java

Post by Gerd Isenberg » Tue Nov 14, 2017 8:19 pm

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: 112
Joined: Sat Jan 28, 2017 12:29 pm
Location: The Netherlands

Re: Bitboards and Java

Post by sandermvdb » Wed Nov 15, 2017 7:09 am

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.

Post Reply