Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
feat(traversal): hash ground, jump, and roll at a fixed 60 Hz
Add the tick sim and the required traversal replay case. Reset
character_full_tick onto the finite ground without weakening the
y > -10 check. Slope, jump, and facing roots stay on libm.

Co-authored-by: Andrew Brown <lazyxeon@users.noreply.github.com>
  • Loading branch information
cursoragent and lazyxeon committed Oct 16, 2026
commit cdf66d8d3f114b192171e2717698da62a0b7c470
16 changes: 9 additions & 7 deletions .github/workflows/determinism-replay.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
# Branch protection is a repository setting. This workflow is the check it must require.
# `planner_pure` (WS-D0), `perception_world` (WS-D1), `gameplay_rng` (WS-D2),
# `fixed64`, `combat_resolve`, `destruction`, `gameplay_qa_aravath_slice`,
# `nav_reroute`, `causal_bridge`, `scripted_system` (WS-MOD), and `weaving`
# fail the compare job on any mismatch or if the case is missing. No path
# filter. cargo test has no retry loop (no-retry). Do not switch this job to
# nextest.
# `nav_reroute`, `causal_bridge`, `scripted_system` (WS-MOD), `weaving`, and
# `traversal` fail the compare job on any mismatch or if the case is missing.
# No path filter. cargo test has no retry loop (no-retry). Do not switch this
# job to nextest.

name: determinism-replay

Expand Down Expand Up @@ -71,6 +71,7 @@ jobs:
cargo test -p astraweave-weaving --lib gameplay_qa::tests::replay_aravath_slice_scenario -- --exact --nocapture
cargo test -p astraweave-causality --test replay_hash -- --nocapture
cargo test -p astraweave-scripting --test script_replay_hash -- --nocapture
cargo test -p astraweave-physics --test traversal_replay -- --nocapture

