Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var (
ErrNoMoves = errors.New("vi: no moves are possible from the given position")
)
Functions ¶
func Game ¶
Makes two VIs play against each other, updating the board state through the returned channel. The channel is closed when the game is over. In this case, the winner of the game can be determined by which player is set to make the next move. That is, if White is the active player when the channel closes, that means that White had no moves left and Black is the winner.
Types ¶
type Arrow ¶
type Arrow struct {
// contains filtered or unexported fields
}
Arrow is a program that was created by Martin Müller and Theodore Tegos, described in their paper "Experiments in Computer Amazons." They describe two versions of Arrow, one which is non-selective (no move ordering) and another which is selective (a beam search where moves are ordered by the same evaluation function used for leaf nodes). This implementation is non-selective. That is, it's just normal alpha-beta search which uses QMinDist to evaluate leaf nodes.
func (*Arrow) AllAnalytics ¶
type EDI ¶
type EDI struct {
// contains filtered or unexported fields
}
EDI is the flagship VI for this project. At the time of writing it uses alpha-beta search with the History Heuristic for move ordering and the KMinDist function for leaf node evaluation.
func (*EDI) AllAnalytics ¶
type Random ¶
type Random struct{}
This VI picks moves completely at random.
func (*Random) AllAnalytics ¶
type Sparrow ¶
type Sparrow struct {
// contains filtered or unexported fields
}
Sparrow uses a simple alpha-beta search with the k-mindist evaluation function and no move ordering.
func (*Sparrow) AllAnalytics ¶
type VI ¶
type VI interface {
// Determines the best move and returns it within the given time limit.
//
// If an error is returned, it will be [ErrNoMoves].
Consult(board state.Board, timeLimit time.Duration) (state.Move, error)
// Returns the analytics from the most recent call to [Consult]. The
// specific fields depends on the VI model. E.g., a VI using alpha-beta
// might describe its effective branching factor and the number of cutoffs,
// while a Monte Carlo model would have entirely different metrics. If
// [Consult] has not yet been successfully called, this function will
// return nil.
Analytics() map[string]float64
// Returns all analytics from past calls to ConsultWithAnalytics, ordered
// so that the last element is from the most recent call. This value will
// be a slice of the same type that GetAnalytics() returns.
AllAnalytics() []map[string]float64
// Returns a string that represents the VI's model.
Id() string
}
We use VI, short for "virtual intelligence," to refer to a program that can recommend a move from a given board state within a certain amount of time. In contrast with a search function, which is defined to be stateless, a VI may "remember" certain things between searches.
The term VI is borrowed from a videogame: https://masseffect.fandom.com/wiki/Virtual_Intelligence. Traditionally we would call such a program "AI," but that term has been diluted in recent years.
func NewSparrow ¶
func NewSparrow() VI