1681-engine / index / straightenPath
Function: straightenPath() ​
ts
function straightenPath(
g,
path,
options?
): TilePoint[];Defined in: src/nav/straightenPath.ts:14
The same route with fewer turns. An eight-way search finds many equally short paths and hands back whichever its heap settled on, often a staircase — diagonal, straight, diagonal, straight — and a body walking one turns on every tile. Each stretch that can be is replaced with the plainest equal way through it: one diagonal run and one straight run. A replacement must cost no more than the stretch did (by the same cost, so it never trades the middle of a clearing for the edge of a wall), step only where the search could, and touch no end-only tile short of the end. Pass the options the path was found with.
Parameters ​
| Parameter | Type |
|---|---|
g | NavGrid |
path | readonly TilePoint[] |
options | NavOptions |