The queen.lisp Reference Manual

Table of Contents

Next: , Previous: , Up: (dir)   [Contents][Index]

The queen.lisp Reference Manual

This is the queen.lisp Reference Manual, generated automatically by Declt version 2.3 "Robert April" on Tue Feb 20 09:14:50 2018 GMT+0.


Next: , Previous: , Up: Top   [Contents][Index]

1 Introduction

QUEEN - Chess Utilities For Common Lisp
=======================================


What's in it:

- board representation (0x88 method)
- move generation (passes perft tests)
- FEN/SAN/PGN parser and generator
- basic (weak) evaluation engine (still, it kinda beats me at depth=5)

This is only tested on SBCL, but there is no SBCL-specific code, so it
should work on other implementations.  I'd love to hear about it.


Synopsis
--------

    ;; create game
    (setf g (make-game))
    (reset-game g)

    ;; print the board with RNBQKP notation
    (print-board (game-board g))

    ;; print board with Unicode chars for pieces
    (let ((*unicode* t)) (print-board (game-board g)))

    ;; generate available moves
    (setf moves (game-compute-moves g))

    ;; print moves
    (loop for m in moves
          do (format t "~A~%" (game-san g m)))

    ;; perft test to depth 6 (~36 sec. on my laptop from start position)
    (time (perft g 6))

    ;; try a move
    (with-move (g (car (game-parse-san g "Nf3")))
      (print-board (game-board g)))        ; prints board after Nf3
    (print-board (game-board g))           ; back to previous position

    ;; execute a move
    (game-move g (car (game-parse-san g "d4")))
    (print-board (game-board g))

    ;; is the current side in check?
    (attacked? g)

    ;; find best line to depth 5 (default: +MAX-DEPTH+)
    (setf line (game-search g 5))
    (cond
      ((and (null line) (attacked? g))
       (format t "Checkmate~%"))
      ((null line)
       (format t "Draw~%"))
      (t
       (format t "~A~%" (dump-line g line))))

    ;; initialize from FEN
    (reset-from-fen g "r4rk1/1pp1qppp/p1np1n2/2b1p1B1/2B1P1b1/P1NP1N2/1PP1QPPP/R4RK1 w - - 0 10")
    (time (perft g 5))
    ;; -->
    ;; Depth: 5, Count: 164075551, Captures: 19528068, Enpa: 122, Checks: 2998608, Promo: 0, Castle: 0
    ;; Evaluation took:
    ;;  54.679 seconds of real time

    ;; find mate in 3
    QUEEN> (reset-from-fen g "r4r2/1pNP4/pPk2N1Q/2BR1n2/1P6/8/2p2K1p/8 w - - 0 1")

    QUEEN> (let ((*unicode* t)) (print-board (game-board g)))
    8 │ ♜ □ □ □ □ ♜ □ □
    7 │ □ ♟ ♘ ♙ □ □ □ □
    6 │ ♟ ♙ ♚ □ □ ♘ □ ♕
    5 │ □ □ ♗ ♖ □ ♞ □ □
    4 │ □ ♙ □ □ □ □ □ □
    3 │ □ □ □ □ □ □ □ □
    2 │ □ □ ♟ □ □ ♔ □ ♟
    1 │ □ □ □ □ □ □ □ □
      └─────────────────
        a b c d e f g h

    QUEEN> (let ((*unicode* t)) (dump-line g (game-search g 5)))
    "1. ♔e1 h1=♛+ 2. ♕xh1 c1=♛+ 3. ♖d1#"

    ;; test the move generator using perftsuite.epd
    (run-perft-tests 5)         ; takes 2 minutes for depth 5

    ;; play a game against the engine
    (play &key fen depth)       ; default depth=5 and start position
    ;;
    ;; enter: valid move in SAN notation, or:
    ;;
    ;;        go -- force computer to move
    ;;        exit -- stop game
    ;;        restart -- restart game to given fen
    ;;        reset -- start new game
    ;;        undo -- undo last move
    ;;        pgn -- show all moves played so far in PGN
    ;;        fen -- show current position as FEN


Data structures and types
-------------------------

Note: this section documents internals, which might change.

- `piece` -- an `(unsigned-byte 8)`.  We use six bits for the piece and one for
  the side, as follows:

    ┌─┬─┬─┬─┬─┬─┬─┬─┐
    │7│6│5│4│3│2│1│0│
    └─┴┬┴┬┴┬┴┬┴┬┴┬┴┬┘
       │ │ │ │ │ │ └────── Queen
       │ │ │ │ │ └──────── Rook
       │ │ │ │ └────────── Knight
       │ │ │ └──────────── Bishop
       │ │ └────────────── Pawn
       │ └──────────────── King
       └────────────────── White

  A piece cannot be both a queen and a rook, of course — so we could have
  used fewer bits — but it's sometimes useful to test whether a piece is
  *either* a queen or a rook; by allocating one bit for each piece type, we
  can do that by AND-ing with 3 (Queen + Rook).

  The idea with the seemingly arbitrary ordering was to be able to represent
  pieces that we can promote to in 4 bits (Q, R, N, B), and pieces that can
  be captured in 5 (Q, R, N, B, P) — so the king is last.

- `board` -- a simple-array of 120 `piece` elements (of which only 64 are used).
  A zero element means the field is empty.

- `board-index` -- an integer between 0 and 119 (index in the `board` array).
  An integer value is a valid index if by AND-ing it with 0x88 we get zero
  (i.e. on other values we never store pieces, even if they still fall between 0
  and 119).

