humanReadableSquareSet function

String humanReadableSquareSet(
  1. SquareSet sq
)

Prints the square set as a human readable string format

Implementation

String humanReadableSquareSet(SquareSet sq) {
  final buffer = StringBuffer();
  for (int y = 7; y >= 0; y--) {
    for (int x = 0; x < 8; x++) {
      final square = x + y * 8;
      buffer.write(sq.has(square) ? '1' : '.');
      buffer.write(x < 7 ? ' ' : '\n');
    }
  }
  return buffer.toString();
}