grid

package
v0.0.0-...-793ea6c Latest Latest
Warning

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

Go to latest
Published: Oct 24, 2021 License: BSD-3-Clause Imports: 2 Imported by: 0

Documentation

Overview

Package grid implements D* Lite grid-based pathfinding.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Coord

type Coord [2]int

Coord represents an single grid coordinate pair [x, y]

func (Coord) Dist

func (a Coord) Dist(b Coord) float64

Dist returns manhattan distance between two coordinates

func (Coord) Equals

func (a Coord) Equals(b dstarlite.State) bool

Implements dstarlite.State interface.

type Data

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

Data represents an actual grid's data.

func New

func New(width, height int, start, goal Coord) *Data

New returns an new grid data structure given an width and height where each cell indicates the cost of traversal.

If the width or height are <= 0; an panic will occur.

If either start or goal coordinates are outside the coordinates of the grid, an panic will occur.

func (*Data) Cost

func (d *Data) Cost(aa, bb dstarlite.State) float64

Implements dstarlite.Data interface.

func (*Data) Dist

func (d *Data) Dist(aa, bb dstarlite.State) float64

Implements dstarlite.Data interface.

func (*Data) Get

func (d *Data) Get(pos Coord) (value float64, ok bool)

Get returns the attached interface value from the given coordinate on the grid.

If the coordinate is outside of the grid's dimensions, ok will equal false.

func (*Data) Goal

func (d *Data) Goal() Coord

Goal returns the goal coordinate, as it is currently.

func (*Data) Plan

func (d *Data) Plan() (path []Coord)

Plan recomputes the lowest cost path through the map, taking into account changes in start location and edge costs.

If no path is found, nil is returned.

func (*Data) Pred

func (d *Data) Pred(s dstarlite.State) []dstarlite.State

Implements dstarlite.Data interface.

func (*Data) Set

func (d *Data) Set(pos Coord, value float64)

Set changes the cost of traversal to the given coordinate on the grid to the specified value.

If the coordinate is outside of the grid's dimensions, an panic will occur.

func (*Data) Size

func (d *Data) Size() (width, height int)

Size returns the width and height of the grid.

func (*Data) Start

func (d *Data) Start() Coord

Start returns the start coordinate, as it is currently.

func (*Data) Succ

func (d *Data) Succ(s dstarlite.State) []dstarlite.State

Implements dstarlite.Data interface.

func (*Data) UpdateStart

func (d *Data) UpdateStart(start Coord)

UpdateStart updates the starting position. This can be used to move a long the path efficiently.

Jump to

Keyboard shortcuts

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