- `move` -- an `(unsigned-byte 32)`:

     3 3 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1 0 0 0 0 0 0 0 0 0 0
     1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0
    ┌─┬─┬─┬─┬─┬─┬─┬─┬─┬─┬─┬─┬─┬─┬─┬─┬─┬─┬─┬─┬─┬─┬─┬─┬─┬─┬─┬─┬─┬─┬─┬─┐
    │ │+│E│x│x│x│x│x│x│=│=│=│=│p│p│p│p│p│p│p│R│R│R│C│C│C│R│R│R│C│C│C│
    └─┴┬┴┬┴┬┴─┴─┴─┴─┴┬┴┬┴─┴─┴┬┴┬┴─┴─┴─┴─┴─┴┬┴┬┴─┴─┴─┴─┴┬┴┬┴─┴─┴─┴─┴┬┘
       │ │ └────┬────┘ └──┬──┘ └─────┬─────┘ └────┬────┘ └────┬────┘
       │ │      │         │          │            │           │
       │ │      │         │          │            │           └────── FROM
       │ │      │         │          │            └────────────────── TO
       │ │      │         │          └─────────────────────────────── PIECE
       │ │      │         └────────────────────────────────────────── PROMOTION
       │ │      └──────────────────────────────────────────────────── CAPTURE
       │ └─────────────────────────────────────────────────────────── ENPA
       └───────────────────────────────────────────────────────────── CHECK

     R : row, 3 bits (integer 0 7)
     C : col, 3 bits (integer 0 7)
     p : piece moved, 7 bits (including side: bit 18 is 1 for white moves)
     = : piece promoted to, 4 bits (same side as p)
     x : captured piece, 6 bits (opposite side from p)
     E : 1 if en-passant move, 0 otherwise
     + : 1 if checking move, 0 otherwise

  Moves are created with the `game-compute-moves` function.  While you *can*
  create an `(unsigned-byte 32)` manually, or maybe via the `make-move`
  function, there is no guarantee that that move is valid in the context of an
  existing game.

- `game` -- a structure containing a board and other features that determine the
  current situation of a game: the side to move, the en-passant target field,
  the castling conditions, and the number of full-moves / half-moves.  Currently
  a `game` struct does not maintain a list of moves played so far (this might
  change).


Game functions
--------------

- (make-game) -- instantiate a `game` struct

- (game-board game) -- the board array

- (game-state game) -- the castling state

- (game-side game) -- the current side to play (+WHITE+ or +BLACK+)

- (game-enpa game) -- the index of the en-passant target field (or NIL)

- (game-fullmove game) -- the current move number

- (game-halfmove game) -- the "halfmove" number (number of moves since the
  last pawn or capturing move)

- (reset-from-fen game fen) -- reset a game from a FEN string or input
  stream

- (reset-game game) -- reset a game to starting position

- (game-fen game) -- return the current game position as a FEN string

- (game-move game move &optional quick) -- execute the given move.  When
  `quick` is true, skip updating the fullmove/halfmove counts.

- (with-move (game move &optional quick) &body body) -- macro; execute the
  move and perform body, then take back the move.

- (king-index game &optional side) -- return the `board-index` of the king
  for the given side (default to current side to play).

- (attacked? game &optional side index) -- return T if the given index/side
  is under attack.  Default arguments are the current side to play, and the
  king index.

- (game-compute-moves game) -- return the list of legal moves for the
  current side to play.

- (game-parse-san game san &optional moves) -- parse a move in SAN notation.
  If `moves` is not passed, it defaults to (game-compute-moves game).  This
  function returns a list of `move` elements; if SAN is valid, this list
  should contain exactly one move, but when it's not valid or ambiguous it
  might have zero or more elements.  `SAN` should be a string or an input
  stream.

- (game-san game move &optional moves) -- return a `move` in SAN notation.
  `moves` defaults to (game-compute-moves game).

- (draw-by-material? game) -- return T if the current position is a draw
  because of insufficient material.

- (perft game depth &optional count-mates) -- return PERFT results for the
  current game, to the given depth.  Pass true for `count-mates` if you'd
  like to count checkmates as well (slightly increases the run time).

- (divide game depth) -- used for debugging; see [1] for more information
  about PERFT and DIVIDE.


PGN parser
----------

(parse-pgn data) -- where `data` is a string or an input stream.  Returns a
plist like this:

    (:headers HEADERS
     :moves MOVES
     :game GAME)

HEADERS is an alist associating header name (as string) with the value (also
a string).

MOVES is a list of moves/comments/result found in the PGN data, in the order
they are encountered.  It has this form:

    ((:move . NUMBER) ... (:comment . "text") ... (:result . "1-0"))

The moves are in numerical representation described above.

GAME is a `game` instance in the final position.

