Repository navigation
Fight simulator stage 3: sweeps, real worlds, CSV and the fight table - #93
Merged
Merged
Conversation
…ort CSV and a fight table
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Stage 3 of the fight simulator (stages 1 and 2: #91, #92): sweeps, real worlds, CSV and the fight table. No rule change, and the CI reference fights are unchanged (
fight --check simstill agrees on all 10).sim::sweep): a matchup file'ssweep:key, e.g.{player.stats.level: [3, 4, 5, 6], foes.0.stats.level: [1, 2, 3]}. Each key is a dotted path into the file, so any key a matchup reads can be swept (stats, counts,story.*,policy.*). Each point is the file with its values set, read again in full.sim::world):--database FILE --story TITLE [--levels A..B]fights each of the story's hostiles against its protagonist at each level. The database is serialized into memory and the file is closed before anything is read, so it is never written. Stat blocks come from the world, and fights run in the arena, so no room writer is needed. A NULL stat is rolled for each seed. An optional matchup file sets seeds, carrying and policy.--fight-table FILE|-(sim::export::fight_table): JSON with each matchup's P(win) and its interval, P(died/fled/stalled), andhp_loss(the share of all fights that cost N HP and were survived; this plusp_diedsums to 1).--csv: one row per matchup, with every rate, its interval and the means. A grid with no flag prints a one-row-per-matchup text table.tests/sim.rs): a sweep point plays the same fights seed for seed as its matchup written out alone. A world run leaves the file byte-identical, fights every hostile at every level, and plays what its stat blocks would. The fight table's probabilities sum to 1. Plus unit tests for grid expansion, levels and CSV quoting. The README "Measuring fights" section is updated.Sample grid
cargo run --release --bin fight -- sim/matchups/levels-grid.yml: the house body (d8, abilities 10) at player levels 3–6 against one d10 foe at levels 1–3, attacking to the end, told driver, seeds 1..2000: