add fight caves env - #689
Open
jordanbailey00 wants to merge 18 commits into
Open
Conversation
Preserve the complete C simulation, Puffer adapter, playable OSRS viewer, checkpoint replay and verified asset bundles in a 21-file integration. Consolidate implementation headers and environment tooling, with acceptance tests under tests/. Validation: 12 Python checks, fixed-seed C fixture (483 steps, a361005c), CPU adapter terminal test, native and viewer builds, short CPU training and 25-tick checkpoint replay. Before/after traces match for 258048 all-wave core ticks and 32768 adapter steps. CUDA training was not rerun. Supersedes fork PR #3; intended only for jordanbailey00/PufferLib:4.0.
Restore stock PufferLib 4.0 build.sh and remove the dedicated Fight Caves workflow. Move optional viewer building and Raylib setup into tools.py; update documentation, preflight checks, and acceptance commands. Validation: 19 Python tests, core/Puffer contract tests, CPU/native/viewer builds, 100 random native episodes, a 4096-step CPU training smoke run, playable startup, and 25-tick checkpoint replay passed. CUDA was not rerun. Gameplay, configuration, and v38 are unchanged.
Port v38 inventory and equipment transactions, dynamic player appearance, context menus, animated NPC picking, and click feedback into the existing flat Fight Caves layout. Include matching viewer assets manifest and regression coverage without changing training configuration or policy actions. Validation: PR run dyu9u9ix matched v38 run ybcsi6a4 at 749,731,840 training steps. All 17 checkpoints were byte-identical; all 49,980 logged environment and loss values matched. Final evaluation: 10,181 episodes, 93.4682% Jad completion, 993.1863 average damage taken. Playable and checkpoint replay launch checks passed.
Connect the full viewer to c_render and the standalone executable, install pinned assets during the standard build, and retain optional CPU compatibility replay. Keep simulation, policy contracts, configuration and trainer code unchanged. Validation: 29 Python tests; clean-source acceptance with deliberate asset/checkpoint failures; graphical regressions; CPU and CUDA training/replay smoke tests. Original, headless and rendered adapters match over 2048 steps (digest aeaaf52e).
Add Fight Caves with standard Puffer build, play, and replay workflows
Remove the environment-specific Docker image and dependency constraints. Document standard asset-installing build, train, play and replay commands in the supplied PufferTank environment. Verified official image 4ffc8947bc8d: Breakout CUDA control (524288 steps), Fight Caves CUDA training (2097152 steps, offline W&B 4kjsw4ma), playable startup, native checkpoint replay, matching headless/rendered traces (aeaaf52e), and core tests. Existing 29 Python tests pass locally. No simulation, policy, reward, config or shared trainer changes.
Add Fight Caves with standard PufferTank setup, training and viewer
Add Fight Caves: training, playable viewer and checkpoint replay
Replace the expanded table with 15 shared spawn patterns and a per-wave pattern map. Preserve slot order and unused/invalid lookup behavior. Remove 908 production lines and add exhaustive wave lookup regression fixtures. Validation: 29 Python tests, core and equipment tests, ASan/UBSan, compiled pre/post parity across all waves and rotations, and native viewer/CUDA builds passed. The 100M-budget run 418mhvg9 exactly matched baseline 20rjpbhn across 6,580 history metrics, 70 final metrics, and all four saved checkpoints.
Remove duplicated preset combat totals, equipment labels, icon overrides, model-item lists, and unused compatibility macros. Keep independent combat regression fixtures for all nine presets. Validation: core tests, 29 Python tests, native viewer build, and 16,065 pre/post simulation snapshots passed. 100M run xm3d45fk exactly matched 20rjpbhn across 6,580 history values, 70 final metrics, and all four checkpoint hashes.
Remove retired metric fields, counters, classifiers, reward-channel accumulation, and training/viewer output. Share the retained 11 metrics through the episode summary; preserve required reward and observation events. Accept compatible older checkpoint sidecars after the state hash advances to v6. Validation: full regression suite (42 Python cases plus C, CPU and graphical integration), ASan/UBSan core tests, and 945 independent pre/post wave/rotation traces passed. The 100M-budget run frh9mzyd matched baseline 20rjpbhn at all 94 logged steps: 1,786 retained metric/loss values, 19 final values, and all four checkpoint files were identical. Effective training configuration matched; only the requested metric removals were excluded from comparison.
Add Fight Caves: training, playable viewer and checkpoint replay
Author
|
Still working on integration with 5.0. Will have that ready in a few days There is some additional in scope functionality i'll be adding to the core backend and frontend over the coming days as well (all combat spells, spellbook swapping, special attacks, special effects, etc) |
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.
Fight Caves
Adds Old School RuneScape's Fight Caves: survive 63 waves, then defeat TzTok-Jad. The agent needs to choose targets, find safe positions, manage run energy, and switch protection prayers before incoming hits.
The environment is implemented in C, with a shared simulator for training, manual play, and checkpoint replay.
Learning Performance
Final evaluations from four independently trained policies using seed 73 and the same configuration, with only the timestep budget changed. Each starts at wave 1 with the Twisted bow loadout and no food or prayer potions. The policy controls movement, attacks, and protection prayers, including 1-tick flicking.
These benchmark tables were recorded before the logging cleanup; damage taken and attack-readiness metrics are no longer emitted by the current version.
Episode averages include deaths; damage is reported in HP. These are single-seed results. A preliminary hyperparameter sweep was completed, but further sweeps are needed to improve performance and stability with the current mechanics.
Training Performance
What's in scope?
The current training policy uses fixed gear and no supplies. Consumables and equipment switching are available in the simulation and manual viewer, but aren't actions the policy can choose yet.
This is limited to the Fight Caves encounter. There's no open world, skilling, questing, banking, trading or PvP. Player spellcasting and a full melee weapon system aren't implemented in this PR (though I am also working on and building a full RSPS in C here https://github.com/jordanbailey00/RuneC-Testing). Neither are offensive prayers, special attacks, enchanted-bolt procs, blowpipe venom, Ava's ammo recovery or general gear degradation. Some of those controls appear in the OSRS interface, but they don't drive gameplay.
Things I'd still like to finish are varying the exact spawn tile within each spawn region, adding the large Tz-Kek's melee recoil, and checking Yt-MejKot's healing probability more closely against the game.
Debug Overlay
Otoggles collision, line of sight, routes and attack range. The overlay also shows NPC footprints and prayer windows.Spacepauses;Right Arrowadvances one tick.The event log records damage, healing, consumable use, kills and wave changes by tick.
The reward tab shows each reward component and the total for the current step.
Separate tabs show player state, cooldowns and action masks.
The manual-play control panel has target and wave selection, NPC health and distance, god mode, and speed controls from 0.25 to 60 TPS. Normal game speed is 5/3 TPS. Replay keeps the camera, diagnostics, pause and speed controls, but disables controls that would change gameplay.
Setup and usage
From an installed PufferLib checkout:
Train
The included configuration uses a 750M-step budget. The build automatically downloads and verifies the required assets.
Play
./build.sh fight_caves --fast unset __GLX_VENDOR_LIBRARY_NAME ./fight_cavesunset __GLX_VENDOR_LIBRARY_NAMEremoves PufferTank’s forced Mesa driver selection, which can cause CPU rendering instead of using the GPU.The viewer starts paused. Press Space to begin, O for debug overlays, and Q to quit.
Replay
Replay supports camera, pause, speed, and debug controls. Gameplay-changing controls are disabled.
Assets
The build downloads the pinned asset bundles into:
resources/fight_caves/runtime/: collision, movement, and line-of-sight maps.resources/fight_caves/viewer/: models, animations, terrain, textures, UI sprites/fonts, and the minimap.Archive and file hashes are verified, and valid installations are reused. Download or verification errors stop setup; missing required runtime data fails explicitly. No raw cache or reference repository is needed.
The exported OSRS assets are distributed separately from the source and are not covered by the software license; see ASSET_NOTICE.md.