astar

package
v0.14.0 Latest Latest
Warning

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

Go to latest
Published: Jul 26, 2021 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// SKIP skip set attr. used by SetStringTiles
	SKIP = byte('*')
	// PLAIN  point can be arrived to
	PLAIN = byte('.')
	// BLOCK  point can not be arrived to
	BLOCK = byte('x')
	// START  the start point
	START = byte('s')
	// END  the end point
	END = byte('e')
	// PATH  not contains start and end.
	PATH = byte('o')
)

AttributeEnum 属性类型

Variables

This section is empty.

Functions

This section is empty.

Types

type CountCost

type CountCost interface {
	Cost(graph *Graph, tile *Tile, ptile *Tile)
}

CountCost count cost interface

type CountWeight

type CountWeight interface {
	Weight(graph *Graph, tile *Tile, ptile *Tile)
}

CountWeight count weight interface

type Graph

type Graph struct {
	Tiles [][]*Tile
	// contains filtered or unexported fields
}

Graph Astar struct

func New

func New(dimX, dimY int) *Graph

New create astar

func NewWithTiles

func NewWithTiles(tiles string) *Graph

NewWithTiles create astar

func (*Graph) Clear

func (graph *Graph) Clear()

Clear astar 搜索

func (*Graph) GetAttr added in v0.10.3

func (graph *Graph) GetAttr(x, y int) byte

GetAttr get tiles attribute not contain start end info

func (*Graph) GetDimension

func (graph *Graph) GetDimension() (int, int)

GetDimension get dimension info

func (*Graph) GetMultiPath

func (graph *Graph) GetMultiPath() []Path

GetMultiPath get multi the astar path of same cost

func (*Graph) GetPath

func (graph *Graph) GetPath() Path

GetPath the astar path

func (*Graph) GetPathTiles added in v0.10.3

func (graph *Graph) GetPathTiles(path Path) string

GetPathTiles get the string of tiles map info

func (*Graph) GetSinglePathTiles added in v0.10.3

func (graph *Graph) GetSinglePathTiles() string

GetSinglePathTiles get the string of tiles map info

func (*Graph) GetSingleSteps

func (graph *Graph) GetSingleSteps() int

GetSingleSteps result == len(pathlist[0]) - 1

func (*Graph) GetSteps

func (graph *Graph) GetSteps(path Path) int

GetSteps result == len(path) - 1

func (*Graph) GetTarget

func (graph *Graph) GetTarget() (*Point, *Point)

GetTarget start end point

func (*Graph) GetTiles added in v0.10.3

func (graph *Graph) GetTiles() string

GetTiles get astar map info not contain target(start, end)

func (*Graph) GetTilesWithTarget added in v0.10.3

func (graph *Graph) GetTilesWithTarget() string

GetTilesWithTarget get astar map info with target

func (*Graph) Search

func (graph *Graph) Search() bool

Search astar search path

func (*Graph) SearchMulti

func (graph *Graph) SearchMulti() bool

SearchMulti astar search multi path

func (*Graph) SetAttr added in v0.10.3

func (graph *Graph) SetAttr(x, y int, attr byte)

SetAttr set tiles attribute

func (*Graph) SetCountCost

func (graph *Graph) SetCountCost(count CountCost)

SetCountCost use the function different cost

func (*Graph) SetCountWeight

func (graph *Graph) SetCountWeight(count CountWeight)

SetCountWeight use the function different weight

func (*Graph) SetNeighbor

func (graph *Graph) SetNeighbor(neighbor Neighbor)

SetNeighbor use the function different directions

func (*Graph) SetStringTiles

func (graph *Graph) SetStringTiles(strtile string)

SetStringTiles if want some tile do nothing, can use SKIP.

func (*Graph) SetTarget

func (graph *Graph) SetTarget(sx, sy, ex, ey int)

SetTarget start point end point

type Neighbor

type Neighbor interface {
	GetNeighbor(graph *Graph, tile *Tile) []*Tile
}

Neighbor 临近类

type Neighbor4

type Neighbor4 struct {
}

Neighbor4 four direction

func (*Neighbor4) GetNeighbor

func (neighbor *Neighbor4) GetNeighbor(graph *Graph, tile *Tile) []*Tile

GetNeighbor four direction

type Neighbor8

type Neighbor8 struct {
}

Neighbor8 eight direction

func (*Neighbor8) GetNeighbor

func (neighbor *Neighbor8) GetNeighbor(graph *Graph, tile *Tile) []*Tile

GetNeighbor must interface

type Path

type Path []*Tile

Path search astar path

type PathList

type PathList []Path

PathList pathlist

func (PathList) Len

func (pl PathList) Len() int

func (PathList) Less

func (pl PathList) Less(i, j int) bool

func (PathList) Swap

func (pl PathList) Swap(i, j int)

type Point

type Point struct {
	X, Y int
	Attr byte
}

Point point x y

type SimpleCost

type SimpleCost struct {
}

SimpleCost simple cost and no attr

func (*SimpleCost) Cost

func (cost *SimpleCost) Cost(graph *Graph, tile *Tile, ptile *Tile)

Cost ca

type SimpleWeight

type SimpleWeight struct {
}

SimpleWeight simple weight and no attr

func (*SimpleWeight) Weight

func (cost *SimpleWeight) Weight(graph *Graph, tile *Tile, ptile *Tile)

Weight ca

type Tile

type Tile struct {
	X, Y    int
	Cost    int
	Weight  int
	IsCount bool

	Attr byte
}

Tile node

Jump to

Keyboard shortcuts

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