3 Chess Squares
(require chess/square) | package: chess |
A chess square is a single space on a chess board . There are 64 squares. This module exports a constant for each chess square, with a name based on its position:
procedure
(chess-square? v) → boolean?
v : any/c
procedure
(chess-square #:rank rank #:file file) → chess-square?
rank : chess-rank? file : chess-file?
procedure
(chess-square-rank square) → chess-rank?
square : chess-square?
procedure
(chess-square-file square) → chess-file?
square : chess-square?
3.1 Occupied Chess Squares
An occupied chess square is a combination of a square and a piece. Construct one with chess-square-occupy.
procedure
v : any/c
procedure
(occupied-chess-square-piece square) → colored-chess-piece?
square : occupied-chess-square?
procedure
(chess-square-occupy square piece) → occupied-chess-square?
square : chess-square? piece : colored-chess-piece?
> (chess-square-occupy d4 white-pawn)
(occupied-chess-square
#:file (chess-file 3)
#:piece (colored-chess-piece #:owner #<white> #:type #<pawn>)
#:rank (chess-rank 3))
procedure
(chess-square-remove-occupant square) → chess-square?
square : occupied-chess-square?
> (define occupied (chess-square-occupy d4 white-pawn)) > (chess-square-remove-occupant occupied) #<chess-square:d4>
3.2 Ranks and Files
procedure
(chess-rank? v) → boolean?
v : any/c
procedure
(chess-rank index) → chess-rank?
index : (integer-in 0 7)
procedure
(chess-rank-index rank) → (integer-in 0 7)
rank : chess-rank?
procedure
(chess-file? v) → boolean?
v : any/c
procedure
(chess-file index) → chess-file?
index : (integer-in 0 7)
procedure
(chess-file-index file) → (integer-in 0 7)
file : chess-file?
procedure
(in-chess-ranks [#:descending? descending?])
→ (sequence/c chess-rank?) descending? : boolean? = #f
procedure
(in-chess-files [#:right-to-left? right-to-left?])
→ (sequence/c chess-file?) right-to-left? : boolean? = #f
3.3 Chess Square Constants
value
value
value
value
value
value
value
value
value
value
value
value
value
value
value
value
value
value
value
value
value
value
value
value
value
value
value
value
value
value
value
value
value
value
value
value
value
value
value
value
value
value
value
value
value
value
value
value
value
value
value
value
value
value
value
value
value
value
value
value
value
value
value
value