title: A Perfect Hashing Function for an 8 by 8 board?
body: <p>I'm implementing a board with only 2 types of pieces, and was looking for a function to map from that board to a Long Integer (64 bits). I was thinking this should not be so hard, since a long integer contains more available information than an 8 by 8 array (call it grid[x][y]) with only 3 possible elements in each spot including the empty element. I tried the following:<br>
  (1) Zobrist hashing with Longs rather than ints (Just to test - I didn't actually expect that to work perfectly)<br>
  (2) Translated the grid into a 64 character string of a base 3 number, and then took that number and parsed it into a long. I think this should work, but it took a very very long time.<br>
  Is there some simpler solution to (2) involving bit operations of shifting or something like that?<br>
  Edit: Please don't give me actual code, as this is for a class project, and that would probably be considered unethical in our department (or at least not in Java).<br>
  Edit2: Basically, there are only 10 whites and 10 blacks on the board at any given time, of which no two pieces of the same color can be neighbors, either in the horizontal, vertical, or diagonal direction. Also, there are 12 spaces for each color where only that color may place pieces.  </p>