encodeMove function

int encodeMove(
  1. Move m,
  2. Game game
)

Implementation

int encodeMove(Move m, Game game) {
  int fromX = game.size.file(m.from);
  int fromY = game.size.rank(m.from);
  int toX = game.size.file(m.to);
  int toY = game.size.rank(m.to);

  int from64 = (fromY * 8) + fromX;
  int to64 = (toY * 8) + toX;

  return (from64 * 64) + to64 + 1;
}