pathing

package
v0.0.0-...-117f852 Latest Latest
Warning

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

Go to latest
Published: Jun 20, 2022 License: GPL-3.0 Imports: 1 Imported by: 3

Documentation

Overview

This file is a part of goRo, a library for writing roguelikes. Copyright (C) 2019 Ketchetwahmeegwun T. Southall

This program is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.

Index

Constants

View Source
const (
	MaximumCost = math.MaxUint32
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Algorithm

type Algorithm uint8

Algorithm represents a pathing algorithm

const (
	AlgorithmNone Algorithm = iota
	AlgorithmAStar
)

Our default algorithms

type NodeAStar

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

type Path

type Path interface {
	Compute(oX, oY int, tX, tY int) []Step
	SetHeuristicsFunc(func(x0, y0 int, x1, y1 int) float64)
	AllowDiagonals(v bool)
}

Path is our interface for paths.

func NewPathAStarFromFunc

func NewPathAStarFromFunc(width, height int, calcFunc func(int, int) uint32) Path

func NewPathAStarFromMap

func NewPathAStarFromMap(pathMap PathMap) Path

func NewPathFromFunc

func NewPathFromFunc(width, height int, calcFunc func(x int, y int) (cost uint32), algo Algorithm) Path

NewPathFromFunc returns a new pathing map with movement costs calculated from calcFunc.

func NewPathFromMap

func NewPathFromMap(pathMap PathMap, algo Algorithm) Path

NewPathFromMap returns a new pathing map from the given pathMap interface.

type PathAStar

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

PathAStar represents a pathing structure for the A* algorithm.

func (*PathAStar) AllowDiagonals

func (p *PathAStar) AllowDiagonals(v bool)

AllowDiagonals sets if diagonal movement is allowed.

func (*PathAStar) Compute

func (p *PathAStar) Compute(oX, oY int, tX, tY int) (steps []Step)

func (*PathAStar) Resize

func (p *PathAStar) Resize(width, height int)

Resize resizes the given MapBase to the provided size.

func (*PathAStar) SetHeuristicsFunc

func (p *PathAStar) SetHeuristicsFunc(f func(x0, y0 int, x1, y1 int) float64)

type PathMap

type PathMap interface {
	Width() int
	Height() int
	CostAt(x, y int) uint32
}

type Step

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

func (Step) X

func (s Step) X() int

func (Step) Y

func (s Step) Y() int

Jump to

Keyboard shortcuts

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