encodeMove method
Maps a Bishop Move to our model's 0-4097 action space. Bishop moves contain 'from' and 'to' integer indices (0-63 for standard chess).
Implementation
int encodeMove(Move m, Game game) {
// 1. Get Bishop's internal size object
final size = game.size;
// 2. Extract X (file) and Y (rank) using Bishop's built-in conversion
int fromX = size.file(m.from); // Correctly strips internal padding
int fromY = size.rank(m.from);
int toX = size.file(m.to);
int toY = size.rank(m.to);
// 3. Convert to a standard flat 0-63 coordinate
// Standard: (Rank * 8) + File
int from64 = (fromY * 8) + fromX;
int to64 = (toY * 8) + toX;
// 4. Map to your model's action space index (1-4096)
// index 0 is reserved for Start/Padding
int finalIdx = (from64 * 64) + to64 + 1;
return finalIdx;
}