BitBully 0.0.78
A fast, perfect-play Connect-4 engine in modern C++
Loading...
Searching...
No Matches
BitBully::TranspositionTable Class Reference

Power-of-two-sized direct-mapped cache for negamax search results. More...

#include <TranspositionTable.h>

Classes

struct  Entry
 One transposition-table slot. More...

Public Member Functions

 TranspositionTable (const int log_2_size=LOG_2_SIZE)
 Allocate a transposition table with 2^log_2_size entries.
Entryget (const Board &b)
 Get the slot associated with b.

Static Public Attributes

static constexpr int LOG_2_SIZE = 20
 Default log2 of the number of entries.

Detailed Description

Power-of-two-sized direct-mapped cache for negamax search results.

The table is indexed by Board::hash() & (size - 1), which compiles down to a single masking operation. A single slot is reserved per index; collisions are simply overwritten. Each slot stores the Board's Board::uid() so that callers can recognise hash collisions.

Definition at line 26 of file TranspositionTable.h.

Constructor & Destructor Documentation

◆ TranspositionTable()

BitBully::TranspositionTable::TranspositionTable ( const int log_2_size = LOG_2_SIZE)
inline

Allocate a transposition table with 2^log_2_size entries.

Parameters
log_2_sizeLog-2 of the number of slots. Use 0 to obtain a single-slot table.

Definition at line 64 of file TranspositionTable.h.

Member Function Documentation

◆ get()

Entry * BitBully::TranspositionTable::get ( const Board & b)
inline

Get the slot associated with b.

The slot is shared with every position that hashes to the same index; callers must inspect Entry::b to verify a hit.

Parameters
bPosition to look up.
Returns
Pointer to the slot. Always non-null and valid for the lifetime of the TranspositionTable.

Definition at line 79 of file TranspositionTable.h.

Here is the call graph for this function:

Member Data Documentation

◆ LOG_2_SIZE

int BitBully::TranspositionTable::LOG_2_SIZE = 20
staticconstexpr

Default log2 of the number of entries.

Definition at line 33 of file TranspositionTable.h.


The documentation for this class was generated from the following file: