mines

package
v0.1.8 Latest Latest
Warning

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

Go to latest
Published: Sep 3, 2024 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	SetMine  delta = +1
	SetClear delta = -1
)
View Source
const (
	NA solveResult = iota - 2
	Stalled
	Success
)

Variables

View Source
var Log = logrus.New()

Functions

This section is empty.

Types

type GameParams

type GameParams struct {
	Width, Height, MineCount int
	Unique                   bool
}

func (GameParams) ValidateSquare

func (p GameParams) ValidateSquare(x, y int) bool

type GameState

type GameState struct {
	GameParams
	Dead, Won, UsedSolve bool
	Grid                 []bool   /* real mine positions */
	PlayerGrid           GridInfo /* player knowledge */

}

func New

func New(params GameParams, x, y int, r *rand.Rand) (*GameState, error)

func (*GameState) ChordSquare

func (s *GameState) ChordSquare(x, y int)

func (*GameState) FlagSquare

func (s *GameState) FlagSquare(x, y int)

func (*GameState) OpenSquare

func (s *GameState) OpenSquare(x, y int) int

func (*GameState) RevealAll

func (s *GameState) RevealAll()

func (*GameState) RevealMines

func (s *GameState) RevealMines()

type GridInfo

type GridInfo []SquareInfo

func (GridInfo) ToString

func (g GridInfo) ToString(width int) string

type SquareInfo

type SquareInfo int8
const (
	Todo        SquareInfo = -10 // internal
	Question    SquareInfo = -3  // ui
	Unknown     SquareInfo = -2
	Mine        SquareInfo = -1
	CorrectFlag SquareInfo = 64 // post-game-over
	Exploded    SquareInfo = 65
	WrongFlag   SquareInfo = 66
	Unflagged   SquareInfo = 67
)

func (SquareInfo) String

func (s SquareInfo) String() string

Jump to

Keyboard shortcuts

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