Documentation
¶
Overview ¶
Package testmap is the maps the tests and the benchmarks of package hpastar search: square maps of cells generated from a seed, rough ground and walls in short lines, a torus or not, and the small grids of costs the A* engine's paths are pinned on.
Index ¶
- Constants
- func Dicts(size int) map[string]func() dict.Dict[Point]
- func EightWays(grid [][]float64) graph.Transitions[Point]
- func FourWays(costWeight float64, grid [][]float64) graph.Transitions[Point]
- func Identity(s int) int
- func Manhattan(p, g Point) float64
- func Octile(p, g Point) float64
- func PathCost(grid [][]float64, path []Point) float64
- func Queries(grid [][]float64, seed uint64) [][2]Point
- func RandomGrid(size int, seed uint64) [][]float64
- func SkipLarge(tb testing.TB, size int)
- func Splitmix(seed uint64) func() float64
- func UniformGrid(size int) [][]float64
- func WalkCost(steps graph.Transitions[int], route []int) (float64, bool)
- func WalledGrid(size int) [][]float64
- type Map
- func (m *Map) AnyOpen(rnd func() float64) int
- func (m *Map) Apart(rnd func() float64, from, n int, near, far float64) []int
- func (m *Map) At(x, y int) (int, bool)
- func (m *Map) Backward(to, _ int, buf []graph.Transition[int]) []graph.Transition[int]
- func (m *Map) Coords(c int) (x, y int, ok bool)
- func (m *Map) FarPair() [2]int
- func (m *Map) Forward(from, _ int, buf []graph.Transition[int]) []graph.Transition[int]
- func (m *Map) Gated(at int) (graph.Implicit[int], int)
- func (m *Map) Graph() graph.Implicit[int]
- func (m *Map) Octile(a, b int) float64
- func (m *Map) OpenNear(x, y int) int
- func (m *Map) Pairs(seed uint64, n int, lo, hi float64) [][2]int
- func (m *Map) States(x, y int, buf []int) []int
- func (m *Map) WallRing(x0, y0, side int)
- type Point
Constants ¶
const InsurmountableObstacle = 100.0
InsurmountableObstacle is the cost of a wall of a grid, a cell no step enters.
Variables ¶
This section is empty.
Functions ¶
func Dicts ¶
Dicts are the dictionaries an engine over a grid of size × size may keep its nodes in, by name, each made anew.
func EightWays ¶
func EightWays(grid [][]float64) graph.Transitions[Point]
EightWays walks grid eight ways: a wall is never entered, a step costs the cell entered, a slantwise one √2 of it.
func FourWays ¶
func FourWays(costWeight float64, grid [][]float64) graph.Transitions[Point]
FourWays walks grid four ways, a step costing the cell entered times costWeight; a step of 100 or more is not taken.
func Octile ¶
Octile is the octile distance, which never overestimates on a grid where no step costs less than its length.
func PathCost ¶
PathCost is the cost of path over grid as FourWays and EightWays price it: the cell entered, a slantwise step √2 of it.
func Queries ¶
Queries are the corners of grid both ways, a cell to itself, the first wall if any, then forty pairs of open cells drawn from seed.
func RandomGrid ¶
RandomGrid is a grid of costs of 1 to 5 and a wall on a fifth of the cells, the corners kept open.
func SkipLarge ¶
SkipLarge skips tb on a map of 4096x4096 or more unless HPASTAR_SCALE=4096 asks for one: a hierarchy over it takes a minute and most of a gigabyte to build.
func WalkCost ¶
WalkCost is what route costs stepped along steps; false where a step is not a transition.
func WalledGrid ¶
WalledGrid is a grid of costs 1 to 5 by the cells' diagonals, walled on most of every fourth column, its corners open.
Types ¶
type Map ¶
Map is a square map of cells for the tests and the benchmarks: each cell's share of full pace (0 a wall), reproducible from a seed; Wrap makes it a torus.
func New ¶
New is a map of size × size cells: ground from smooth value noise with shares between 0.13 and 1 (as rough ground to a road), walls on the share of cells walls says, laid as short lines so that pockets and detours form.
func (*Map) Apart ¶
Apart draws n open cells from rnd, each at least near from from by the octile distance and, where far is above 0, at most far.
func (*Map) Backward ¶
func (m *Map) Backward(to, _ int, buf []graph.Transition[int]) []graph.Transition[int]
Backward is Forward seen from the destination: the states a step leads from into to, each at the cost of that step.
func (*Map) FarPair ¶
FarPair is two open cells near opposite corners, an eighth of the side in from each: a route across most of a map with edges.
func (*Map) Forward ¶
func (m *Map) Forward(from, _ int, buf []graph.Transition[int]) []graph.Transition[int]
Forward is the map's transitions: eight directions, a step priced by its length over the share of the cell it enters, none into a wall.
func (*Map) Gated ¶
Gated is the map's graph with a gate past its cells, a state off the plane stepping only to at, and the gate.
func (*Map) Octile ¶
Octile is the octile distance, which never overestimates: no step costs less than its length.
func (*Map) OpenNear ¶
OpenNear is the open cell nearest x, y, looked for a ring of cells at a time; -1 where the map has none.
func (*Map) Pairs ¶
Pairs are n pairs of open cells drawn from seed, lo to hi apart by the octile distance.