• Welcome to Smashboards, the world's largest Super Smash Brothers community! Over 250,000 Smash Bros. fans from around the world have come to discuss these great games in over 19 million posts!

    You are currently viewing our boards as a visitor. Click here to sign up right now and start on your path in the Smash community!

VB.NET Question

EnigmaticCam

Smash Ace
Joined
Jun 22, 2005
Messages
688
Location
CA
Ok, so I'm trying to write a chess engine in VB.Net 2005. Yes, I know it's not the greatest environment to make a chess engine, but it's just for fun.

Anyways, I'm using bitboards to help calculate moves as quickly as possible. If you're not familiar with bitboards, they are basically very large numbers that are binary representations of the board in a current position.

My problem is that a bitboard has to hold a value from 2^0 to 2^64-1 (which I can do just fine storing it in an unsigned long), yet when I attempt to AND any number equal to or greater than 2^63, I get an overflow exception. Basically, the AND bitwise operator is limited to numbers lower than 2^63, and I can't find an alternative.

Anybody here who can help me out?
 

AltF4

BRoomer
BRoomer
Joined
Dec 13, 2005
Messages
5,042
Location
2.412 – 2.462 GHz
If you're just doing a bitwise AND, you could split the number into two smaller numbers. Compute the AND separately, then join them again.

It's kind of a kludge, but it should do the trick. It would work like...

10101000 10101101 (binary) = 43,181 (decimal)
AND
10010100 10001101 (binary) = 38,029 (decimal)

split into...

10101000 = 168 10101101 = 173
AND AND
10010100 = 148 10001101 = 141
EQUALS EQUALS
10000000 = 128 10001101 = 141

Then combine again...

10000000 10001101 = 32909
 

EnigmaticCam

Smash Ace
Joined
Jun 22, 2005
Messages
688
Location
CA
I thought about splitting it like that. The key to a strong chess engine is being able to calculate these moves quickly, and I was hoping if there was some more direct approach with less extra conversion than necessary. If there isn't, then that's exactly what I will have to do, split the bitboard.
 

AltF4

BRoomer
BRoomer
Joined
Dec 13, 2005
Messages
5,042
Location
2.412 – 2.462 GHz
Like I said, it's a kludge. But I'm not familiar with VB.NET, so I can't tell you what functions are available to you. Just general programming tips.
 
Top Bottom