transposition

package
v0.2.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 29, 2022 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package transposition implements different transposition table strategies to memoize search results.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Entry

type Entry struct {
	Score int
	Depth int
	Flag  Flag
}

Entry holds an entry in the transposition hash table.

type Flag

type Flag int8

Flag represents the score bounds for this entry.

const (
	NoBounds   Flag = iota // NoBounds represents a score with undefined bounds.
	LowerBound             // LowerBound represents a lower bound score.
	UpperBound             // UpperBound represents an upper bound score.
	Exact                  // Exact represents an exact score.
)

type Interface

type Interface interface {
	fmt.Stringer
	Init(size int) error                   // Init initializes the transposition hash table.
	Set(key *chess.Position, value Entry)  // Set adds an entry to the cache for the given position. If an entry already exists for the position, it is replaced. The addition is not guaranteed.
	Get(key *chess.Position) (Entry, bool) // Get returns the entry (if any) and a boolean representing whether the value was found or not.
	Close()                                // Close initiates a graceful shutdown of the transposition table.
}

Interface is the interface implemented by objects that can memoize search results.

type None

type None struct{}

None is the strategy used when we want no transposition hash tables.

func (None) Close

func (None) Close()

Close implements the Interface interface.

func (None) Get

func (None) Get(key *chess.Position) (Entry, bool)

Get implements the Interface interface.

func (None) Init

func (None) Init(size int) error

Init implements the Interface interface.

func (None) Set

func (None) Set(key *chess.Position, value Entry)

Set implements the Interface interface.

func (None) String

func (None) String() string

String implements the Interface interface.

type Ristretto

type Ristretto struct {
	// contains filtered or unexported fields
}

Ristretto implements transposition hash tables using the Ristretto library. It is safe to use concurrently.

func (*Ristretto) Close

func (r *Ristretto) Close()

Close implements the Interface interface.

func (*Ristretto) Get

func (r *Ristretto) Get(key *chess.Position) (Entry, bool)

Get implements the Interface interface.

func (*Ristretto) Init

func (r *Ristretto) Init(size int) error

Init implements the Interface interface.

func (*Ristretto) Set

func (r *Ristretto) Set(key *chess.Position, entry Entry)

Set implements the Interface interface.

func (Ristretto) String

func (Ristretto) String() string

String implements the Interface interface.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL