Versions in this module Expand all Collapse all v0 v0.2.0 Jun 29, 2026 Changes in this version + var ErrInvalidAction = errors.New("invalid action") + var ErrInvalidBoard = errors.New("board must be greater than 3x3 and place (NxM)/2 mines") + var ErrInvalidSize = errors.New("size must be a positive number") + var ErrInvalidTotalMines = errors.New("total mines must be a positive number") + var ErrOutOfBounds = errors.New("coordinates out of bounds") + type Action struct + Kind ActionKind + X int + Y int + func NewAction(kind ActionKind, x, y int) Action + func ParseAction(s string) (*Action, error) + func ParseActions(s string) ([]*Action, error) + func (a Action) String() string + type ActionKind byte + const ActionRevealCell + const ActionToggleFlag + func (a ActionKind) String() string + type Board struct + func NewBoard(width, height int) *Board + func (b *Board) AdjacentCells(x, y int) iter.Seq[*Cell] + func (b *Board) Cell(x, y int) *Cell + func (b *Board) Cells() iter.Seq[*Cell] + func (b *Board) Height() int + func (b *Board) InBounds(x, y int) bool + func (b *Board) Width() int + type Cell struct + AdjacentMines uint8 + IsFlagged bool + IsMine bool + IsRevealed bool + X int + Y int + func NewCell(x, y int) *Cell + func (c *Cell) IsEmpty() bool + func (c *Cell) Reveal() + func (c *Cell) ToggleFlag() + type CellSymbol = byte + const SymbolBreakln + const SymbolEmpty + const SymbolFlag + const SymbolMine + const SymbolUnrevealed + type CellView struct + Flagged bool + Revealed bool + Value int + X int + Y int + func (c *CellView) UnmarshalJSON(data []byte) error + func (c CellView) MarshalJSON() ([]byte, error) + type Game struct + func NewGame(width, height, minesTotal int) (*Game, error) + func NewGameSeeded(seed uint64, width, height, minesTotal int) (*Game, error) + func (g *Game) Board() *Board + func (g *Game) Bytes() []byte + func (g *Game) FlagsPlaced() int + func (g *Game) Handle(act *Action) error + func (g *Game) Mines() int + func (g *Game) Rand() *rand.Rand + func (g *Game) Render(w io.Writer) (err error) + func (g *Game) RevealCell(startX, startY int) error + func (g *Game) Seed() uint64 + func (g *Game) Start(x, y int) error + func (g *Game) Status() GameStatus + func (g *Game) String() string + func (g *Game) ToJSON() ([]byte, error) + func (g *Game) ToggleFlag(x, y int) error + func (g *Game) View() GameView + type GameStatus uint8 + const StatusLost + const StatusPlaying + const StatusUnknown + const StatusWon + func (gs GameStatus) String() string + type GameView struct + Board [][]CellView + Height int + MinesLeft int + Status string + Width int + func (g *GameView) UnmarshalJSON(data []byte) error + func (g GameView) MarshalJSON() ([]byte, error) v0.1.0 Jun 27, 2026