I'm looking to create a basic chess (or failing that, checkers/draughts) engine. After researching the topic I'm fairly confident that I want to use a series of bitboards. I understand the concept at a basic level but I'm having trouble representing them in Java.
I've attempted to represent the white pieces of a chessboard as 1 and everything else as 0 using a long:
long whitePieces = 0000000000000000000000000000000000000000000000001111111111111111L;
But when I print it out I get the following 46 bits:
System.out.println(Long.toBinaryString(whitePieces));
1001001001001001001001001001001001001001001001
What is causing this result? I'm sure there's something I'm fundamentally misunderstanding here; If anyone could point me in the right direction I'd be very grateful.
05
?, Answer:5
. Make a 2d array of booleans instead. Or a coded integer of some kind instead of multiple such arrays. – Karyoplasm1111111111111111
, it will not be1111111111111111
...1111111111111111
is the binary representation of the binary number1111111111111111
, which is the integer65535
. – Psoas