8.16.0.1
1 Chess Pieces and Colors
(require chess/piece) | package: chess |
A chess piece is a pawn, knight, bishop, rook, queen, or king. They come in two flavors:
A colored chess piece is a piece associated with a particular player, such as a white bishop or a black king.
An uncolored chess piece isn’t associated with any player, and only represents a type of piece.
procedure
(chess-piece? v) → boolean?
v : any/c
A predicate for chess pieces.
1.1 Uncolored Chess Pieces
procedure
v : any/c
A predicate for uncolored chess pieces. Implies chess-piece?.
value
value
value
value
value
value
Constants representing uncolored chess pieces.
An immutable set of all possible uncolored chess pieces.
1.2 Colored Chess Pieces
procedure
(colored-chess-piece? v) → boolean?
v : any/c
A predicate for colored chess pieces. Implies chess-piece?.
value
value
value
value
value
value
value
value
value
value
value
value
Constants representing colored chess pieces.
procedure
(colored-chess-piece #:type type #:owner owner) → colored-chess-piece? type : uncolored-chess-piece? owner : chess-color?
Example:
> (colored-chess-piece #:type pawn #:owner white) (colored-chess-piece #:owner #<white> #:type #<pawn>)
procedure
piece : colored-chess-piece?
Returns the type of piece, as an uncolored chess piece.
Example:
> (colored-chess-piece-type black-knight) #<knight>
procedure
(colored-chess-piece-owner piece) → chess-color?
piece : colored-chess-piece?
Returns the chess color that owns piece.
Example:
> (colored-chess-piece-owner white-queen) #<white>
An immutable set of all possible colored chess pieces.
1.3 Chess Colors
A chess color is either white or black.
procedure
(chess-color? v) → boolean?
v : any/c
A predicate for chess colors.
value
value
Constants representing the two chess colors.