Possible actions provided by hint
const ( NoIdea string = "no idea" SetFlag string = "flag" DoUncover string = "uncover" )
API is an interface for APIs communicating with the backend.
type API interface { HostAPI() }
func NewGraphQlAPI(field *Playground) (API, error)
NewGraphQlAPI creates a new GraphQLAPI
Guess represents the probability that a cell contains a bomb. The Probability should have a value between 0.0 and 1.0.
type Guess struct { X int Y int Probability float32 }
Hint represents an Action.
type Hint struct { X int Y int Action string }
Playground contains the a slice of rows of the field.
type Playground struct { Rows []Row Win bool // contains filtered or unexported fields }
▹ Example
func NewPlayground() *Playground
NewPlayground generates a new Playground
func (field *Playground) InRange(x, y int) bool
InRange checks whether the given coordinates are inside the playground. If the position is inside the playground true is returned, otherwise false.
func (field *Playground) Init(sizeX, sizeY, bombs int) error
Init a new playground with the given size. The size of the playground gets passed to the method.
func (field *Playground) ToString() string
ToString generates a string representation of the playground.
func (field *Playground) ToggleFlag(x, y int)
ToggleFlag either sets or unsets a flag.
func (field *Playground) Uncover(x, y int)
Uncover uncovers the field at the given position and sets the CloseBombs variable so it gets visible in the UI
Position contains all required information about the representing position on the playground.
type Position struct { Uncovered bool BombBackend bool Bomb bool Flagged bool CloseBombsBackend int CloseBombs int // contains filtered or unexported fields }
Row contains a slice of positions.
type Row struct { Fields []Position }