Documentation ¶
Overview ¶
Package transpositiontable implements a transposition table (cache) data structure and functionality for a chess engine search. The TtTable class is not thread safe and needs to be synchronized externally if used from multiple threads. Is especially relevant for Resize and Clear which should not be called in parallel while searching.
Index ¶
- Constants
- type TtEntry
- type TtStats
- type TtTable
- func (tt *TtTable) AgeEntries()
- func (tt *TtTable) Clear()
- func (tt *TtTable) GetEntry(key position.Key) *TtEntry
- func (tt *TtTable) Hashfull() int
- func (tt *TtTable) Len() uint64
- func (tt *TtTable) Probe(key position.Key) *TtEntry
- func (tt *TtTable) Put(key position.Key, move Move, depth int8, value Value, valueType ValueType, ...)
- func (tt *TtTable) Resize(sizeInMByte int)
- func (tt *TtTable) String() string
Constants ¶
const ( // TtEntrySize is the size in bytes for each TtEntry TtEntrySize = 16 // 16 bytes // MaxSizeInMB maximal memory usage of tt MaxSizeInMB = 65_536 )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type TtEntry ¶
type TtEntry struct { Key position.Key // 64-bit Zobrist Key Move Move // 32-bit Move and value Depth int8 // 7-bit 0-127 0b01111111 Age int8 // 3-bit 0-7 0b00000111 0=used 1=generated, not used, >1 older generation Type ValueType // 2-bit None, Exact, Alpha (upper), Beta (lower) MateThreat bool // 1-bit }
TtEntry struct is the data structure for each entry in the transposition table. Each entry has 16-bytes (128-bits)
type TtStats ¶
type TtStats struct {
// contains filtered or unexported fields
}
TtStats holds statistical data on tt usage
type TtTable ¶
type TtTable struct { Stats TtStats // contains filtered or unexported fields }
TtTable is the actual transposition table object holding data and state. Create with NewTtTable()
func NewTtTable ¶
NewTtTable creates a new TtTable with the given number of bytes as a maximum of memory usage. actual size will be determined by the number of elements fitting into this size which need to be a power of 2 for efficient hashing/addressing via bit masks
func (*TtTable) AgeEntries ¶
func (tt *TtTable) AgeEntries()
AgeEntries ages each entry in the tt Creates a number of go routines with processes each a certain slice of data to process
func (*TtTable) Clear ¶
func (tt *TtTable) Clear()
Clear clears all entries of the tt The TtTable class is not thread safe and needs to be synchronized externally if used from multiple threads. Is especially relevant for Resize and Clear which should not be called in parallel while searching.
func (*TtTable) GetEntry ¶
GetEntry returns a pointer to the corresponding tt entry. Given key is checked against the entry's key. When equal pointer to entry will be returned. Otherwise nil will be returned. Does not change statistics.
func (*TtTable) Hashfull ¶
Hashfull returns how full the transposition table is in permill as per UCI
func (*TtTable) Probe ¶
Probe returns a pointer to the corresponding tt entry or nil if it was not found. Decreases TtEntry.Age by 1
func (*TtTable) Put ¶
func (tt *TtTable) Put(key position.Key, move Move, depth int8, value Value, valueType ValueType, mateThreat bool)
Put an TtEntry into the tt. Encodes value into the move.