Xlbully's picture
Add CLI and example output
bdfcde8
metadata
library_name: staticplay-curiodynamics
license: mit
tags:
  - physics
  - symbolic-regression
  - curiosity
  - dynamics
  - discovery
  - scientific-ml

Staticplay CurioDynamics

Curiosity-driven symbolic physics discovery from raw trajectories (position, velocity, time). The agent observes only state and learns a sparse symbolic model that recovers hidden dynamics such as gravity, drag, and wind.

What It Does

  • Generates a hidden physics world (projectile motion with drag + wind).
  • Observes only position, velocity, and time.
  • Learns a symbolic acceleration model via sparse regression.
  • Recovers interpretable formulas like:
    • ax = wind − k * vx * |vx|
    • ay = −g − k * vy * |vy|

Quick Start

Requires Python 3.10+.

python .\physics_world.py

CLI Usage

python .\physics_world.py --episodes 50 --steps 200 --g 9.81 --drag 0.12 --wind 0.4 --drag_power 2.0 --dt 0.1 --seed 123

How It Works

  1. Simulates a hidden world with gravity + drag + wind.
  2. Collects state transitions only (no equations given).
  3. Fits a sparse symbolic model over a small feature library.
  4. Interprets the recovered constants as wind and gravity.

Latest Test Results

Hidden world: quadratic drag + wind

g_true = 9.81
drag_true = 0.12
wind_true = 0.4

model_ax: ax = 0.4 − 0.12 * vx|vx|
model_ay: ay = −9.81 − 0.12 * vy|vy|
wind_est = 0.4
g_est = 9.81

Example Output

{'g_true': 9.81, 'drag_true': 0.12, 'wind_true': 0.4, 'drag_power_true': 2.0,
 'model_ax': {'vx_abs_vx': -0.12, '1': -2.209},
 'model_ay': {'vy_abs_vy': -0.12, '1': -13.034},
 'wind_est': 0.4, 'g_est': 9.81, 'samples': 634}

Install

No external dependencies beyond standard library.

If you want a virtual environment:

python -m venv .venv
.\.venv\Scripts\activate
python .\physics_world.py

Files

  • physics_world.py: hidden physics world + curiosity agent + symbolic regression

How To Run Different Scenarios

Edit run_stress_test(...) in physics_world.py:

  • wind
  • drag
  • drag_power
  • episodes
  • steps

Example:

result = run_stress_test(
    episodes=50,
    steps=200,
    g=9.81,
    drag=0.12,
    wind=0.4,
    drag_power=2.0,
    dt=0.1
)
print(result)

Notes

This is intentionally minimal and deterministic to highlight discovery mechanics. The feature library is constrained to keep the model interpretable.

Acknowledgements

  • teliov/symcat-to-synthea

Links