- name: Merge replay hashes
run: |
Expand All @@ -82,17 +83,18 @@ jobs:
const combat = JSON.parse(fs.readFileSync(path.join(root, "replay-hash-combat.json"), "utf8"));
const gameplay = JSON.parse(fs.readFileSync(path.join(root, "replay-hash-gameplay-qa.json"), "utf8"));
const causal = JSON.parse(fs.readFileSync(path.join(root, "replay-hash-causal.json"), "utf8"));
const traversal = JSON.parse(fs.readFileSync(path.join(root, "replay-hash-traversal.json"), "utf8"));
const seen = new Set(core.map((row) => row.case));
const merged = core.slice();
for (const row of combat.concat(gameplay, causal)) {
for (const row of combat.concat(gameplay, causal, traversal)) {
if (seen.has(row.case)) {
console.error(`duplicate replay case ${row.case}`);
process.exit(1);
}
seen.add(row.case);
merged.push(row);
}
const required = ["planner_pure", "perception_world", "gameplay_rng", "fixed64", "combat_resolve", "destruction", "gameplay_qa_aravath_slice", "nav_reroute", "causal_bridge", "scripted_system", "weaving"];
const required = ["planner_pure", "perception_world", "gameplay_rng", "fixed64", "combat_resolve", "destruction", "gameplay_qa_aravath_slice", "nav_reroute", "causal_bridge", "scripted_system", "weaving", "traversal"];
const names = new Set(merged.map((row) => row.case));
for (const name of required) {
if (!names.has(name)) {
Expand Down Expand Up @@ -131,7 +133,7 @@ jobs:
import sys
from pathlib import Path

required = {"planner_pure", "perception_world", "gameplay_rng", "fixed64", "combat_resolve", "destruction", "gameplay_qa_aravath_slice", "nav_reroute", "causal_bridge", "scripted_system", "weaving"}
required = {"planner_pure", "perception_world", "gameplay_rng", "fixed64", "combat_resolve", "destruction", "gameplay_qa_aravath_slice", "nav_reroute", "causal_bridge", "scripted_system", "weaving", "traversal"}
root = Path("replay-artifacts")
files = sorted(root.glob("*/replay-hash.json"))
print(f"artifacts: {[str(p) for p in files]}")
Expand Down
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions astraweave-core/src/sim.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ pub const SIM_SYSTEM_NAV: u64 = 0x4E41_7001;
pub const SIM_SYSTEM_HTN: u64 = 0x4854_7001;
/// Causal rule draws. The bridge table does not draw it.
pub const SIM_SYSTEM_CAUSAL: u64 = 0xCA05_7001;
/// Traversal slip and variant draws. Mixed into [`SimRng`] with the world seed and tick.
pub const SIM_SYSTEM_TRAVERSAL: u64 = 0x7A4E_7001;

/// Mix `(world_seed, tick, system_id)` into one `StdRng` seed.
///
Expand Down Expand Up @@ -181,6 +183,7 @@ mod tests {
SIM_SYSTEM_NAV,
SIM_SYSTEM_HTN,
SIM_SYSTEM_CAUSAL,
SIM_SYSTEM_TRAVERSAL,
];
for i in 0..ids.len() {
for j in (i + 1)..ids.len() {
Expand Down
3 changes: 3 additions & 0 deletions astraweave-physics/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ bitflags = "2"
# direction is physics → water (water is a glam-only leaf), keeping the
# physics→fluids→terrain→gameplay→physics cycle open.
astraweave-water = { path = "../astraweave-water" }
libm = { version = "0.2", default-features = false }
rayon = { version = "1.10", optional = true }
serde = { version = "1.0", features = ["derive"], optional = true }
serde_json = { workspace = true, optional = true }
Expand All @@ -46,6 +47,8 @@ astraweave-alloc = { workspace = true, optional = true }

[dev-dependencies]
criterion = { workspace = true }
serde_json = { workspace = true }
sha2 = { workspace = true }

[[bench]]
name = "raycast"
Expand Down
15 changes: 14 additions & 1 deletion astraweave-physics/benches/character_controller.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,17 @@ fn assert_transform_valid(transform: Option<Mat4>, context: &str) {
}
}

/// Put the capsule back on the finite ground and clear the fall velocity.
fn reset_character_for_tick(world: &mut PhysicsWorld, id: astraweave_physics::BodyId) {
world.set_body_position(id, vec3(0.0, 1.0, 0.0));
if let Some(ctrl) = world.char_map.get_mut(&id) {
ctrl.vertical_velocity = 0.0;
ctrl.time_since_grounded = 0.0;
ctrl.jump_buffer_timer = 0.0;
ctrl.pending_jump_velocity = 0.0;
}
}

/// Setup a simple test world with ground
fn setup_simple_world() -> PhysicsWorld {
let mut world = PhysicsWorld::new(vec3(0.0, -9.8, 0.0));
Expand Down Expand Up @@ -213,10 +224,12 @@ fn character_full_tick(c: &mut Criterion) {

c.bench_function("character_full_tick", |b| {
b.iter(|| {
// The ground plane is 100 m across. Criterion repeats this body, so
// each sample starts at the origin. The y > -10 assertion stays.
reset_character_for_tick(&mut world, char_id);
let desired_move = black_box(vec3(1.0, 0.0, 0.0));
world.control_character(char_id, desired_move, 1.0 / 60.0, false);
world.step();
// CORRECTNESS: Full tick must produce consistent physics state
let transform = world.body_transform(char_id);
assert_transform_valid(transform, "character_full_tick");
black_box(transform)
Expand Down
11 changes: 11 additions & 0 deletions astraweave-physics/src/detmath.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,14 @@ pub fn sqrt(value: f32) -> f32 {
pub fn acos(value: f32) -> f32 {
libm::acosf(value)
}
pub fn sin(value: f32) -> f32 {
libm::sinf(value)
}

pub fn cos(value: f32) -> f32 {
libm::cosf(value)
}

pub fn atan2(y: f32, x: f32) -> f32 {
libm::atan2f(y, x)
}
2 changes: 2 additions & 0 deletions astraweave-physics/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,8 @@ const _: () = assert!(

mod detmath;

/// Tick-based traversal sim. The Aravath motor and the replay gate both call it.
pub mod traversal;
#[cfg(feature = "profiling")]
use astraweave_profiling::{plot, span};

Expand Down
Loading