alphabeta

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Apr 8, 2020 License: GPL-3.0 Imports: 9 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 = 30
	// 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

This section is empty.

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) Children added in v0.3.0

func (g *GameNode) Children() []*GameNode

func (*GameNode) GeneratedPlays added in v0.3.0

func (g *GameNode) GeneratedPlays() []*move.Move

func (*GameNode) Move added in v0.3.0

func (g *GameNode) Move() *move.Move

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

func (s *Solver) Init(movegen movegen.MoveGenerator, game *mechanics.XWordGame)

Init initializes the solver

func (*Solver) RootNode added in v0.3.0

func (s *Solver) RootNode() *GameNode

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) SetSimpleEvaluator

func (s *Solver) SetSimpleEvaluator(i bool)

func (*Solver) Solve

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

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