Square
The Square class represents a square on a chessboard, defined by a File (column) and a Rank (row). It provides methods for parsing algebraic notation, determining square color, and string representation.
Overview
A square is defined by a file ('a' to 'h') and a rank (1 to 8).
Provides utility methods for parsing, color determination, and string representation.
Parsing
From Algebraic Notation: The Square can be constructed from algebraic notation (e.g., "e4").
Validates the notation and extracts the file and rank components.
Square Color
Dark Square: A square is dark if the sum of its file and rank indices is even.
Light Square: A square is light if the sum of its file and rank indices is odd.
Example Usage
val square = Square("e4")
val isDark = square.isDarkSquare() // true
val notation = square.toString() // "e4"Content copied to clipboard