vulpes

package module
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Jun 18, 2020 License: MIT Imports: 2 Imported by: 0

README

Vulpes GoDoc Build Status Report Card

A Negamax AI with Alpha-Beta pruning implementation. For zero-sum, turn-based, two-player games, written in pure Go.

Vulpes is designed to be both performant and easy to use, and comes built-in with an example Connect Four AI capable of searching to depths 15-20 in a matter of seconds, and with modifications could probably solve the game in a few hours.

How?

Just supply 2 functions to fulfill the Game interface:

// Game describes a two-player, zero-sum, turn-based game.
type Game interface {
	// Children returns the child nodes from this one. If the game is not ended, this must return at least 1 child.
	Children() []Game
	// Evaluate returns an evaluation of the current game state from the perspective of the current player. 'ending' must be one of {LOSS, TIE, WIN, UNFINISHED}. 'heuristic' is only required when ending is UNFINISHED.
	Evaluate() (ending int, heuristic float64)
}

Documentation

Index

Constants

View Source
const (
	// LOSS means the game is over and the current player has lost the game.
	LOSS = iota
	// TIE means the game is over and ended in a tie.
	TIE
	// WIN means the game is over and the current player has won the game.
	WIN
	// UNFINISHED means the game is not yet over.
	UNFINISHED
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Game

type Game interface {
	// Children returns the child nodes from this one. If the game is not ended, this must return at least 1 child.
	Children() []Game
	// Evaluate returns an evaluation of the current game state from the perspective of the current player. 'ending' must be one of {LOSS, TIE, WIN, UNFINISHED}. 'heuristic' is only required when ending is UNFINISHED.
	Evaluate() (ending int, heuristic float64)
}

Game describes a two-player, zero-sum, turn-based game.

func Search(state Game, depth uint, alpha, beta float64) (Game, float64)

Search returns the computed score of a given state.

func SolveGame

func SolveGame(state Game, depth uint) (Game, float64)

SolveGame takes a starting node for the game, and returns the best child node and its score, after searching to the specified depth

Directories

Path Synopsis
games
ttt

Jump to

Keyboard shortcuts

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