Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
15 changes: 9 additions & 6 deletions .github/workflows/determinism-replay.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
# Required status check on pull requests: `determinism-replay / compare`.
# 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`, and `destruction` 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.
# `fixed64`, `combat_resolve`, `destruction`, and `gameplay_qa_aravath_slice`
# 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 @@ -66,6 +66,7 @@ jobs:
run: |
cargo test -p astraweave-core --test replay_hash -- --nocapture
cargo test -p astraweave-combat --test replay_hash -- --nocapture
cargo test -p astraweave-weaving --lib gameplay_qa::tests::replay_aravath_slice_scenario -- --exact --nocapture

- name: Merge replay hashes
run: |
Expand All @@ -75,16 +76,18 @@ jobs:
const root = process.env.CARGO_TARGET_DIR || "target";
const core = JSON.parse(fs.readFileSync(path.join(root, "replay-hash.json"), "utf8"));
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 seen = new Set(core.map((row) => row.case));
const merged = core.slice();
for (const row of combat) {
for (const row of combat.concat(gameplay)) {
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"];
const required = ["planner_pure", "perception_world", "gameplay_rng", "fixed64", "combat_resolve", "destruction", "gameplay_qa_aravath_slice"];
const names = new Set(merged.map((row) => row.case));
for (const name of required) {
if (!names.has(name)) {
Expand Down Expand Up @@ -123,7 +126,7 @@ jobs:
import sys
from pathlib import Path

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

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

21 changes: 9 additions & 12 deletions astraweave-audio/tests/advanced_edge_cases.rs
Original file line number Diff line number Diff line change
Expand Up @@ -335,27 +335,24 @@ n0 = "tests/assets/override_test/NONEXISTENT.wav"
#[serial]
fn test_rapid_master_volume_changes() -> Result<()> {
let mut engine = AudioEngine::new()?;
// Private directory. A shared `tests/assets` path races with
// `cleanup_test_assets`, which deletes that tree from another test.
let dir = tempfile::tempdir()?;
let wav = dir.path().join("rapid.wav");
let wav_str = wav
.to_str()
.ok_or_else(|| anyhow::anyhow!("temp wav path is not utf-8"))?;

test_asset_generator::generate_test_beep(
"tests/assets/test_beep_rapid.wav",
440.0,
1.0,
22050,
)?;
test_asset_generator::generate_test_beep(wav_str, 440.0, 1.0, 22050)?;

// Play a long sound
engine.play_sfx_file("tests/assets/test_beep_rapid.wav")?;
engine.play_sfx_file(wav_str)?;

// Rapidly change master volume
for i in 0..20 {
let volume = (i as f32 / 20.0).clamp(0.0, 1.0);
engine.set_master_volume(volume);
engine.tick(0.02);
thread::sleep(Duration::from_millis(10));
}

// Cleanup
fs::remove_file("tests/assets/test_beep_rapid.wav")?;

Ok(())
}
3 changes: 3 additions & 0 deletions astraweave-weaving/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,10 @@ weaving = []
[dependencies]
# Core dependencies
anyhow = { workspace = true }
ron = "0.8"
serde = { workspace = true }
serde_json = { workspace = true }
sha2 = { workspace = true }
toml = { workspace = true }
rand = { workspace = true }

Expand Down
33 changes: 24 additions & 9 deletions astraweave-weaving/examples/aravath_slice.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,25 @@
fn main() {
let slice = astraweave_weaving::run_aravath_slice();
println!(
"aravath sword hp {} weave hp {} cover intact {} cover damage {}",
slice.sword_hp, slice.weave_hp, slice.cover_intact, slice.cover_damage
);
assert_eq!(slice.sword_hp, 15);
assert_eq!(slice.weave_hp, 25);
assert!(!slice.cover_intact);
fn main() -> anyhow::Result<()> {
let scenario = astraweave_weaving::load_bundled_scenario()?;
match astraweave_weaving::run_scenario(&scenario) {
astraweave_weaving::RunOutcome::Pass(report) => {
println!(
"aravath sword hp {} weave hp {} cover intact {} cover damage {}",
report.slice.sword_hp,
report.slice.weave_hp,
report.slice.cover_intact,
report.slice.cover_damage
);
println!("gameplay_qa_aravath_slice {}", report.trace_sha256);
Ok(())
}
astraweave_weaving::RunOutcome::Fail(artifact) => {
let json = astraweave_weaving::gameplay_qa::failure_json(&artifact)?;
eprintln!("{json}");
anyhow::bail!(
"scenario {} failed: {}",
artifact.scenario_id,
artifact.failure.kind
);
}
}
}
18 changes: 18 additions & 0 deletions astraweave-weaving/scenarios/aravath_slice_sword.ron
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
Scenario(
schema: 1,
id: "aravath_slice_sword",
seed: 0xA11CE5EE,
max_ticks: 1,
setup: Slice,
bot: Script(steps: [
(edges: [
Hit(attack_id: 1, defender: Cover, seq: 0, heal: false),
Hit(attack_id: 3, defender: Woven, seq: 1, heal: false),
WeaveDecay,
]),
]),
goal: (objective: "cover_broken", policy: "slice_sword_then_weave"),
checks: [
Reach(by_tick: 1, sword_hp: 15, weave_hp: 25, cover_intact: false, min_cover_damage: 25),
],
)
7 changes: 5 additions & 2 deletions astraweave-weaving/src/aravath.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,9 @@ pub struct AravathSlice {
pub cover_damage: i64,
}

/// World seed and destruction seed used by [`run_aravath_slice`].
pub const ARAVATH_SLICE_SEED: u64 = 0xA11C_E5EE;

/// Sword for 25, a data-driven weave school for 15, and a cover bond that breaks.
pub fn run_aravath_slice() -> AravathSlice {
let mut app = App::new().add_plugin(CombatPlugin);
Expand All @@ -81,11 +84,11 @@ pub fn run_aravath_slice() -> AravathSlice {
)
.expect("install table");
app.world.insert_resource(CombatClock {
world_seed: 0xA11C_E5EE,
world_seed: ARAVATH_SLICE_SEED,
tick: 0,
});

let mut destruction = DestructionWorld::new(0xA11C_E5EE, 0);
let mut destruction = DestructionWorld::new(ARAVATH_SLICE_SEED, 0);
let half = [Fixed64::from_int(1); 3];
let post = [Fixed64::from_int(0), Fixed64::from_int(1), Fixed64::ZERO];
destruction
Expand Down
Loading
Loading