arena

package
v0.0.0-...-9d97bcf Latest Latest
Warning

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

Go to latest
Published: Jan 7, 2024 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrorInvalidArenaNoStart        = errors.New("invalid map: no start cell found")
	ErrorInvalidArenaNoFinish       = errors.New("invalid map: no finish cell found")
	ErrorInvalidArenaMultipleStart  = errors.New("invalid map: multiple start cells found")
	ErrorInvalidArenaMultipleFinish = errors.New("invalid map: multiple finish cells found")
)
View Source
var (
	SymbolNonWalkable = "#"
	SymbolWalkable    = "."
	SymbolStart       = "S"
	SymbolFinish      = "F"
	SymbolPath        = "@"
)

Functions

This section is empty.

Types

type Arena

type Arena struct {
	// contains filtered or unexported fields
}

func Parse

func Parse(input string) (*Arena, error)

func (*Arena) CellTypeForCoordinate

func (m *Arena) CellTypeForCoordinate(c Coordinate) CellType

func (*Arena) FinishCoordinate

func (m *Arena) FinishCoordinate() Coordinate

func (*Arena) NeighboursOfCoordinate

func (m *Arena) NeighboursOfCoordinate(c Coordinate) []Coordinate

func (*Arena) Render

func (m *Arena) Render(w io.Writer)

render the map into the writer

func (*Arena) RenderWithPath

func (m *Arena) RenderWithPath(w io.Writer, path []Coordinate)

func (*Arena) RenderWithVisited

func (m *Arena) RenderWithVisited(w io.Writer, visited []Coordinate)

func (*Arena) StartCoordinate

func (m *Arena) StartCoordinate() Coordinate

type CellType

type CellType uint8
const (
	CellTypeUndefined CellType = iota
	CellTypeWalkable
	CellTypeNonWalkable
	CellTypeStart
	CellTypeFinish
	CellTypePath
)

func (CellType) String

func (t CellType) String() string

type Coordinate

type Coordinate struct {
	// contains filtered or unexported fields
}

func NewCoordinate

func NewCoordinate(x, y int) Coordinate

func (Coordinate) DistanceTo

func (c Coordinate) DistanceTo(t Coordinate) int

func (Coordinate) East

func (c Coordinate) East() Coordinate

func (Coordinate) North

func (c Coordinate) North() Coordinate

func (Coordinate) South

func (c Coordinate) South() Coordinate

func (Coordinate) West

func (c Coordinate) West() Coordinate

Jump to

Keyboard shortcuts

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