maze

package
v0.0.0-...-cb1c626 Latest Latest
Warning

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

Go to latest
Published: Aug 23, 2022 License: AGPL-3.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Cell

type Cell struct {
	NorthRoute bool `json:"northRoute"`
	WestRoute  bool `json:"westRoute"`
	Visited    bool `json:"-"`
}

cell is an individual part of a maze with a route north, west, and a visited flag a "route" north, representing lack of a wall, is used instead of a wall=true as the default type for a bool is false so by default there is no route from that cell. This saves constructing cells with true values.

type Maze

type Maze struct {
	Cells [][]Cell `json:"cells"`
}

maze represents the entire maze

func Load

func Load(s string) (Maze, error)

Load creates a Maze from a JSON string

func New

func New(width, height int, start Position) (Maze, error)

New creates a new Maze problem

func (*Maze) JSON

func (m *Maze) JSON() string

JSON returns a representation of the maze in JSON

type Position

type Position struct {
	X int
	Y int
}

type Route

type Route []Position

func (*Route) IsEmpty

func (s *Route) IsEmpty() bool

func (*Route) Pop

func (s *Route) Pop() Position

func (*Route) Push

func (s *Route) Push(p Position)

Jump to

Keyboard shortcuts

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