game

package
v0.0.0-...-6d5b5b3 Latest Latest
Warning

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

Go to latest
Published: Jan 14, 2020 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Crosses = x
	Noughts = o
)

Variables

View Source
var (
	EOG         = errors.New("game has come to an end")
	Occupied    = errors.New("the cell is occupied already")
	NoFreeMoves = errors.New("no free moves left")
)

Functions

func ValidateBoard

func ValidateBoard(curr string) bool

func ValidateBoardWithPrevMove

func ValidateBoardWithPrevMove(prev string, curr string) bool

Types

type Board

type Board struct {
	ID     strfmt.UUID
	B      []Cell
	Policy Policy
}

func NewBoard

func NewBoard(game models.Game, policy Policy) *Board

func (*Board) GetCurrentStatus

func (gb *Board) GetCurrentStatus() string

func (*Board) IsEmpty

func (gb *Board) IsEmpty() bool

func (*Board) IsStartOfTheGame

func (gb *Board) IsStartOfTheGame() bool

func (*Board) MakeMachineMove

func (gb *Board) MakeMachineMove(player Cell)

func (*Board) String

func (gb *Board) String() string

func (*Board) ToModelGame

func (gb *Board) ToModelGame() *models.Game

type Cell

type Cell = uint8

type Policy

type Policy interface {
	FindBestMove(board string) int
}

func NewDefaultPolicy

func NewDefaultPolicy(policyFilePath string) (Policy, error)

Jump to

Keyboard shortcuts

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