跳转到内容
查看源码

navigation自动生成

分类:包 · 清单:use "kernels/";

网格上的寻路:按代价逐遍松弛的距离场,以及朝目标走的下一步。

Ways over a grid: how far each cell is from a seed by what each costs to enter, relaxed a pass at a time, and the step a walk takes toward it.

Layer: Foundation. Uses: no other package.

use "navigation.entpkg";
  • kernels/grid_path.ent — Ways over a grid of cells. Kernels: navigation.relax@1.

tests/ holds scenes and their replays, run on every backend: grid.replay. Every Kernel of the package is reached by one of them.

Used by the slg example.

Kernel 执行模式 简述
navigation.relax@1 map One pass: each cell the nearer of what it is and its cheapest neighbor’s and its own cost (cost, blocked or more not entered). A node runs it times = N; carry previous <- result; from a seed (0 where it begins, grid_far() else).
函数 简述
grid_far() -> Int Far: a cell not yet reached, or one none may reach.
grid_inside(dist: Grid<Int>, c: IVec2) -> Bool
grid_at(dist: Grid<Int>, c: IVec2) -> Int
grid_step(dist: Grid<Int>, c: IVec2) -> IVec2 A step from c toward the seed of dist: the neighbor nearest it (the first of right, left, down, up when two are as near); c when none is nearer.
off_segment(p: Vec2, a: Vec2, b: Vec2) -> Float How far point p is from the segment a to b.
path_cover(dist: Grid<Int>, from: IVec2, to: IVec2, p: Vec2, half: Float) -> Float The walk from cell from down dist (its seed to) drawn at p (in cells: a cell’s middle is its index and a half): a line through each step’s middle half of a cell wide each side, and at to an arrow’s head pointing the way the last step goes; how much covers p (0 to 1). At most steps steps.

One pass: each cell the nearer of what it is and its cheapest neighbor’s and its own cost (cost, blocked or more not entered). A node runs it times = N; carry previous <- result; from a seed (0 where it begins, grid_far() else).

执行模式 map
需要能力 field.read, field.write
输入 previous: Grid<Int>, cost: Grid<Int>
参数 blocked: Int = 99
输出 result: Grid<Int>
源码 packages/navigation.entpkg/kernels/grid_path.ent

grid.replay