alphabeta

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Mar 19, 2023 License: GPL-3.0 Imports: 16 Imported by: 0

Documentation

Overview

Package alphabeta implements an endgame solver using depth-limited minimax with alpha-beta pruning.

Index

Constants

View Source
const (
	// Infinity is 10 million.
	Infinity = 10000000
	// TwoPlyOppSearchLimit is how many plays to consider for opponent
	// for the evaluation function.
	TwoPlyOppSearchLimit = 50
	// FutureAdjustment potentially weighs the value of future points
	// less than present points, to allow for the possibility of being
	// blocked. We just make it 1 because our 2-ply evaluation function
	// is reasonably accurate.
	FutureAdjustment = float32(1)
)
View Source
const PerTurnPenalty = float32(0.001)

Variables

View Source
var ErrNoEndgameSolution = errors.New("no endgame solution found")

Functions

This section is empty.

Types

type GameNode added in v0.3.0

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

a game node has to have enough information to allow the game and turns to be reconstructed.

func (*GameNode) Copy added in v0.4.10

func (g *GameNode) Copy() *GameNode

func (*GameNode) CopyFrom added in v0.4.10

func (g *GameNode) CopyFrom(o *GameNode)

func (*GameNode) GetDepth added in v0.4.10

func (g *GameNode) GetDepth() uint8

func (*GameNode) Parent added in v0.3.0

func (g *GameNode) Parent() *GameNode

func (*GameNode) String added in v0.3.0

func (g *GameNode) String() string

type Solver

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

Solver implements the minimax + alphabeta algorithm.

func (*Solver) Init

Init initializes the solver

func (*Solver) RootNode added in v0.3.0

func (s *Solver) RootNode() *GameNode

func (*Solver) SetComplexEvaluator added in v0.4.9

func (s *Solver) SetComplexEvaluator(i bool)

func (*Solver) SetIterativeDeepening

func (s *Solver) SetIterativeDeepening(i bool)

func (*Solver) SetPruningDisabled added in v0.3.0

func (s *Solver) SetPruningDisabled(i bool)

func (*Solver) Solve

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

Solve solves the endgame given the current state of s.game, for the current player whose turn it is in that state.

Jump to

Keyboard shortcuts

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