maze

package
v0.0.0-...-884cce2 Latest Latest
Warning

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

Go to latest
Published: Dec 25, 2022 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Plain = Kind(iota)
	Wall
	Water
	Start
	Goal
)

Variables

View Source
var Costs = map[Kind]int{
	Plain: 1,
	Water: 5,
}
View Source
var Kinds = map[rune]Kind{
	' ': Plain,
	'#': Wall,
	'w': Water,
	'S': Start,
	'G': Goal,
}
View Source
var Symbols = map[Kind]rune{
	Plain: ' ',
	Wall:  '#',
	Water: 'w',
	Start: 'S',
	Goal:  'G',
}

Functions

This section is empty.

Types

type Kind

type Kind rune

type Node

type Node struct {
	Kind
	Pos
	Neighbors []*Node
	Visited   int
}

func (*Node) Cost

func (n *Node) Cost() int

func (*Node) EachNeighbor

func (n *Node) EachNeighbor(f func(*Node))

func (*Node) Heuristic

func (n *Node) Heuristic(to *Node) int

func (*Node) String

func (n *Node) String() string

type World

type World struct {
	Width, Height int
	Map           []Node
}

func NewWorld

func NewWorld(input string) *World

NewWorld is the World constructor. Takes a serialized World as input.

func (*World) At

func (w *World) At(x, y int) *Node

func (*World) FindAll

func (w *World) FindAll(kind Kind) (nodes []*Node)

func (*World) FindOne

func (w *World) FindOne(kind Kind) *Node

func (*World) RenderPath

func (w *World) RenderPath(path []*Node) string

RenderPath serializes a path in a human readable way.

Jump to

Keyboard shortcuts

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