tictactoe

package
v0.0.0-...-ba10cce Latest Latest
Warning

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

Go to latest
Published: Jul 31, 2023 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Action

type Action struct {
	Player Player
	X      int
	Y      int
}

func NewAction

func NewAction(player Player, x, y int) *Action

type Actor

type Actor struct {
	Player   Player
	TakeTurn func(game gmcts.Game) (gmcts.Action, error)
}

func NewActorAI

func NewActorAI(history history.History, player Player, ephemeral func(message string), concurrency int, timeout time.Duration) *Actor

func NewActorHuman

func NewActorHuman(history history.History, player Player, ephemeral func(message string)) *Actor

type Board

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

func NewBoard

func NewBoard() *Board

func (*Board) Clone

func (b *Board) Clone() *Board

func (*Board) Get

func (b *Board) Get() [][]int

func (*Board) Set

func (b *Board) Set(player Player, x, y int) error

func (*Board) Winner

func (b *Board) Winner() (Player, bool)

type Game

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

func NewGame

func NewGame(history history.History, board *Board, actors ...*Actor) *Game

func (*Game) ApplyAction

func (g *Game) ApplyAction(action gmcts.Action) (gmcts.Game, error)

func (*Game) GetActions

func (g *Game) GetActions() []gmcts.Action

func (*Game) IsTerminal

func (g *Game) IsTerminal() bool

func (*Game) Player

func (g *Game) Player() gmcts.Player

func (*Game) Progress

func (g *Game) Progress() (game.Game, error)

func (*Game) Render

func (g *Game) Render()

func (*Game) Winner

func (g *Game) Winner() string

func (*Game) Winners

func (g *Game) Winners() []gmcts.Player

type Player

type Player int
const (
	PlayerX Player = +1
	PlayerO Player = -1
)

func (Player) String

func (p Player) String() string

Jump to

Keyboard shortcuts

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