Example:

    QUEEN> (parse-pgn "[White \"Foo\"]
    [Black \"Bar\"]

    1.d4 d5 2.c4 {Queen's gambit} dxc4 {accepted}")

    ==>

    (:HEADERS (("White" . "Foo")
               ("Black" . "Bar"))
     :MOVES ((:MOVE . 329419)
             (:MOVE . 67827)
             (:MOVE . 329354)
             (:COMMENT . "Queen's gambit")
             (:MOVE . 134284963)
             (:COMMENT . "accepted"))
     :GAME #S(GAME
              :BOARD #(...)
              :STATE 15
              :SIDE 64
              :ENPA NIL
              :FULLMOVE 3
              :HALFMOVE 0))


Piece functions
---------------

A piece is an 8 bit unsigned integer (only 7 bits are used).

- constants: +PAWN+, +KNIGHT+, +BISHOP+, +ROOK+, +QUEEN+, +KING+
             +WPAWN+, +WKNIGHT+, +WBISHOP+, +WROOK+, +WQUEEN+, +WKING+
             +WHITE+, +BLACK+

- (is-pawn? p), (is-knight? p), (is-bishop? p), (is-rook? p), (is-queen?
  p), (is-king? p) -- predicates that receive one argument (unsigned-byte 8)
  and return T if it's the respective piece.

- (is-white? p), (is-black? p) -- receive an (unsigned-byte 8) and return T
  if it's the respective color.

- (piece-side p) -- return the side of the piece (+WHITE+ or +BLACK+)

- (same-side? p1 p2) -- return T if the pieces are same color

- (piece-char p) -- return the piece as a character in standard chess
  notation, e.g.:

    R, N, B, Q, K, P for white pieces
    r, n, b, q, k, p for black pieces

  When *unicode* is T, use Unicode chess chars instead.

- (char-piece p) -- the inverse of `piece-char`


Board functions
---------------

A board is stored in a simple array of 120 `piece`-s.

- (board-index row col) -- return the index of the field with the given
  coords

- (field-index field) -- return the index of the named field.

      QUEEN> (field-index "d2")
      19
      QUEEN> (board-index 1 3)
      19
      QUEEN> $d2   ;; when using queen::syntax named readtable
      19

- (index-row index), (index-col index) -- return the coords (0..7)

- (index-field index) -- return the field name, e.g. "d2"

- (index-valid? index) -- return T if the index is valid, that is, it's an
  integer between 0 and 119 and it has the fourth and eighth bit clear.
  More exactly, a valid index looks like this:

    ┌─┬─┬─┬─┬─┬─┬─┬─┐
    │0│R│R│R│0│C│C│C│
    └─┴─┴─┴─┴─┴─┴─┴─┘

  Bits 0, 1, 2 are for the column, and 4, 5, 6 for the row.

- (board-get board index) -- return the piece at the given index (zero when
  the field is empty)

- (board-set board index piece) -- set the piece at the given index

- (board-get-rc board row col) -- return the piece at the given coords

- (board-set-rc board row col piece) -- set the piece at the given coords

- (board-foreach board fn) -- calls the given function for every piece of
  the board (skips empty fields).  The function is called with four
  arguments: piece, row, col and index.

- (print-board board :key (output t)) -- print the board to the given stream
  (by default it goes to standard output).


Move functions
--------------

You should not need to create `move`-s manually; obtain a list of moves via
`game-compute-moves`.  You can use the following accessors on a move (which
is just a 32 bit unsigned integer):

- (move-from move), (move-to move) -- return as `board-index` the move
  from/to fields

- (move-piece move) -- returns the moved piece

- (move-white? move), (move-black? move) -- return T if the moved piece is
  of the respective color

- (move-side move) -- return the move side (+WHITE+ or +BLACK+)

- (move-capture? move) -- return T if it's a capturing move

- (move-captured-piece move) -- returns the captured piece, or NIL if it's a
  non-capturing move

- (move-promote? move) -- return T if it's a promoting move

- (move-promoted-piece move) -- return the promoted piece, or NIL if it's
  not the case

- (move-check? move) -- return T if it's a checking move

- (move-enpa? move) -- return T if it's an en-passant move

- (move-captured-index move) -- return the index of the captured piece if
  it's a capturing move, NIL otherwise.  This can be different from (move-to
  move) in the case of en-passant moves.

- (move-oo? move) -- return T if it's a king-side castling move

- (move-ooo? move) -- return T if it's a queen-side castling move

- (move-castle? move) -- return T if it's a castling move


Evaluation
----------

I wrote this just for fun, and it's outside the scope of this library.  I
don't reasonably expect to produce a strong chess engine, compared to what's
available these days, but if nothing else, this helped me learn a lot about
optimizing Common Lisp code.  Before working on evaluation, (perft 6) ran in
12 minutes.  After optimization it's down to under 40 seconds [*].  Luckily,
this didn't require large refactoring of the code -- just inline trivial
functions, add type declarations, `(declare (optimize speed))` to certain
key functions, and listen to advice from SBCL (which is impressively smart).

  [*] For comparison, Crafty runs perft 6 in 4 seconds on my machine.  Now
      Crafty is a venerable, strong chess engine, written in hand-optimized
      C and using bitboards for move generation (the fastest known method; I
      couldn't wrap my brains around it).  I'd say 10x slower is Okay.

      I'm interested in the performance of other array-based move generators
      (i.e. not bitboards), if you know any please tell me.

Main entry point:

    (game-search game &optional (depth +MAX-DEPTH+))

It returns two values:

- a list of moves -- the "best line" that the algorithm could see.  Executed
  in sequence, these moves lead to the position that produces the best
  static evaluation score (see below) for the side to play, at the given
  depth (default: 5).

- the score for the final position.

What's implemented:

- NegaScout search algorithm (see [2]).  It's not exactly "principal
  variation search" yet, because we don't keep a history of researched
  positions and their score (which means our evaluation is prone to
  repetitions)

    (pvs game depth α β pline)

  It returns a score for the current position, and the best variant in pline
  (pass a (cons nil nil) and get the list of moves in the `car`).

- Quiescence search -- when NegaScout reaches depth zero, we try all
  capturing moves

    (quies game α β moves pline)

  This is called by pvs when it reaches depth=0.

The static evaluation function is based on [3].  It's symmetrical, in that
it cares for pieces of both sides — for example (static-value game) for the
start position returns zero.  A score bigger than zero means that the
current side to play looks better than the opponent.

The value is calculated by adding up the score for all our pieces, and
subtracting the score for all opponent pieces.  A piece has a material value
(the +MATx+ constants) and a certain score depending on where it's located
on the board (see scores in eval.lisp).

                                   * * *

[1] https://chessprogramming.wikispaces.com/Perft
[2] https://en.wikipedia.org/wiki/Principal_variation_search
[3] https://chessprogramming.wikispaces.com/Simplified+evaluation+function

                                   * * *

(c) Mihai Bazon 2016
License: MIT

Got questions? Let's talk.    http://lisperator.net


Next: , Previous: , Up: Top   [Contents][Index]

2 Systems

The main system appears first, followed by any subsystem dependency.


Previous: , Up: Systems   [Contents][Index]

2.1 queen

Author

Mihai Bazon <mihai.bazon@gmail.com>

License

MIT

Description

Chess utilities: board representation (0x88), move generation, PGN/SAN parser/generator

Dependencies
Source

queen.asd (file)

Components

Next: , Previous: , Up: Top   [Contents][Index]

3 Files

Files are sorted by type and then listed depth-first from the systems components trees.


Previous: , Up: Files   [Contents][Index]

3.1 Lisp


Next: , Previous: , Up: Lisp files   [Contents][Index]

3.1.1 queen.asd

Location

queen.asd

Systems

queen (system)

Packages

queen-config

Exported Definitions

*base-directory* (special variable)


Next: , Previous: , Up: Lisp files   [Contents][Index]

3.1.2 queen/package.lisp

Parent

queen (system)

Location

package.lisp

Packages

queen


Next: , Previous: , Up: Lisp files   [Contents][Index]

3.1.3 queen/stream.lisp

Dependency

package.lisp (file)

Parent

queen (system)

Location

stream.lisp

Internal Definitions

Next: , Previous: , Up: Lisp files   [Contents][Index]

3.1.4 queen/board.lisp

Dependency

stream.lisp (file)

Parent

queen (system)

Location

board.lisp

Exported Definitions
Internal Definitions

Next: , Previous: , Up: Lisp files   [Contents][Index]

3.1.5 queen/pgn.lisp

Dependency

board.lisp (file)

Parent

queen (system)

Location

pgn.lisp

Exported Definitions

Next: , Previous: , Up: Lisp files   [Contents][Index]

3.1.6 queen/eval.lisp

Dependency

pgn.lisp (file)

Parent

queen (system)

Location

eval.lisp

Exported Definitions
Internal Definitions

Previous: , Up: Lisp files   [Contents][Index]

3.1.7 queen/tests.lisp

Dependency

eval.lisp (file)

Parent

queen (system)

Location

tests.lisp

Internal Definitions

Next: , Previous: , Up: Top   [Contents][Index]

4 Packages

Packages are listed by definition order.


Next: , Previous: , Up: Packages   [Contents][Index]

4.1 queen-config

Source

queen.asd

Exported Definitions

*base-directory* (special variable)


Previous: , Up: Packages   [Contents][Index]

4.2 queen

Source

package.lisp (file)

Use List
Exported Definitions
Internal Definitions

Next: , Previous: , Up: Top   [Contents][Index]

5 Definitions

Definitions are sorted by export status, category, package, and then by lexicographic order.


Next: , Previous: , Up: Definitions   [Contents][Index]

5.1 Exported definitions


Next: , Previous: , Up: Exported definitions   [Contents][Index]

5.1.1 Constants

Constant: +bishop+
Package

queen

Source

board.lisp (file)

Constant: +king+
Package

queen

Source

board.lisp (file)

Constant: +knight+
Package

queen

Source

board.lisp (file)

Constant: +pawn+
Package

queen

Source

board.lisp (file)

Constant: +queen+
Package

queen

Source

board.lisp (file)

Constant: +rook+
Package

queen

Source

board.lisp (file)

Constant: +wbishop+
Package

queen

Source

board.lisp (file)

Constant: +white+
Package

queen

Source

board.lisp (file)

Constant: +wking+
Package

queen

Source

board.lisp (file)

Constant: +wknight+
Package

queen

Source

board.lisp (file)

Constant: +wpawn+
Package

queen

Source

board.lisp (file)

Constant: +wqueen+
Package

queen

Source

board.lisp (file)

Constant: +wrook+
Package

queen

Source

board.lisp (file)


Next: , Previous: , Up: Exported definitions   [Contents][Index]

5.1.2 Special variables

Special Variable: *base-directory*
Package

queen-config

Source

queen.asd

Special Variable: *unicode*
Package

queen

Source

board.lisp (file)

Special Variable: +fen-start+
Package

queen

Source

board.lisp (file)


Next: , Previous: , Up: Exported definitions   [Contents][Index]

5.1.3 Macros

Macro: with-move (GAME MOVE &optional QUICK) &body BODY
Package

queen

Source

board.lisp (file)

Macro: with-piece (BOARD POS P &optional ALLOW-EMPTY) &body BODY
Package

queen

Source

board.lisp (file)

Macro: with-row-col (INDEX ROW COL) &body BODY
Package

queen

Source

board.lisp (file)


Next: , Previous: , Up: Exported definitions   [Contents][Index]

5.1.4 Functions

Function: attacked? GAME &optional SIDE INDEX
Package

queen

Source

board.lisp (file)

Function: board-foreach BOARD FN
Package

queen

Source

board.lisp (file)

Function: board-get BOARD INDEX
Package

queen

Source

board.lisp (file)

Setf Expander

(setf board-get) (setf expander)

Setf Expander: (setf board-get) BOARD INDEX VAL
Package

queen

Source

board.lisp (file)

Reader

board-get (function)

Writer

board-set (function)

Function: board-index ROW COL
Package

queen

Source

board.lisp (file)

Function: board-set BOARD INDEX VAL
Package

queen

Source

board.lisp (file)

Setf Expander

(setf board-get) (setf expander)

Function: char-piece P
Package

queen

Source

board.lisp (file)

Function: draw-by-material? GAME
Package

queen

Source

board.lisp (file)

Function: dump-line GAME MOVES
Package

queen

Source

eval.lisp (file)

Function: field-index FIELD
Package

queen

Source

board.lisp (file)

Function: game-board INSTANCE
Function: (setf game-board) VALUE INSTANCE
Package

queen

Source

board.lisp (file)

Function: game-compute-moves GAME
Package

queen

Source

board.lisp (file)

Function: game-enpa INSTANCE
Function: (setf game-enpa) VALUE INSTANCE
Package

queen

Source

board.lisp (file)

Function: game-fullmove INSTANCE
Function: (setf game-fullmove) VALUE INSTANCE
Package

queen

Source

board.lisp (file)

Function: game-halfmove INSTANCE
Function: (setf game-halfmove) VALUE INSTANCE
Package

queen

Source

board.lisp (file)

Function: game-move GAME MOVE &optional QUICK
Package

queen

Source

board.lisp (file)

Function: game-search GAME &optional DEPTH
Package

queen

Source

eval.lisp (file)

Function: game-side INSTANCE
Function: (setf game-side) VALUE INSTANCE
Package

queen

Source

board.lisp (file)

Function: game-state INSTANCE
Function: (setf game-state) VALUE INSTANCE
Package

queen

Source

board.lisp (file)

Function: index-col INDEX
Package

queen

Source

board.lisp (file)

Function: index-field INDEX
Package

queen

Source

board.lisp (file)

Function: index-row INDEX
Package

queen

Source

board.lisp (file)

Function: index-valid? INDEX
Package

queen

Source

board.lisp (file)

Function: is-bishop? P
Package

queen

Source

board.lisp (file)

Function: is-black? P
Package

queen

Source

board.lisp (file)

Function: is-king? P
Package

queen

Source

board.lisp (file)

Function: is-knight? P
Package

queen

Source

board.lisp (file)

Function: is-pawn? P
Package

queen

Source

board.lisp (file)

Function: is-queen? P
Package

queen

Source

board.lisp (file)

Function: is-rook? P
Package

queen

Source

board.lisp (file)

Function: is-white? P
Package

queen

Source

board.lisp (file)

Function: king-index GAME &optional SIDE
Package

queen

Source

board.lisp (file)

Function: move-black? MOVE
Package

queen

Source

board.lisp (file)

Function: move-capture? MOVE
Package

queen

Source

board.lisp (file)

Function: move-captured-index MOVE
Package

queen

Source

board.lisp (file)

Function: move-captured-piece MOVE
Package

queen

Source

board.lisp (file)

Function: move-enpa? MOVE
Package

queen

Source

board.lisp (file)

Function: move-from MOVE
Package

queen

Source

board.lisp (file)

Function: move-oo? MOVE
Package

queen

Source

board.lisp (file)

Function: move-ooo? MOVE
Package

queen

Source

board.lisp (file)

Function: move-piece MOVE
Package

queen

Source

board.lisp (file)

Function: move-promote? MOVE
Package

queen

Source

board.lisp (file)

Function: move-promoted-piece MOVE
Package

queen

Source

board.lisp (file)

Function: move-set-promoted-piece MOVE PROMO
Package

queen

Source

board.lisp (file)

Function: move-side MOVE
Package

queen

Source

board.lisp (file)

Function: move-to MOVE
Package

queen

Source

board.lisp (file)

Function: move-white? MOVE
Package

queen

Source

board.lisp (file)

Function: opp-side? P1 P2
Package

queen

Source

board.lisp (file)

Function: piece-char P
Package

queen

Source

board.lisp (file)

Function: play &key FEN DEPTH
Package

queen

Source

eval.lisp (file)

Function: print-board BOARD &key OUTPUT
Package

queen

Source

board.lisp (file)

Function: same-side? P1 P2
Package

queen

Source

board.lisp (file)


Next: , Previous: , Up: Exported definitions   [Contents][Index]

5.1.5 Generic functions

Generic Function: game-fen GAME
Package

queen

Methods
Method: game-fen (GAME game)
Source

board.lisp (file)

Generic Function: game-parse-san GAME IN &optional MOVES
Package

queen

Methods
Method: game-parse-san (GAME game) (SAN string) &optional MOVES
Source

board.lisp (file)

Method: game-parse-san (GAME game) (IN stream) &optional MOVES
Source

board.lisp (file)

Generic Function: game-san GAME MOVE &optional MOVES
Package

queen

Methods
Method: game-san (GAME game) MOVE &optional MOVES
Source

board.lisp (file)

Generic Function: parse-pgn IN
Package

queen

Methods
Method: parse-pgn (PGN string)
Source

pgn.lisp (file)

Method: parse-pgn (IN stream)
Source

pgn.lisp (file)

Generic Function: reset-from-fen GAME IN
Package

queen

Methods
Method: reset-from-fen (GAME game) (FEN string)
Source

board.lisp (file)

Method: reset-from-fen (GAME game) (IN stream)
Source

board.lisp (file)

Generic Function: reset-game GAME
Package

queen

Methods
Method: reset-game (GAME game)
Source

board.lisp (file)


Next: , Previous: , Up: Exported definitions   [Contents][Index]

5.1.6 Structures

Structure: game ()
Package

queen

Source

board.lisp (file)

Direct superclasses

structure-object (structure)

Direct methods
Direct slots
Slot: board
Type

queen::board

Initform

(queen::make-board)

Readers

game-board (function)

Writers

(setf game-board) (function)

Slot: state
Type

(unsigned-byte 32)

Initform

0

Readers

game-state (function)

Writers

(setf game-state) (function)

Slot: side
Type

queen::piece

Initform

queen:+white+

Readers

game-side (function)

Writers

(setf game-side) (function)

Slot: enpa
Type

(or queen:board-index null)

Readers

game-enpa (function)

Writers

(setf game-enpa) (function)

Slot: fullmove
Type

(unsigned-byte 32)

Initform

0

Readers

game-fullmove (function)

Writers

(setf game-fullmove) (function)

Slot: halfmove
Type

(unsigned-byte 32)

Initform

0

Readers

game-halfmove (function)

Writers

(setf game-halfmove) (function)


Previous: , Up: Exported definitions   [Contents][Index]

5.1.7 Types

Type: board-index ()
Package

queen

Source

board.lisp (file)

Type: move ()
Package

queen

Source

board.lisp (file)


Previous: , Up: Definitions   [Contents][Index]

5.2 Internal definitions


Next: , Previous: , Up: Internal definitions   [Contents][Index]

5.2.1 Constants

Constant: +all-castle+
Package

queen

Source

board.lisp (file)

Constant: +black+
Package

queen

Source

board.lisp (file)

Constant: +black-castle+
Package

queen

Source

board.lisp (file)

Constant: +black-oo+
Package

queen

Source

board.lisp (file)

Constant: +black-ooo+
Package

queen

Source

board.lisp (file)

Constant: +capturable+
Package

queen

Source

board.lisp (file)

Constant: +matb+
Package

queen

Source

eval.lisp (file)

Constant: +matk+
Package

queen

Source

eval.lisp (file)

Constant: +matn+
Package

queen

Source

eval.lisp (file)

Constant: +matp+
Package

queen

Source

eval.lisp (file)

Constant: +matq+
Package

queen

Source

eval.lisp (file)

Constant: +matr+
Package

queen

Source

eval.lisp (file)

Constant: +piece+
Package

queen

Source

board.lisp (file)

Constant: +promotable+
Package

queen

Source

board.lisp (file)

Constant: +white-castle+
Package

queen

Source

board.lisp (file)

Constant: +white-oo+
Package

queen

Source

board.lisp (file)

Constant: +white-ooo+
Package

queen

Source

board.lisp (file)


Next: , Previous: , Up: Internal definitions   [Contents][Index]

5.2.2 Special variables

Special Variable: *b-scores*
Package

queen

Source

eval.lisp (file)

Special Variable: *has-letter-prop*
Package

queen

Source

stream.lisp (file)

Special Variable: *k-scores-ending*
Package

queen

Source

eval.lisp (file)

Special Variable: *k-scores-opening*
Package

queen

Source

eval.lisp (file)

Special Variable: *n-scores*
Package

queen

Source

eval.lisp (file)

Special Variable: *p-scores*
Package

queen

Source

eval.lisp (file)

Special Variable: *perft-pathname*
Package

queen

Source

tests.lisp (file)

Special Variable: *q-scores*
Package

queen

Source

eval.lisp (file)

Special Variable: *r-scores*
Package

queen

Source

eval.lisp (file)

Special Variable: +max-depth+
Package

queen

Source

eval.lisp (file)

Special Variable: +moves-bishop+
Package

queen

Source

board.lisp (file)

Special Variable: +moves-knight+
Package

queen

Source

board.lisp (file)

Special Variable: +moves-qing+
Package

queen

Source

board.lisp (file)

Special Variable: +moves-rook+
Package

queen

Source

board.lisp (file)


Next: , Previous: , Up: Internal definitions   [Contents][Index]

5.2.3 Macros

Macro: defscore NAME &body VALUE
Package

queen

Source

eval.lisp (file)

Macro: with-parse-stream INPUT &body BODY
Package

queen

Source

stream.lisp (file)


Next: , Previous: , Up: Internal definitions   [Contents][Index]

5.2.4 Functions

Function: board-get-rc BOARD ROW COL
Package

queen

Source

board.lisp (file)

Function: board-set-rc BOARD ROW COL PIECE
Package

queen

Source

board.lisp (file)

Function: board-undo-move BOARD MOVE
Package

queen

Source

board.lisp (file)

Function: copy-game INSTANCE
Package

queen

Source

board.lisp (file)

Function: divide GAME DEPTH
Package

queen

Source

board.lisp (file)

Function: game-p OBJECT
Package

queen

Source

board.lisp (file)

Function: get-score PIECE ROW COL &optional ENDING
Package

queen

Source

eval.lisp (file)

Function: init-moves GAME &optional DEPTH
Package

queen

Source

eval.lisp (file)

Function: make-board ()
Package

queen

Source

board.lisp (file)

Function: make-game &key (BOARD BOARD) (STATE STATE) (SIDE SIDE) (ENPA ENPA) (FULLMOVE FULLMOVE) (HALFMOVE HALFMOVE)
Package

queen

Source

board.lisp (file)

Function: make-move FROM TO PIECE CAPTURE ENPA
Package

queen

Source

board.lisp (file)

Function: move-castle? MOVE
Package

queen

Source

board.lisp (file)

Function: move-check? MOVE
Package

queen

Source

board.lisp (file)

Function: move-set-check MOVE
Package

queen

Source

board.lisp (file)

Function: move-value MOVE
Package

queen

Source

eval.lisp (file)

Function: perft GAME DEPTH &optional COUNT-MATES
Package

queen

Source

board.lisp (file)

Function: piece P
Package

queen

Source

board.lisp (file)

Function: piece-side P
Package

queen

Source

board.lisp (file)

Function: piece-unicode P
Package

queen

Source

board.lisp (file)

Function: piece-value PIECE
Package

queen

Source

eval.lisp (file)

Function: pvs GAME START-DEPTH Α Β PLINE
Package

queen

Source

eval.lisp (file)

Function: quies GAME Α Β MOVES PLINE
Package

queen

Source

eval.lisp (file)

Function: quies-moves MOVES
Package

queen

Source

eval.lisp (file)

Function: run-perft-tests &optional DEPTH
Package

queen

Source

tests.lisp (file)

Function: sort-moves MOVES
Package

queen

Source

eval.lisp (file)

Function: static-value GAME
Package

queen

Source

eval.lisp (file)


Previous: , Up: Internal definitions   [Contents][Index]

5.2.5 Types

Type: board ()
Package

queen

Source

board.lisp (file)

Type: piece ()
Package

queen

Source

board.lisp (file)

Type: score ()
Package

queen

Source

eval.lisp (file)


Previous: , Up: Top   [Contents][Index]

Appendix A Indexes


Next: , Previous: , Up: Indexes   [Contents][Index]

A.1 Concepts

Jump to:   F   L   Q  
Index Entry  Section

F
File, Lisp, queen.asd: The queen<dot>asd file
File, Lisp, queen/board.lisp: The queen/board<dot>lisp file
File, Lisp, queen/eval.lisp: The queen/eval<dot>lisp file
File, Lisp, queen/package.lisp: The queen/package<dot>lisp file
File, Lisp, queen/pgn.lisp: The queen/pgn<dot>lisp file
File, Lisp, queen/stream.lisp: The queen/stream<dot>lisp file
File, Lisp, queen/tests.lisp: The queen/tests<dot>lisp file

L
Lisp File, queen.asd: The queen<dot>asd file
Lisp File, queen/board.lisp: The queen/board<dot>lisp file
Lisp File, queen/eval.lisp: The queen/eval<dot>lisp file
Lisp File, queen/package.lisp: The queen/package<dot>lisp file
Lisp File, queen/pgn.lisp: The queen/pgn<dot>lisp file
Lisp File, queen/stream.lisp: The queen/stream<dot>lisp file
Lisp File, queen/tests.lisp: The queen/tests<dot>lisp file

Q
queen.asd: The queen<dot>asd file
queen/board.lisp: The queen/board<dot>lisp file
queen/eval.lisp: The queen/eval<dot>lisp file
queen/package.lisp: The queen/package<dot>lisp file
queen/pgn.lisp: The queen/pgn<dot>lisp file
queen/stream.lisp: The queen/stream<dot>lisp file
queen/tests.lisp: The queen/tests<dot>lisp file

Jump to:   F   L   Q  

Next: , Previous: , Up: Indexes   [Contents][Index]

A.2 Functions

Jump to:   (  
A   B   C   D   F   G   I   K   M   O   P   Q   R   S   W  
Index Entry  Section

(
(setf board-get): Exported functions
(setf game-board): Exported functions
(setf game-enpa): Exported functions
(setf game-fullmove): Exported functions
(setf game-halfmove): Exported functions
(setf game-side): Exported functions
(setf game-state): Exported functions

A
attacked?: Exported functions

B
board-foreach: Exported functions
board-get: Exported functions
board-get-rc: Internal functions
board-index: Exported functions
board-set: Exported functions
board-set-rc: Internal functions
board-undo-move: Internal functions

C
char-piece: Exported functions
copy-game: Internal functions

D
defscore: Internal macros
divide: Internal functions
draw-by-material?: Exported functions
dump-line: Exported functions

F
field-index: Exported functions
Function, (setf game-board): Exported functions
Function, (setf game-enpa): Exported functions
Function, (setf game-fullmove): Exported functions
Function, (setf game-halfmove): Exported functions
Function, (setf game-side): Exported functions
Function, (setf game-state): Exported functions
Function, attacked?: Exported functions
Function, board-foreach: Exported functions
Function, board-get: Exported functions
Function, board-get-rc: Internal functions
Function, board-index: Exported functions
Function, board-set: Exported functions
Function, board-set-rc: Internal functions
Function, board-undo-move: Internal functions
Function, char-piece: Exported functions
Function, copy-game: Internal functions
Function, divide: Internal functions
Function, draw-by-material?: Exported functions
Function, dump-line: Exported functions
Function, field-index: Exported functions
Function, game-board: Exported functions
Function, game-compute-moves: Exported functions
Function, game-enpa: Exported functions
Function, game-fullmove: Exported functions
Function, game-halfmove: Exported functions
Function, game-move: Exported functions
Function, game-p: Internal functions
Function, game-search: Exported functions
Function, game-side: Exported functions
Function, game-state: Exported functions
Function, get-score: Internal functions
Function, index-col: Exported functions
Function, index-field: Exported functions
Function, index-row: Exported functions
Function, index-valid?: Exported functions
Function, init-moves: Internal functions
Function, is-bishop?: Exported functions
Function, is-black?: Exported functions
Function, is-king?: Exported functions
Function, is-knight?: Exported functions
Function, is-pawn?: Exported functions
Function, is-queen?: Exported functions
Function, is-rook?: Exported functions
Function, is-white?: Exported functions
Function, king-index: Exported functions
Function, make-board: Internal functions
Function, make-game: Internal functions
Function, make-move: Internal functions
Function, move-black?: Exported functions
Function, move-capture?: Exported functions
Function, move-captured-index: Exported functions
Function, move-captured-piece: Exported functions
Function, move-castle?: Internal functions
Function, move-check?: Internal functions
Function, move-enpa?: Exported functions
Function, move-from: Exported functions
Function, move-oo?: Exported functions
Function, move-ooo?: Exported functions
Function, move-piece: Exported functions
Function, move-promote?: Exported functions
Function, move-promoted-piece: Exported functions
Function, move-set-check: Internal functions
Function, move-set-promoted-piece: Exported functions
Function, move-side: Exported functions
Function, move-to: Exported functions
Function, move-value: Internal functions
Function, move-white?: Exported functions
Function, opp-side?: Exported functions
Function, perft: Internal functions
Function, piece: Internal functions
Function, piece-char: Exported functions
Function, piece-side: Internal functions
Function, piece-unicode: Internal functions
Function, piece-value: Internal functions
Function, play: Exported functions
Function, print-board: Exported functions
Function, pvs: Internal functions
Function, quies: Internal functions
Function, quies-moves: Internal functions
Function, run-perft-tests: Internal functions
Function, same-side?: Exported functions
Function, sort-moves: Internal functions
Function, static-value: Internal functions

G
game-board: Exported functions
game-compute-moves: Exported functions
game-enpa: Exported functions
game-fen: Exported generic functions
game-fen: Exported generic functions
game-fullmove: Exported functions
game-halfmove: Exported functions
game-move: Exported functions
game-p: Internal functions
game-parse-san: Exported generic functions
game-parse-san: Exported generic functions
game-parse-san: Exported generic functions
game-san: Exported generic functions
game-san: Exported generic functions
game-search: Exported functions
game-side: Exported functions
game-state: Exported functions
Generic Function, game-fen: Exported generic functions
Generic Function, game-parse-san: Exported generic functions
Generic Function, game-san: Exported generic functions
Generic Function, parse-pgn: Exported generic functions
Generic Function, reset-from-fen: Exported generic functions
Generic Function, reset-game: Exported generic functions
get-score: Internal functions

I
index-col: Exported functions
index-field: Exported functions
index-row: Exported functions
index-valid?: Exported functions
init-moves: Internal functions
is-bishop?: Exported functions
is-black?: Exported functions
is-king?: Exported functions
is-knight?: Exported functions
is-pawn?: Exported functions
is-queen?: Exported functions
is-rook?: Exported functions
is-white?: Exported functions

K
king-index: Exported functions

M
Macro, defscore: Internal macros
Macro, with-move: Exported macros
Macro, with-parse-stream: Internal macros
Macro, with-piece: Exported macros
Macro, with-row-col: Exported macros
make-board: Internal functions
make-game: Internal functions
make-move: Internal functions
Method, game-fen: Exported generic functions
Method, game-parse-san: Exported generic functions
Method, game-parse-san: Exported generic functions
Method, game-san: Exported generic functions
Method, parse-pgn: Exported generic functions
Method, parse-pgn: Exported generic functions
Method, reset-from-fen: Exported generic functions
Method, reset-from-fen: Exported generic functions
Method, reset-game: Exported generic functions
move-black?: Exported functions
move-capture?: Exported functions
move-captured-index: Exported functions
move-captured-piece: Exported functions
move-castle?: Internal functions
move-check?: Internal functions
move-enpa?: Exported functions
move-from: Exported functions
move-oo?: Exported functions
move-ooo?: Exported functions
move-piece: Exported functions
move-promote?: Exported functions
move-promoted-piece: Exported functions
move-set-check: Internal functions
move-set-promoted-piece: Exported functions
move-side: Exported functions
move-to: Exported functions
move-value: Internal functions
move-white?: Exported functions

O
opp-side?: Exported functions

P
parse-pgn: Exported generic functions
parse-pgn: Exported generic functions
parse-pgn: Exported generic functions
perft: Internal functions
piece: Internal functions
piece-char: Exported functions
piece-side: Internal functions
piece-unicode: Internal functions
piece-value: Internal functions
play: Exported functions
print-board: Exported functions
pvs: Internal functions

Q
quies: Internal functions
quies-moves: Internal functions

R
reset-from-fen: Exported generic functions
reset-from-fen: Exported generic functions
reset-from-fen: Exported generic functions
reset-game: Exported generic functions
reset-game: Exported generic functions
run-perft-tests: Internal functions

S
same-side?: Exported functions
Setf Expander, (setf board-get): Exported functions
sort-moves: Internal functions
static-value: Internal functions

W
with-move: Exported macros
with-parse-stream: Internal macros
with-piece: Exported macros
with-row-col: Exported macros

Jump to:   (  
A   B   C   D   F   G   I   K   M   O   P   Q   R   S   W  

Next: , Previous: , Up: Indexes   [Contents][Index]

A.3 Variables

Jump to:   *   +  
B   C   E   F   H   S  
Index Entry  Section

*
*b-scores*: Internal special variables
*base-directory*: Exported special variables
*has-letter-prop*: Internal special variables
*k-scores-ending*: Internal special variables
*k-scores-opening*: Internal special variables
*n-scores*: Internal special variables
*p-scores*: Internal special variables
*perft-pathname*: Internal special variables
*q-scores*: Internal special variables
*r-scores*: Internal special variables
*unicode*: Exported special variables

+
+all-castle+: Internal constants
+bishop+: Exported constants
+black+: Internal constants
+black-castle+: Internal constants
+black-oo+: Internal constants
+black-ooo+: Internal constants
+capturable+: Internal constants
+fen-start+: Exported special variables
+king+: Exported constants
+knight+: Exported constants
+matb+: Internal constants
+matk+: Internal constants
+matn+: Internal constants
+matp+: Internal constants
+matq+: Internal constants
+matr+: Internal constants
+max-depth+: Internal special variables
+moves-bishop+: Internal special variables
+moves-knight+: Internal special variables
+moves-qing+: Internal special variables
+moves-rook+: Internal special variables
+pawn+: Exported constants
+piece+: Internal constants
+promotable+: Internal constants
+queen+: Exported constants
+rook+: Exported constants
+wbishop+: Exported constants
+white+: Exported constants
+white-castle+: Internal constants
+white-oo+: Internal constants
+white-ooo+: Internal constants
+wking+: Exported constants
+wknight+: Exported constants
+wpawn+: Exported constants
+wqueen+: Exported constants
+wrook+: Exported constants

B
board: Exported structures

C
Constant, +all-castle+: Internal constants
Constant, +bishop+: Exported constants
Constant, +black+: Internal constants
Constant, +black-castle+: Internal constants
Constant, +black-oo+: Internal constants
Constant, +black-ooo+: Internal constants
Constant, +capturable+: Internal constants
Constant, +king+: Exported constants
Constant, +knight+: Exported constants
Constant, +matb+: Internal constants
Constant, +matk+: Internal constants
Constant, +matn+: Internal constants
Constant, +matp+: Internal constants
Constant, +matq+: Internal constants
Constant, +matr+: Internal constants
Constant, +pawn+: Exported constants
Constant, +piece+: Internal constants
Constant, +promotable+: Internal constants
Constant, +queen+: Exported constants
Constant, +rook+: Exported constants
Constant, +wbishop+: Exported constants
Constant, +white+: Exported constants
Constant, +white-castle+: Internal constants
Constant, +white-oo+: Internal constants
Constant, +white-ooo+: Internal constants
Constant, +wking+: Exported constants
Constant, +wknight+: Exported constants
Constant, +wpawn+: Exported constants
Constant, +wqueen+: Exported constants
Constant, +wrook+: Exported constants

E
enpa: Exported structures

F
fullmove: Exported structures

H
halfmove: Exported structures

S
side: Exported structures
Slot, board: Exported structures
Slot, enpa: Exported structures
Slot, fullmove: Exported structures
Slot, halfmove: Exported structures
Slot, side: Exported structures
Slot, state: Exported structures
Special Variable, *b-scores*: Internal special variables
Special Variable, *base-directory*: Exported special variables
Special Variable, *has-letter-prop*: Internal special variables
Special Variable, *k-scores-ending*: Internal special variables
Special Variable, *k-scores-opening*: Internal special variables
Special Variable, *n-scores*: Internal special variables
Special Variable, *p-scores*: Internal special variables
Special Variable, *perft-pathname*: Internal special variables
Special Variable, *q-scores*: Internal special variables
Special Variable, *r-scores*: Internal special variables
Special Variable, *unicode*: Exported special variables
Special Variable, +fen-start+: Exported special variables
Special Variable, +max-depth+: Internal special variables
Special Variable, +moves-bishop+: Internal special variables
Special Variable, +moves-knight+: Internal special variables
Special Variable, +moves-qing+: Internal special variables
Special Variable, +moves-rook+: Internal special variables
state: Exported structures

Jump to:   *   +  
B   C   E   F   H   S  

Previous: , Up: Indexes   [Contents][Index]

A.4 Data types

Jump to:   B   G   M   P   Q   S   T  
Index Entry  Section

B
board: Internal types
board-index: Exported types

G
game: Exported structures

M
move: Exported types

P
Package, queen: The queen package
Package, queen-config: The queen-config package
piece: Internal types

Q
queen: The queen system
queen: The queen package
queen-config: The queen-config package

S
score: Internal types
Structure, game: Exported structures
System, queen: The queen system

T
Type, board: Internal types
Type, board-index: Exported types
Type, move: Exported types
Type, piece: Internal types
Type, score: Internal types

Jump to:   B   G   M   P   Q   S   T