
spacewalk
The geometry instrument for operations conducted on a lattice — board games, tactics games, and tile maps: cells, directions, distance, sight, regions, and routes. Pieces, terrain, players, and the game clock remain under the command of your application.
Quick start
[]
= "0.1"
use ;
let grid = square;
let mud = ;
let movement = cell_cost;
let route = grid
.path_between
.expect;
assert_eq!;
assert_eq!; // the start is included
Why
- One vocabulary, three boards. Code written against the
Gridtrait runs on a stored cell set (FullGrid), an arithmetic rectangle (RectGrid), or a borrowed region (SubGrid) without a change of course. - Any shape. Square, hex, disc, and tile-map hex rectangles ship as
constructors; a custom
Coordimplementation opens anything else, including three-dimensional boards. - Directed movement costs. A step's cost belongs to the cell entered and the direction of arrival — rivers, conveyors, and ledges just work. A*, budget-bounded Dijkstra, and reverse reachability search the graph with deterministic tie-breaking.
- Sight and regions come back as boards. Range, ring, component, and
field-of-view queries return a
SubGrid, so the thing you highlight is also the thing you path over. - Integer pathfinding, reproducible replays. Floats exist only in the screen-layout layer; no float ever reaches a cost, metric, or step table.
Requirements and features
- Rust 1.88 or newer, edition 2024.
#![no_std]withalloc; one runtime dependency (hashbrown).serdefeature: serialization for the plain-data types andCellMap. Grids rebuild from their cells; serialize coordinates, never indices.- Safety caps bound untrusted map files:
MAX_CELLSis 2²⁴ cells andMAX_SIGHTis 64. Panicking constructors havetry_counterparts.
More examples and documentation
- API documentation — rustdoc is the manual:
the
Gridvocabulary, cost models, metrics, index identity, and layouts. tests/— public-API missions: square tactics, checkers, hex capture, three-dimensional chess, field of view, directed threats, save/load, and robustness at hostile numeric limits.- CHANGELOG
- Issue tracker
License
Licensed under either of Apache License, Version 2.0 or MIT license at your option.
Banner image: “Astronaut Walks in Space,” credited to the U.S. Information Agency; source via Artvee.