@codexo/exojs-pathfinding 0.17.0 → 0.18.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/README.md +18 -54
  2. package/package.json +3 -3
package/README.md CHANGED
@@ -1,11 +1,8 @@
1
1
  # @codexo/exojs-pathfinding
2
2
 
3
- Official ExoJS extension for 2D pathfinding. One search core - A\* with jump-point pruning -
4
- over pluggable navigation spaces: weighted grids for top-down worlds, waypoint graphs for
5
- platformers and for graphs that have no geometry at all.
3
+ Official ExoJS extension for 2D pathfinding. One search core - A\* with jump-point pruning - over pluggable navigation spaces: weighted grids for top-down worlds, waypoint graphs for platformers and for graphs that have no geometry at all.
6
4
 
7
- It is plain logic. No scene node, no renderer, no asset type, no registration step: you
8
- construct a space and a `Pathfinder`, and you own both.
5
+ It is plain logic. No scene node, no renderer, no asset type, no registration step: you construct a space and a `Pathfinder`, and you own both.
9
6
 
10
7
  ## Installation
11
8
 
@@ -13,19 +10,14 @@ construct a space and a `Pathfinder`, and you own both.
13
10
  npm install @codexo/exojs @codexo/exojs-pathfinding
14
11
  ```
15
12
 
16
- `@codexo/exojs` is a peer dependency and the only one. In particular this package does **not**
17
- depend on `@codexo/exojs-tilemap`: feeding a tilemap into a grid is three lines of your code,
18
- shown below.
13
+ `@codexo/exojs` is a peer dependency and the only one. In particular this package does **not** depend on `@codexo/exojs-tilemap`: feeding a tilemap into a grid is three lines of your code, shown below.
19
14
 
20
15
  ## What this package provides
21
16
 
22
17
  - `Pathfinder` - runs the queries and owns the reusable search buffers.
23
- - `GridSpace` - a finite window of weighted cells, with diagonal policies, per-cell costs,
24
- clearance for wide agents, string-pulling path smoothing, and a jump-point fast path.
25
- - `WaypointGraph` - a directed graph of hand-placed nodes whose edges carry a `kind` and a
26
- payload, so a path can tell a jump from a walk.
27
- - `NavigationSpace` - the interface both implement, and the one your own space implements when
28
- neither fits.
18
+ - `GridSpace` - a finite window of weighted cells, with diagonal policies, per-cell costs, clearance for wide agents, string-pulling path smoothing, and a jump-point fast path.
19
+ - `WaypointGraph` - a directed graph of hand-placed nodes whose edges carry a `kind` and a payload, so a path can tell a jump from a walk.
20
+ - `NavigationSpace` - the interface both implement, and the one your own space implements when neither fits.
29
21
 
30
22
  ## Capability matrix
31
23
 
@@ -60,9 +52,7 @@ if (result.status === 'found') {
60
52
  }
61
53
  ```
62
54
 
63
- `findPath` takes node ids, `findPathBetween` takes world coordinates. Both return the same
64
- `PathResult`, and `status` is a value rather than an exception, because "no path" is an ordinary
65
- game state:
55
+ `findPath` takes node ids, `findPathBetween` takes world coordinates. Both return the same `PathResult`, and `status` is a value rather than an exception, because "no path" is an ordinary game state:
66
56
 
67
57
  | `status` | Meaning |
68
58
  | ----------------- | -------------------------------------------------------------------- |
@@ -70,15 +60,11 @@ game state:
70
60
  | `unreachable` | The search exhausted the space. Empty path, unless `snapToNearest`. |
71
61
  | `budget-exceeded` | `maxExpandedNodes` ran out. The best partial path is still returned. |
72
62
 
73
- `result.revision` records `space.revision` at search time, so a follower can notice that the
74
- world changed under its path and ask for a new one.
63
+ `result.revision` records `space.revision` at search time, so a follower can notice that the world changed under its path and ask for a new one.
75
64
 
76
65
  ## Grids
77
66
 
78
- Coordinates are absolute cell coordinates - the same numbers your map uses - not offsets into
79
- the window. The window itself is finite by construction, and everything outside it is blocked;
80
- that is the answer for infinite or streamed maps: size the window to the region the actors are
81
- in, and push chunk changes into it with `setCost`.
67
+ Coordinates are absolute cell coordinates - the same numbers your map uses - not offsets into the window. The window itself is finite by construction, and everything outside it is blocked; that is the answer for infinite or streamed maps: size the window to the region the actors are in, and push chunk changes into it with `setCost`.
82
68
 
83
69
  ```ts
84
70
  // Streamed tilemap, no package dependency in either direction.
@@ -91,25 +77,15 @@ const window = GridSpace.from(96, 96, (x, y) => walkCost(map.getTileAt(layerId,
91
77
  map.onTileChanged(({ x, y, tile }) => window.setCost(x, y, walkCost(tile)));
92
78
  ```
93
79
 
94
- Cost `0` blocks a cell, `1` is ordinary ground, larger values are terrain the search routes
95
- around when the detour is cheaper. Diagonal steps cost their length, and the default diagonal
96
- policy (`'no-corner-cutting'`) forbids the diagonal that would clip through the corner where two
97
- walls meet.
80
+ Cost `0` blocks a cell, `1` is ordinary ground, larger values are terrain the search routes around when the detour is cheaper. Diagonal steps cost their length, and the default diagonal policy (`'no-corner-cutting'`) forbids the diagonal that would clip through the corner where two walls meet.
98
81
 
