squareName method

String squareName(
  1. int square
)

Returns the name for a square, according to chess conventions, e.g. c6, b1.

Implementation

String squareName(int square) {
  int rank = v - (square ~/ (h * 2));
  int file = square % (h * 2);
  String fileName = String.fromCharCode(Bishop.asciiA + file);
  return '$fileName$rank';
}