Config

class Config

Various constants used across game package. Since they are needed by many modules it made more sense to place them here in their own class, than into one or more other classes.

DEFAULT_ID: Final[int] = 1

Default ID for pieces for situations whe one is needed and must be provided.

MAX_HEIGHT: Final[int] = 4096

Max board height

MAX_WIDTH: Final[int] = 4096

Max board width

NO_ID: Final[int] = -1

Invalid, non-existing ID of a piece. It is used in situations where it would be OK to use None, but this is more specific and has same type as piece IDs have.

NO_POS: Final[int] = -1

Invalid board position

Functions

index_1d(x: int, y: int, board_width: int) int

Converts 2D coordinate to board position index.

index_x(index: int, board_width: int) int

x component of board position index.

index_y(index: int, board_width: int) int

y component of board position index.

index_row(index: int, board_width: int) int

x component of board position index.

index_column(index: int, board_width: int) int

y component of board position index.

is_on_board_2d(x: int, y: int, board_width: int, board_height: int) bool
is_on_board_1d(index: Optional[int], board_width: int, board_height: int) bool