Skip to content

Instantly share code, notes, and snippets.

@cammckinnon
Created March 31, 2012 02:05
Show Gist options
  • Save cammckinnon/2258605 to your computer and use it in GitHub Desktop.
Save cammckinnon/2258605 to your computer and use it in GitHub Desktop.
// get the x coordinate for bit set on the board.
// b must have exactly 1 bit set or else the behavior is undefined.
uint getX() {
static uint x_precomputed[67] =
{
0, 7, 6, 0, 5, 0, 7, 0,
4, 3, 7, 4, 6, 4, 7, 1,
3, 0, 2, 5, 6, 1, 3, 3,
5, 1, 3, 4, 6, 3, 0, 0,
2, 7, 0, 1, 1, 1, 4, 5,
5, 2, 0, 6, 2, 4, 2, 5,
4, 1, 0, 2, 2, 6, 3, 7,
5, 6, 2, 3, 7, 0, 7, 4,
1, 5, 6
};
return x_precomputed[board % 67];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment