1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
//! 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.
//!
//! [`docs/tutorials/`]: https://github.com/rjwalters/thrust/tree/main/docs/tutorials
//! [`docs/tutorials/README.md`]: https://github.com/rjwalters/thrust/blob/main/docs/tutorials/README.md
//!
//! # Landed tutorials
//!
//! - [`tutorial_01_first_agent`](crate::tutorials::tutorial_01_first_agent) —
//! Your first agent (SimpleBandit + actor-critic; the rollout → loss → update
//! loop).
//! - [`tutorial_02_cartpole_ppo`](crate::tutorials::tutorial_02_cartpole_ppo) —
//! Solving CartPole with PPO (`EnvPool`, GAE, the config surface, reading
//! learning curves).
//! - [`tutorial_03_dqn`](crate::tutorials::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`](crate::tutorials::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`](crate::tutorials::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`](crate::tutorials::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`](crate::tutorials::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).
/// Tutorial 1 — Your first agent.
///
/// See the rendered Markdown at
/// [`docs/tutorials/01-your-first-agent.md`](https://github.com/rjwalters/thrust/blob/main/docs/tutorials/01-your-first-agent.md).
/// Tutorial 2 — Solving CartPole with PPO.
///
/// See the rendered Markdown at
/// [`docs/tutorials/02-cartpole-ppo.md`](https://github.com/rjwalters/thrust/blob/main/docs/tutorials/02-cartpole-ppo.md).
/// Tutorial 3 — Off-policy training with DQN.
///
/// See the rendered Markdown at
/// [`docs/tutorials/03-dqn.md`](https://github.com/rjwalters/thrust/blob/main/docs/tutorials/03-dqn.md).
/// Tutorial 4 — Continuous control with SAC.
///
/// See the rendered Markdown at
/// [`docs/tutorials/04-sac-continuous.md`](https://github.com/rjwalters/thrust/blob/main/docs/tutorials/04-sac-continuous.md).
/// Tutorial 5 — Memory and POMDPs with recurrent PPO.
///
/// See the rendered Markdown at
/// [`docs/tutorials/05-memory-pomdps.md`](https://github.com/rjwalters/thrust/blob/main/docs/tutorials/05-memory-pomdps.md).
/// Tutorial 6 — Writing your own environment.
///
/// See the rendered Markdown at
/// [`docs/tutorials/06-your-own-env.md`](https://github.com/rjwalters/thrust/blob/main/docs/tutorials/06-your-own-env.md).
/// Tutorial 7 — Train in Rust, run in the browser.
///
/// See the rendered Markdown at
/// [`docs/tutorials/07-wasm-deploy.md`](https://github.com/rjwalters/thrust/blob/main/docs/tutorials/07-wasm-deploy.md).