Enums

This module has the enumeration classes.

class enums.Color(value)[source]

Represents color as a boolean.

Color

Value

WHITE

True

BLACK

False

class enums.Numbers(value)[source]

An enumeration.

class enums.Positions(value)[source]

Represents the “magic” numbers of a chess board.

Numbers

ALGEBRIAC

Dictionary of two-character notation string, 'a1', to two-item tuple, (97, 1).

CASTLING

Dictionary of king end position (two-item tuple) and nearest rooks (tuple of two-item tuples).

CASTLING_FILE_END

File number for queen-side position of rook.

FILE_NUMBERS

List of unicode numbers of the file letters from ‘a’ through ‘h’.

FILE_RANK

Dictionary of two-item tuple, (97, 1), to two-character notation string, 'a1'.

POSITIONS

List of two-item tuples for all positions.

class enums.PieceType(value)[source]

Represents the names of the pieces.

  • BISHOP

  • KING

  • KNIGHT

  • PAWN

  • ROOK

  • QUEEN

class enums.Rank(value)[source]

Represents the starting ranks for specific pieces.

Rank

Value

HIGH

(1, 8)

PAWN

(2, 7)

This class inherits from both tuple and Enum. The tuple class allows access to the assigned value via the in statement without having to add .value statement to the end.

>>> enums.Rank.HIGH
<Rank.HIGH: (1, 8)>
>>> enums.Rank.HIGH.value
(1, 8)
>>> 8 in enums.Rank.HIGH
True
>>> 7 in enums.Rank.HIGH
False
class enums.SetOrder(value)[source]

Represents the set order for high and pawn pieces on the board.

Rank

Value

HIGH

Rook, Knight, Bishop, Queen, King, Bishop, Knight, Rook

PAWN

Pawn, Pawn, Pawn, Pawn, Pawn, Pawn, Pawn, Pawn

class enums.Status(value)[source]

Represents move status.

  • CAPTURE

  • CASTLING

  • CHECK

  • CHECKMATE

  • EN_PASSANT

  • INVALID

  • VALID