Tork5
The gears of war
About
This is version of the board game Pentago. It is notable to me because it is the first, (and hopefully the last) time I try to write a bitboard implementation in javascript using javascript’s float type, which is insane!
Floats in javascript give you 53 bits of precision - however, you can only do bitwise operations on 32 bits at a time. This meant writing helper functions for all the common bitwise operations, for example this xor function:
While this ended up working, it’s rarely a good sign when you’re constantly amazed that your own implementation actually works, and is a complete nightmare to debug. Since then I’ve had some success in switching over to using javascript typed arrays for my javascript bitboard needs.
#More Madness But wait - there’s more… Usually it’s convenient to layout the bitboard so that it’s convenient to map a [row, column] position to bit position. However, to make it easier to rotate the quad boards, it is arranged thusly:
This allowed for quads to be rotated using a bitshift operation.
Comments