ai

package
v0.0.0-...-7c4a433 Latest Latest
Warning

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

Go to latest
Published: Sep 4, 2019 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MaxEval      int64 = 1 << 30
	MinEval            = -MaxEval
	WinThreshold       = 1 << 29
	Illegal            = -1 << 31
)

Variables

View Source
var DefaultWeights = []Weights{
	defaultWeights,
	defaultWeights,
	defaultWeights,
	defaultWeights,
	defaultWeights,
	defaultWeights,
	defaultWeights6,
	defaultWeights,
	defaultWeights,
}
View Source
var WeightNohat = []float64{
	0,
	-20,
	-40,
	-80,
	-160,
	-320,
	-720,
	-100000,
	0,
	25,
	50,
	100,
	200,
	400,
	10000,
	20000,
	600,
	450,
	300,
	150,
	0,
	20,
	100,
	200,
	600,
	-10,
	-30,
	.003,
	5,
	60,
}
View Source
var WeightNohat6x6 = []float64{
	-7.882857408056033,
	-18.422073883974566,
	-36.0493127331049,
	-79.56604291873225,
	-118.62470509229402,
	-210.29295370964735,
	-517.3034545361437,
	-100000,
	-10,
	10,
	35,
	90,
	160,
	320,
	10000,
	20000,
	758.9873559223424,
	583.7652877392484,
	418.738596952849,
	181.21979073578143,
	0,
	23.88262609962125,
	95.00995285905964,
	226.4340785427944,
	790.8549324342757,
	-10,
	-25,
	0.0028395103346359513,
	5.204139819874648,
	73.41388857816798,
}
View Source
var WeightNohatAdjust = []float64{
	-50,
	-50,
	-50,
	-80,
	-160,
	-320,
	-720,
	0,
	50,
	50,
	50,
	100,
	200,
	400,
	0,
	0,
	600,
	450,
	300,
	150,
	0,
	20,
	100,
	200,
	750,
	-10,
	-30,
	.003,
	5,
	60,
}

var WeightNohat = []float64{0, -20.80992860246264, -39.53973239686991, -81.50246863507586, -155.93079444027765, -289.23796777428583, -614.5346962394407, -100000, 0, 32.30082505350642, 45.12214408862102, 65.61008053136833, 156.60239035239982, 413.263468400728, 10000, 20000, 589.4603825920285, 506.1123687112676, 344.8402195215042, 194.76452676703917, 0, 19.077561948722284, 98.2862020188589, 222.64556765567144, 612.5365342926455, -9.800679880630113, -36.74424919228099, 0.002582788992910993, 5.446911960287178, 72.91389999925025}

Functions

func EvaluateWinner

func EvaluateWinner(m *MinimaxAI, p *tak.Position) int64

func ExplainScore

func ExplainScore(m *MinimaxAI, out io.Writer, p *tak.Position)

Types

type EvaluationFunc

type EvaluationFunc func(m *MinimaxAI, p *tak.Position) int64

func MakeEvaluator

func MakeEvaluator(size int, w *Weights) EvaluationFunc

func MakeNohat

func MakeNohat(size int, w []float64) EvaluationFunc

type FlatScores

type FlatScores struct {
	Hard, Soft int
}

type MinimaxAI

type MinimaxAI struct {
	Diversify int64
	// contains filtered or unexported fields
}

func NewMinimax

func NewMinimax(cfg MinimaxConfig) *MinimaxAI

func (*MinimaxAI) Analyze

func (m *MinimaxAI) Analyze(ctx context.Context, p *tak.Position) ([]tak.Move, int64, Stats)

func (*MinimaxAI) GetMove

func (m *MinimaxAI) GetMove(ctx context.Context, p *tak.Position) tak.Move

func (*MinimaxAI) GetMove1

func (m *MinimaxAI) GetMove1(ctx context.Context, p *tak.Position, spread float64) (tak.Move, float64)

func (*MinimaxAI) GetMovex

func (m *MinimaxAI) GetMovex(ctx context.Context, p *tak.Position, depth int, spread float64) (tak.Move, float64)

type MinimaxConfig

type MinimaxConfig struct {
	Size  int
	Depth int
	Debug int
	Seed  int64

	NoSort     bool
	NoTable    bool
	NoNullMove bool

	Evaluate EvaluationFunc
}

type RandomAI

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

func (*RandomAI) GetMove

func (r *RandomAI) GetMove(ctx context.Context, p *tak.Position) tak.Move

type Stats

type Stats struct {
	Depth     int
	Generated uint64
	Evaluated uint64
	Scout     uint64
	Terminal  uint64
	Visited   uint64

	CutNodes   uint64
	NullSearch uint64
	NullCut    uint64
	Cut0       uint64
	Cut1       uint64
	CutSearch  uint64

	ReSearch uint64

	AllNodes uint64

	TTHits     uint64
	TTShortcut uint64
}

type TakPlayer

type TakPlayer interface {
	GetMove(ctx context.Context, p *tak.Position) tak.Move
}

func NewRandom

func NewRandom(seed int64) TakPlayer

type Weights

type Weights struct {
	TopFlat     int
	EndgameFlat int
	Standing    int
	Capstone    int

	FlatCaptives     FlatScores
	StandingCaptives FlatScores
	CapstoneCaptives FlatScores

	Liberties int

	Groups [8]int
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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