indexToUci static method

String indexToUci(
  1. int index
)

Decodes a MuZero move index (0-4095) into a UCI string (e.g., "e2e4")

Implementation

static String indexToUci(int index) {
  if (index == 0) return "START";

  // The 4096 moves are usually structured as:
  // (from_square [0-63]) * 64 + (to_square [0-63])
  // Note: This is a simplified version of the AlphaZero 73-plane encoding
  int fromSq = (index - 1) ~/ 64;
  int toSq = (index - 1) % 64;

  if (fromSq > 63 || toSq > 63) return "invalid";

  String fromName = _squareName(fromSq);
  String toName = _squareName(toSq);

  return "$fromName$toName";
}