negamax

package
v0.9.0 Latest Latest
Warning

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

Go to latest
Published: Apr 6, 2024 License: GPL-3.0 Imports: 25 Imported by: 0

Documentation

Index

Constants

View Source
const (
	EarlyPassBF = 1 << 13
	HashMoveBF  = 1 << 12
	GoingOutBF  = 1 << 11
	// Moves that score more than 256 pts in the endgame may have some
	// sorting issues. Can probably fix this later.
	TilesPlayedBFOffset = 8
)

Bitflags for move estimates.

View Source
const (
	TTExact = 0x01
	TTLower = 0x02
	TTUpper = 0x03
)
View Source
const HugeNumber = int16(32000)
View Source
const MaxLazySMPThreads = 10
View Source
const MaxVariantLength = 25

Variables

View Source
var (
	ErrNoEndgameSolution = errors.New("no endgame solution found")
)
View Source
var GlobalTranspositionTable = &TranspositionTable{}

GlobalTranspositionTable is a singleton instance. Since transposition tables take up a large enough amount of memory, and they're meant to be shared, we only really want to keep one in memory to avoid re-allocation costs.

Functions

This section is empty.

Types

type DebugTableEntry

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

type DebugTranspositionTable

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

type FakeLock

type FakeLock struct{}

func (FakeLock) Lock

func (f FakeLock) Lock()

func (FakeLock) RLock

func (f FakeLock) RLock()

func (FakeLock) RUnlock

func (f FakeLock) RUnlock()

func (FakeLock) Unlock

func (f FakeLock) Unlock()

type PVLine

type PVLine struct {
	Moves [MaxVariantLength]*move.Move
	// contains filtered or unexported fields
}

Credit: MIT-licensed https://github.com/algerbrex/blunder/blob/main/engine/search.go

func (*PVLine) Clear

func (pvLine *PVLine) Clear()

Clear the principal variation line.

func (*PVLine) GetPVMove

func (pvLine *PVLine) GetPVMove() *move.Move

Get the best move from the principal variation line.

func (PVLine) NLBString

func (pvLine PVLine) NLBString() string

func (PVLine) String

func (pvLine PVLine) String() string

Convert the principal variation line to a string.

func (*PVLine) Update

func (pvLine *PVLine) Update(m *move.Move, newPVLine PVLine, score int16)

Update the principal variation line with a new best move, and a new line of best play after the best move.

type Solver

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

func (*Solver) Game added in v0.8.0

func (s *Solver) Game() *game.Game

func (*Solver) Init

func (s *Solver) Init(m movegen.MoveGenerator, game *game.Game) error

Init initializes the solver

func (*Solver) IsSolving added in v0.8.6

func (s *Solver) IsSolving() bool

func (*Solver) Movegen added in v0.8.7

func (s *Solver) Movegen() movegen.MoveGenerator

func (*Solver) QuickAndDirtySolve

func (s *Solver) QuickAndDirtySolve(ctx context.Context, plies, thread int) (int16, []*move.Move, error)

QuickAndDirtySolve is meant for a pre-endgame engine to call this function without having to initialize everything. The caller is responsible for initializations of data structures. It is single-threaded as well.

func (*Solver) SetFirstWinOptim

func (s *Solver) SetFirstWinOptim(w bool)

func (*Solver) SetIterativeDeepening

func (s *Solver) SetIterativeDeepening(id bool)

func (*Solver) SetLogStream added in v0.9.0

func (s *Solver) SetLogStream(l io.Writer)

SetLogStream only prints coherent logs for single-threaded endgames for now.

func (*Solver) SetNegascoutOptim added in v0.9.0

func (s *Solver) SetNegascoutOptim(n bool)

func (*Solver) SetThreads

func (s *Solver) SetThreads(threads int)

func (*Solver) SetTranspositionTableOptim

func (s *Solver) SetTranspositionTableOptim(tt bool)

func (*Solver) Solve

func (s *Solver) Solve(ctx context.Context, plies int) (int16, []*move.Move, error)

type TableEntry

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

16 bytes (entrySize)

type TableLock

type TableLock interface {
	Lock()
	Unlock()
	RLock()
	RUnlock()
}

type TranspositionTable

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

func (*TranspositionTable) Reset

func (t *TranspositionTable) Reset(fractionOfMemory float64, boardDim int)

func (*TranspositionTable) SetMultiThreadedMode

func (t *TranspositionTable) SetMultiThreadedMode()

func (*TranspositionTable) SetSingleThreadedMode

func (t *TranspositionTable) SetSingleThreadedMode()

func (*TranspositionTable) SetZobrist added in v0.8.3

func (t *TranspositionTable) SetZobrist(z *zobrist.Zobrist)

func (*TranspositionTable) Stats added in v0.9.0

func (t *TranspositionTable) Stats() string

func (*TranspositionTable) Zobrist added in v0.8.3

func (t *TranspositionTable) Zobrist() *zobrist.Zobrist

Jump to

Keyboard shortcuts

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