A chess library in lisp. Defines a data structure for a board, validates and performs moves, and reads portable game notation.
In knight-owl, a chess board is stored as a two-dimensional array of piece symbols in the form [bw]-[prnbqk]. For example, ‘b-n would indicate a black knight. Empty squares are denoted with nil.
- Description: Evaluate to a fresh 2D array with initial the chess position.
- Arguments:
- board
- A two-dimensional array of piece symbols.
- board
- Description: Create a new two-dimensional array identical to the input board.
- Arguments:
- board
- A two-dimensional array of piece symbols.
- stream
- An input stream designator. Defaults to
t
.
- An input stream designator. Defaults to
- board
- Description: Write a 2D chess board array to a stream in a pretty fashion.
- Arguments:
- board
- A two-dimensional array of piece symbols.
- file
- An integer.
- rank
- An integer.
- board
- Description: Access a chess board x/y location. Note that (setf get-square) also exists.
- Arguments:
- move
- A string chess action in standard algebraic notation.
- board
- A two-dimensional array of piece symbols.
- whitep
- A generalized boolean. Truth value for white, nil for black.
- move
- Description: Destructively modify the board for the given move.
- Arguments:
- move
- A string chess action in standard algebraic notation.
- board
- A two-dimensional array of piece symbols.
- whitep
- A generalized boolean. Truth value for white, nil for black.
- move
- Description: Determine if a move can legally be performed on a given board.
- Arguments:
- board
- A two-dimensional array of piece symbols.
- whitep
- A generalized boolean. Truth value for white, nil for black.
- board
- Description: Determines if the king is being attacked.
- Arguments:
- board
- A two-dimensional array of piece symbols.
- whitep
- A generalized boolean. Truth value for white, nil for black.
- board
- Description: Determine if the king is both being attacked and cannot escape.
- Description: Constant that’s defined as a list of all possible string algebraic notation moves.
- Arguments:
- stream
- An input stream designator
- stream
- Description: Parse a single chess game depicted in portable game notation.
For general moves, the first character (or lack thereof) indicates the piece: R for Rook, N for kNight, B for Bishop, Q for Queen, K for King, and the empty string for pawn. Optionally a file or rank (or both) may be given after the piece letter to remove ambiguity. An x comes next if a capture takes place. The next two characters always represent the destination file [a,z] and rank [1,8]. If the move includes a pawn promotion, an equals sign and the letter of the replacement piece are added. Lastly, a plus sign describes check and the hash symbol checkmate. For castling, O-O and O-O-O label kingside and queenside castles, respectively.
<move> ::= <castle><checking>? | <piece><file>?<rank>?<capture>?<file> <rank><promotion>?<checking>? <piece> ::= R | N | B | Q | K | <empty string> <empty string> ::= <file> ::= [a-h] <rank> ::= [1-8] <capture> ::= x <promotion> ::= =<piece> <checking> ::= [#+] <castle> ::= <queenside castle> | <kingside castle> <kingside castle> ::= O-O <queenside castle> ::= O-O-O