game

package module
v0.0.0-...-a8f892f Latest Latest
Warning

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

Go to latest
Published: May 8, 2023 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

View Source
const BOARD_SIDE_LENGTH = 3
View Source
const MaxInt = int(MaxUint >> 1)
View Source
const MaxUint = ^uint(0)

Max val constants

View Source
const MinInt = -MaxInt - 1
View Source
const MinUint = 0

Variables

This section is empty.

Functions

This section is empty.

Types

type Board

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

func NewBoard

func NewBoard() *Board

func (*Board) CheckForWin

func (board *Board) CheckForWin() square

func (*Board) CheckGoodMove

func (board *Board) CheckGoodMove(i, j int) bool

func (*Board) Copy

func (board *Board) Copy() *Board

Copy a board

func (*Board) Evaluate

func (board *Board) Evaluate() int

Evaluate a board by checking for a win and mapping the value to a score

func (*Board) IsFull

func (board *Board) IsFull() bool

func (*Board) MakeMove

func (board *Board) MakeMove(i, j int, s square)

func (Board) String

func (b Board) String() string

type BotPlayer

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

func NewBotPlayer

func NewBotPlayer(player int, debug bool) *BotPlayer

func (*BotPlayer) GetMove

func (p *BotPlayer) GetMove(board *Board) (int, int)

func (*BotPlayer) IsHuman

func (p *BotPlayer) IsHuman() bool

type Game

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

func NewGame

func NewGame(crossPlayer, noughtPlayer *Player) *Game

func (*Game) Loop

func (g *Game) Loop() GameResult

func (*Game) SwitchPlayer

func (g *Game) SwitchPlayer()

Switch the player

type GameResult

type GameResult int
const (
	Cross  GameResult = iota
	Draw   GameResult = iota
	Nought GameResult = iota
)

type HumanPlayer

type HumanPlayer struct{}

func (*HumanPlayer) GetMove

func (p *HumanPlayer) GetMove(board *Board) (int, int)

func (*HumanPlayer) IsHuman

func (p *HumanPlayer) IsHuman() bool

type Player

type Player interface {
	GetMove(board *Board) (int, int)
	IsHuman() bool
}

type RandomPlayer

type RandomPlayer struct{}

func (*RandomPlayer) GetMove

func (p *RandomPlayer) GetMove(board *Board) (int, int)

func (*RandomPlayer) IsHuman

func (p *RandomPlayer) IsHuman() bool

Jump to

Keyboard shortcuts

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