Not strictly a question, more of a puzzle...
Over the years, I\'ve been involved in a few technical interviews of new employees. Other than asking the standard \"do you
If computational time is not an issue then you could use a deterministic possible position generator to assign unique ids to a given position.
From a given position first generate number of possible positions in a deterministic manor, e.g. starting bottom left moving to top right. That determines how many bits you'll need for the next move, some situations it could be as little as one. Then when the move is made store just the unique id for that move.
Promotion and other rules simply count as valid moves as long as they are handled in a deterministic way, e.g. to queen, to rook, to bishop each count as a separate move.
The initial position is hardest and could generate around 250 million possible positions (I think) which would require about 28 bits plus an extra bit to determine whose move it is.
Assuming we know who's turn it is (each turn flips from white to black) the deterministic generator would look something like:
for each row
for each column
add to list ( get list of possible moves( current piece, players turn) )
'get list of possible moves' would do something like:
if current piece is not null
if current piece color is the same as the players turn
switch( current piece type )
king - return list of possible king moves( current piece )
queen - return list of possible queen moves( current piece )
rook - return list of possible rook moves( current piece )
etc.
If the king is in check then each 'list of possible xxx moves' only returns valid moves that change the check situation.