99
- `agentSize` restricts a query to cells where an agent that many cells wide fits. Clearance is
100
- anchored at a cell's **top-left** corner, so the last row and column of a window can never hold
101
- an agent wider than one cell.
82
+ `agentSize` restricts a query to cells where an agent that many cells wide fits. Clearance is anchored at a cell's **top-left** corner, so the last row and column of a window can never hold an agent wider than one cell.
102
83
 
103
84
  ## Jump-point search
104
85
 
105
- `GridSpace` substitutes jump-point search for plain neighbour expansion whenever the grid is
106
- uniform-cost, `agentSize` is `1`, and the diagonal policy is the default. It returns the same
107
- cost-optimal path while expanding a fraction of the nodes; `result.expandedNodes` shows the
108
- difference. Nothing has to be switched on, and `{ pruning: false }` switches it off.
86
+ `GridSpace` substitutes jump-point search for plain neighbour expansion whenever the grid is uniform-cost, `agentSize` is `1`, and the diagonal policy is the default. It returns the same cost-optimal path while expanding a fraction of the nodes; `result.expandedNodes` shows the difference. Nothing has to be switched on, and `{ pruning: false }` switches it off.
109
87
 
110
- Because pruning settles only jump points, a `budget-exceeded` partial path under pruning ends on
111
- a jump point rather than on the nearest cell. `snapToNearest` is unaffected: when the goal turns
112
- out to be unreachable, the query re-runs unpruned so the snapped node really is the closest one.
88
+ Because pruning settles only jump points, a `budget-exceeded` partial path under pruning ends on a jump point rather than on the nearest cell. `snapToNearest` is unaffected: when the goal turns out to be unreachable, the query re-runs unpruned so the snapped node really is the closest one.
113
89
 
114
90
  ## Waypoint graphs
115
91
 
@@ -131,15 +107,11 @@ for (const step of new Pathfinder().findPath(graph, ledge, platform).edges) {
131
107
  }
132
108
  ```
133
109
 
134
- Node positions are optional. Leave them out and the heuristic drops to zero, which turns the
135
- same search into plain Dijkstra over an abstract graph - the shape a web application's routing
136
- problem usually has.
110
+ Node positions are optional. Leave them out and the heuristic drops to zero, which turns the same search into plain Dijkstra over an abstract graph - the shape a web application's routing problem usually has.
137
111
 
138
112
  ## Reachable-area queries
139
113
 
140
- `floodFrom` returns every node within a cost budget, cheapest first: the "tiles I can still
141
- reach with the movement points I have left" query, and the input a flow field would be built
142
- from.
114
+ `floodFrom` returns every node within a cost budget, cheapest first: the "tiles I can still reach with the movement points I have left" query, and the input a flow field would be built from.
143
115
 
144
116
  ```ts
145
117
  const region = pathfinder.floodFrom(grid, grid.nodeAt(unit.tileX, unit.tileY), { maxCost: 6 });
@@ -151,21 +123,13 @@ for (const node of region.nodes) {
151
123
 
152
124
  ## Determinism and allocation
153
125
 
154
- Equal-cost paths are resolved by a pinned tie-break (lower node id first), so the same query on
155
- an unmutated space returns the identical path on every machine and every run - which is what
156
- makes paths safe to record in a replay or assert in a test.
126
+ Equal-cost paths are resolved by a pinned tie-break (lower node id first), so the same query on an unmutated space returns the identical path on every machine and every run - which is what makes paths safe to record in a replay or assert in a test.
157
127
 
158
- A `Pathfinder` owns its search state and reuses it across queries, including queries against
159
- different spaces of different sizes. Once the buffers have grown to fit, a search allocates
160
- nothing that scales with the number of nodes it visits. The result object is allocated fresh
161
- every time, deliberately: callers keep paths, and pooling something a caller keeps buys a little
162
- garbage back at the price of use-after-reuse bugs.
128
+ A `Pathfinder` owns its search state and reuses it across queries, including queries against different spaces of different sizes. Once the buffers have grown to fit, a search allocates nothing that scales with the number of nodes it visits. The result object is allocated fresh every time, deliberately: callers keep paths, and pooling something a caller keeps buys a little garbage back at the price of use-after-reuse bugs.
163
129
 
164
130
  ## Custom spaces
165
131
 
166
- Implement `NavigationSpace` and every query in this package works against it. `neighbors`
167
- receives the pathfinder's own buffers instead of returning an array, so a third-party space is
168
- allocation-free on the same terms as the built-in ones.
132
+ Implement `NavigationSpace` and every query in this package works against it. `neighbors` receives the pathfinder's own buffers instead of returning an array, so a third-party space is allocation-free on the same terms as the built-in ones.
169
133
 
170
134
  ## License
171
135
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@codexo/exojs-pathfinding",
3
- "version": "0.17.0",
3
+ "version": "0.18.0",
4
4
  "description": "Deterministic, allocation-free 2D pathfinding for ExoJS: A*, jump-point search, weighted grids and waypoint graphs.",
5
5
  "repository": {
6
6
  "type": "git",
@@ -26,10 +26,10 @@
26
26
  "LICENSE"
27
27
  ],
28
28
  "peerDependencies": {
29
- "@codexo/exojs": "0.17.x"
29
+ "@codexo/exojs": "0.18.x"
30
30
  },
31
31
  "devDependencies": {
32
- "@codexo/exojs": "0.17.0",
32
+ "@codexo/exojs": "0.18.0",
33
33
  "@codexo/exojs-config": "0.0.0"
34
34
  },
35
35
  "license": "MIT",