Skip to main content

Module tutorials

Module tutorials 

Source
Expand description

Guided tutorial series (requires the training feature).

A dependency-ordered path from install to a trained, deployed policy. Each tutorial’s code is doc-tested, so the copy-paste snippets in the prose are CI-enforced against the live API. See the module docs for the index, or read the Markdown source under docs/tutorials/. Guided tutorial series: from cargo add thrust-rl to a trained, deployed policy.

Each tutorial is a single Markdown file under docs/tutorials/ whose rust code blocks are pulled in here with #[doc = include_str!(...)]. Because they are rendered as rustdoc, every code block is compiled and run as a doc-test by cargo test --features training — so the copy-paste code in the prose can never rot out of sync with the library API. This is the CI-enforced mechanism the tutorial series is built on.

The Markdown files are the single source of truth: read them in docs/tutorials/ (rendered nicely on GitHub) or here on docs.rs. The series is ordered by concept dependency — see docs/tutorials/README.md for the full dependency-ordered outline.

§Landed tutorials

  • tutorial_01_first_agent — Your first agent (SimpleBandit + actor-critic; the rollout → loss → update loop).
  • tutorial_02_cartpole_ppo — Solving CartPole with PPO (EnvPool, GAE, the config surface, reading learning curves).
  • tutorial_03_dqn — Off-policy training with DQN (replay buffer, target network, ε-annealing, Double-DQN, Polyak soft updates; when to prefer DQN over PPO).
  • tutorial_04_sac — Continuous control with SAC (Box action spaces, tanh squashing, automatic entropy tuning, twin critics; reusing the off-policy replay + Polyak machinery for continuous actions).
  • tutorial_05_memory — Memory and POMDPs with recurrent PPO (FlickeringCartPole, LSTM policy, recurrent rollouts and hidden-state handling; when an LSTM earns its cost vs. a memoryless MLP baseline).
  • tutorial_06_own_env — Writing your own environment (implementing the Environment trait from scratch; the seeding/determinism contract behind clone_state / restore_state).
  • tutorial_07_wasm — Train in Rust, run in the browser (exporting a trained MlpBurnPolicy to the InferenceModel JSON format, the Burn→inference weight transpose, and wiring the JSON into the WASM demo).

Modules§

tutorial_01_first_agent
Tutorial 1 — Your first agent.
tutorial_02_cartpole_ppo
Tutorial 2 — Solving CartPole with PPO.
tutorial_03_dqn
Tutorial 3 — Off-policy training with DQN.
tutorial_04_sac
Tutorial 4 — Continuous control with SAC.
tutorial_05_memory
Tutorial 5 — Memory and POMDPs with recurrent PPO.
tutorial_06_own_env
Tutorial 6 — Writing your own environment.
tutorial_07_wasm
Tutorial 7 — Train in Rust, run in the browser.