Cache Tables

class ai.table.AgingTable(max_age: int, max_size: int)[source]

Bases: ABC, Generic[_Entry, _Value]

Aging table, storing _Entry type entries into a hash table that supports deleting them after their are not accessed for a long time (they aged).
The table might optionally wrap the inner entries and expose a value-based interface instead, depending on whether the _Value type is equal to the _Entry type.
clear() None[source]

Clears the storage from all entries.

flush() None[source]

Ages entries and removes old ones.

items()[source]

Returns all stored items.

Returns:

A set-like object providing a view on the stored items.

Return type:

OrderedDictItemsView

keys()[source]

Returns all stored keys.

Returns:

A set-like object providing a view on the stored keys.

Return type:

OrderedDictKeysView

popitem(last: bool = True) tuple[int, _Value][source]

Removes and returns a (key, value) pair from the storage.

Parameters:

last (bool, optional) – Whether to return pairs in LIFO (True) or FIFO (False) order, defaults to True.

Returns:

_description_

Return type:

tuple[int, _Value]

values()[source]

Returns all stored values.

Returns:

A set-like object providing a view on the stored values.

Return type:

OrderedDictValuesView

class ai.table.AgingTableEntry[source]

Bases: ABC

Table entry for tables that implement deletion of entries based on age.

class ai.table.ScoreTable(max_age: int = 10, max_size: int = 10000000)[source]

Bases: AgingTable[ScoreTableEntry, float]

Score cache table with max size and entry aging.

class ai.table.ScoreTableEntry(score: float)[source]

Bases: AgingTableEntry

Score table entry.

class ai.table.TranspositionTable(max_age: int = 10, max_size: int = 10000000)[source]

Bases: AgingTable[TranspositionTableEntry, TranspositionTableEntry]

Transposition table with max size and entry aging.

class ai.table.TranspositionTableEntry(entry_type: TranspositionTableEntryType, value: float, depth: int, move: Move | None)[source]

Bases: AgingTableEntry

Transposition table entry.

class ai.table.TranspositionTableEntryType(*values)[source]

Bases: IntEnum

Alpha-beta pruning node evaluation type.

EXACT = 1

Exact evaluation was performed for the node.

LOWER_BOUND = 2

The node is a lower bound, the search failed high.

UPPER_BOUND = 3

The node is an upper bound, the search failed low.