Skip to content

Commit

Permalink
docs: add notes on JPS, landmarks
Browse files Browse the repository at this point in the history
  • Loading branch information
glitchassassin committed Dec 17, 2024
1 parent e92130a commit 6df38ee
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
12 changes: 10 additions & 2 deletions docs/primitives/astar.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,17 @@

The [venerable A\* algorithm](https://www.redblobgames.com/pathfinding/a-star/introduction.html) provides the baseline for pathfinding in Screeps.

Red Blob Games has some [WIP articles on heuristics](https://www.redblobgames.com/blog/2024-05-05-wip-heuristics/).
Within a single room, the Clockwork implementation of the A\* algorithm alone is competitive with PathFinder. However, across longer distances (greater than a single room), PathFinder's JPS optimizations make a significant difference.

We'll experiment with a few different options.

## Optimizations

- [Jump-Point Search](https://zerowidth.com/2013/a-visual-explanation-of-jump-point-search/) is also used under the hood by PathFinder
- [Pre-computed landmarks](https://www.redblobgames.com/blog/2024-05-05-wip-heuristics/) for more accurate A\* heuristics

## Other interesting variants

- [Cooperative Pathfinding](https://theory.stanford.edu/~amitp/GameProgramming/MovingObstacles.html#predicting-obstacle-movement) (building a table of the paths of other units)
- JPS (generating paths, ignoring terrain costs)
- [Incremental heuristic search](https://en.wikipedia.org/wiki/Incremental_heuristic_search) (tracking moving targets)
- [Parallel Breadth-First Search](https://arxiv.org/abs/2210.16351)
1 change: 1 addition & 0 deletions docs/wasm/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@
We are using wasm-bindgen to create the WASM and a JS shim (`packages/wasm`). There are a few things we tweak to improve performance (such as passing in the `__packedPos` instead of the whole RoomPosition), so this is further wrapped in a Typescript library (`packages/screeps-clockwork`) which wraps and re-exports the WASM functionality.

- Copying data across the [WASM boundary](./boundary.md) adds up, so we must be thoughtful about when and how we copy data back and forth.
- Javascript can't garbage-collect our Rust objects, so we need to [clean them up explicitly](./cleanup.md).

0 comments on commit 6df38ee

Please sign in to comment.