player

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Feb 4, 2022 License: GPL-3.0 Imports: 8 Imported by: 0

Documentation

Overview

Package player is an automatic player of Crossword Game, using various forms of AI.

Index

Constants

View Source
const (
	// Infinity is a shockingly large number.
	Infinity = 10000000.0
)

Variables

This section is empty.

Functions

func GenBestStaticTurn

func GenBestStaticTurn(game *game.Game, movegen movegen.MoveGenerator,
	aiplayer AIPlayer, playerIdx int) *move.Move

GenBestStaticTurn is a useful utility function for sims and autoplaying.

Types

type AIPlayer

type AIPlayer interface {
	// AssignEquity will assign equities to the given moves.
	AssignEquity([]*move.Move, *board.GameBoard, *alphabet.Bag, *alphabet.Rack)
	// BestPlay picks the best play from the list of plays.
	BestPlay([]*move.Move) *move.Move
	// TopPlays picks the top N plays from the list of plays.
	TopPlays([]*move.Move, int) []*move.Move

	Strategizer() strategy.Strategizer

	GetBotType() pb.BotRequest_BotCode
}

AIPlayer describes an artificial player. It uses a Strategizer to decide on moves to make.

type RawEquityPlayer

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

RawEquityPlayer plays by equity only and does no look-ahead / sim.

func NewRawEquityPlayer

func NewRawEquityPlayer(s strategy.Strategizer, botType pb.BotRequest_BotCode) *RawEquityPlayer

func (*RawEquityPlayer) AssignEquity

func (p *RawEquityPlayer) AssignEquity(moves []*move.Move, board *board.GameBoard,
	bag *alphabet.Bag, oppRack *alphabet.Rack)

AssignEquity uses the strategizer to assign an equity to every move. This is the sole module dedicated to assigning equities. (Perhaps it should be named something else?)

func (*RawEquityPlayer) BestPlay

func (p *RawEquityPlayer) BestPlay(moves []*move.Move) *move.Move

BestPlay picks the highest equity play. It is assumed that these plays have already been assigned an equity but are not necessarily sorted.

func (*RawEquityPlayer) GetBotType

func (p *RawEquityPlayer) GetBotType() pb.BotRequest_BotCode

func (*RawEquityPlayer) Strategizer

func (p *RawEquityPlayer) Strategizer() strategy.Strategizer

func (*RawEquityPlayer) TopPlays

func (p *RawEquityPlayer) TopPlays(moves []*move.Move, n int) []*move.Move

TopPlays sorts the plays by equity and returns the top N. It assumes that the equities have already been assigned.

Jump to

Keyboard shortcuts

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