
spacewalk
The geometry instrument for operations conducted on a lattice, such as 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.3"
use ;
let grid = square;
let mud = ;
let movement = cell_cost;
let = ;
let route = grid
.path
.expect;
assert_eq!;
assert_eq!; // the start is included
π¨βπ Mission Objectives
- Code written against the
Gridtrait runs on a board you built (FullGrid) or on a borrowed region of one (SubGrid) without a change of course. - Square, hex, disc, and tile-map hex rectangles ship as constructors. A
custom
Coordimplementation opens anything else, including three-dimensional boards. - A step's cost belongs to the cell entered and the direction of arrival, so
a river, a conveyor, or a one-way ledge needs no special case. A*,
budget-bounded Dijkstra, and reverse reachability search the graph with
deterministic tie-breaking. A
Graphruns the same searches over nodes you name yourself, from a plain list of edges, with no grid at all. - Range, ring, component, and field-of-view queries return a
SubGrid, so the thing you highlight is also the thing you path over. - Elevation lives in a
CellMapbeside your terrain.height::height_gatesays what a hill hides andheight::climb_gatewhat a ledge refuses, and both compose with the closures you already pass. - Pathfinding is integer arithmetic, so a replay reproduces. Floats exist only in the screen-layout layer, and no float ever reaches a cost, a metric, or a step.
π¨βπ 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, with
the
Gridvocabulary, cost models, metrics, index identity, and layouts. tests/: public-API missions, from square tactics, checkers, hex capture, and three-dimensional chess to field of view, directed threats, save and 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.