Commit Graph

27 Commits

Author SHA1 Message Date
31cb6862e1 Overhaul model learning: kNN+GP, uncertainty, dataset pruning, sim-speed fix
Data collection:
- time_delta is now target game-time; wall sleep = game_delta / sim_speed
  so stored deltas are uniform regardless of GAME_SIM_SPEED setting
- Auto-exclude junk params (GAME_VERSION, TIME, ALARMS_ACTIVE, …) and
  params returning None (uninstalled subsystems)
- Optional include_valve_states=True adds all 53 valve positions as inputs

Model backends (model_type='nn' or 'knn'):
- ReactorKNNModel: k-nearest neighbours with GP interpolation
  - Finds k nearest states, computes per-second transition rates,
    linearly scales to requested game_delta (linear-in-time assumption)
  - forward_with_uncertainty() returns (prediction_dict, gp_std)
    where std≈0 = on known data, std≈1 = out of distribution
- NN training fixed: loss computed in tensor space, mse_loss per batch

Dataset management:
- drop_well_fitted(error_threshold): drop samples model predicts well,
  keep hard cases (useful for NN curriculum)
- drop_redundant(min_state_distance, min_output_distance): drop samples
  that are close in BOTH input state AND output transition space, keeping
  genuinely different dynamics even at the same input state

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-12 17:16:22 +01:00
c78106dffc Add valve API, cheat_mode, and write-only param fixes
- Rename is_admin/admin_mode -> is_cheat/cheat_mode (only FUN_* event
  triggers are cheat params, not operational commands like SCRAM)
- Fix steam ejector valve write commands: int 0-100, not bool
- Move SCRAM, EMERGENCY_STOP, bay hatches, turbine trip etc. to normal
  write-only (not cheat-gated)
- Add FUN_IS_ENABLED to readable params (it appears in GET list)
- Add get_valve/get_valves, open/close/off_valve(s) methods with correct
  actuator semantics: OPEN/CLOSE powers motor, OFF holds position

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-12 17:16:08 +01:00
2ec68ff2e5 Add is_admin flag and admin_mode for dangerous write-only parameters
Parameters like CORE_SCRAM_BUTTON, CORE_EMERGENCY_STOP, bay hatch/fuel
loading, VALVE_OPEN/CLOSE/OFF, STEAM_TURBINE_TRIP, and all FUN_* event
triggers are now marked is_admin=True. Writing to them is blocked unless
the Nucon instance has admin_mode=True or force=True is used.

Normal control setpoints (MSCV_*, STEAM_TURBINE_*_BYPASS_ORDERED,
CHEM_BORON_*) remain write-only but are not admin-gated.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-12 16:42:13 +01:00
90616dcf69 Full parameter coverage compatible with game V2.2.25.213
- Add ~300 missing parameters with types, ranges, and units
- Add SPECIAL_VARIABLES frozenset to block non-param game endpoints
- Fix batch query to handle {"values": {...}} wrapper
- Fix str-typed params falling back to individual GET (batch returns int codes)
- Handle null/empty values from uninstalled subsystems
- Add is_readable field to NuconParameter for write-only support
- Add 57 write-only parameters: SCRAM, emergency stop, bay hatches/fuel loading,
  RODS_ALL_POS_ORDERED, MSCVs, steam turbine bypass/trip, ejector valves,
  VALVE_OPEN/CLOSE/OFF, chemistry rates, FUN_* event triggers
- Update get_all/get_all_readable/get_all_iter to skip write-only params
- __len__ now reflects readable param count (consistent with get_all)
- Update tests to skip write-only params in write test, handle None values

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-12 16:27:57 +01:00
5cfedceab7 Dev and simulator fixes
- Export ParameterEnum from __init__
- Add flask and numpy to dev dependencies
- Fix sim: remove run() call from test fixture, handle WEBSERVER_LIST_VARIABLES and WEBSERVER_BATCH_GET, normalize variable names to uppercase
- Remove RODS params from sim state (no longer part of sim model)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-12 16:27:48 +01:00
d5a0212824 Update exposed vars to match game V2 2025-02-18 21:22:43 +01:00
a6b5b68777 Fix: Also export BreakerStatus in __init__ 2025-02-18 21:21:45 +01:00
08ecbb461d Param Repr should contain is_writable not writable 2024-10-11 08:57:40 +02:00
878fb9cf4f Fix: Repr for Parameter should contain param_type, not type 2024-10-10 17:14:00 +02:00
81398225ec Ensure we expose the correct default modules 2024-10-10 17:13:35 +02:00
6d1df49ede More sensible bool values for enums 2024-10-10 16:43:50 +02:00
a43c9550ac Fix typo in meme 2024-10-03 23:28:29 +02:00
e7e7c81d29 Impl drake 2024-10-03 23:25:53 +02:00
03da3415c8 Updated __init__ 2024-10-03 21:56:46 +02:00
4c3ad983fc Morer objectives and fixes 2024-10-03 21:56:27 +02:00
33b5db2f57 Fixes and Updates 2024-10-03 21:56:16 +02:00
60cd44cc9e Implemenetd Model Learning 2024-10-03 21:55:59 +02:00
132c47ff21 Implemented Simulator 2024-10-03 21:55:44 +02:00
0d99378f7d Bug fixes and additions 2024-10-02 22:36:06 +02:00
7da36e8a14 ofc not send 'force' attrib to game... 2024-10-02 19:58:36 +02:00
d580f77fce Allowed weighted objectives 2024-10-02 19:31:19 +02:00
dc59173fe7 Better parameterized objectives and gym bindings 2024-10-02 19:22:23 +02:00
08828e2dec RL oh yeah 2024-10-02 18:45:06 +02:00
1f3a71ba96 Added range checks 2024-10-02 18:43:18 +02:00
ccd63de9ea Better cast to string for Params 2024-10-02 17:05:20 +02:00
2c58571d62 Allow force writing values 2024-10-02 16:51:12 +02:00
7a34be0f09 Initial commit 2024-10-02 16:25:45 +02:00