Documentation ¶
Index ¶
- Variables
- func CachedGenerateWiningPositions(rows, cols, winseq int) [][]Move
- func GameRules(rows int, cols int, length int) (int, int, int)
- func GenerateWiningPositions(inline int, rows, columns int) [][]Move
- func IsGameFinished(x State) bool
- func NewMachine() *machine.Machine[Command, State]
- func NewMachineWithState(s State) *machine.Machine[Command, State]
- func PrintGameRC(w io.Writer, movesTaken map[Move]PlayerID, rows, cols int)
- func ToMovesTaken(moves []Move) map[Move]PlayerID
- func Wining() [][]Move
- func Wining3x3() [][]Move
- type CreateGameCMD
- type GameEndWithDraw
- type GameEndWithWin
- type GameProgress
- type GameWaitingForPlayer
- type GiveUpCMD
- type JoinGameCMD
- type Move
- type MoveCMD
- type PlayerID
- type StartGameCMD
- type TicTacToeBaseState
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ErrGameAlreadyStarted = errors.New("game already started") ErrGameHasAllPlayers = errors.New("game is not waiting for player") ErrUniquePlayers = errors.New("game can not have same player twice") ErrGameNotInProgress = errors.New("cannot move, game is not in progress") ErrNotYourTurn = errors.New("not your turn") ErrPositionTaken = errors.New("position is taken") ErrGameFinished = errors.New("game is finished") ErrInputInvalid = errors.New("input is invalid") )
Functions ¶
func GenerateWiningPositions ¶
func IsGameFinished ¶
func IsGameFinished(x State) bool
func NewMachine ¶
func NewMachineWithState ¶
func ToMovesTaken ¶
Types ¶
type CreateGameCMD ¶
Commands that trigger state transitions.
type GameEndWithDraw ¶
type GameEndWithDraw struct { TicTacToeBaseState MovesTaken map[Move]PlayerID }
State of the game. Commands are used to update or change state
type GameEndWithWin ¶
type GameEndWithWin struct { TicTacToeBaseState Winner PlayerID WiningSequence []Move MovesTaken map[Move]PlayerID }
State of the game. Commands are used to update or change state
type GameProgress ¶
type GameProgress struct { TicTacToeBaseState NextMovePlayerID Move MovesTaken map[Move]PlayerID MovesOrder []Move }
State of the game. Commands are used to update or change state
type GameWaitingForPlayer ¶
type GameWaitingForPlayer struct {
TicTacToeBaseState
}
State of the game. Commands are used to update or change state
type GiveUpCMD ¶
type GiveUpCMD struct {
PlayerID PlayerID
}
Commands that trigger state transitions.
type JoinGameCMD ¶
type JoinGameCMD struct{ SecondPlayerID PlayerID }
Commands that trigger state transitions.
type PlayerID ¶
type PlayerID = string
Value objects, values that restrict cardinality of the state.
Click to show internal directories.
Click to hide internal directories.