Compare commits

..

4 Commits

Author SHA1 Message Date
Elijah Voigt b2e46a00c1 chore(edu): archive completed beans and add self-play chapter section tickets [edu-coqp]
Archives completed/scrapped beans from previous chapters (markov, vector
db, compiler). Adds section beans for the self-play ML chapter (edu-coqp).
3 months ago
Elijah Voigt 05ac10f5e3 docs(edu): outline simple LLM chapter and create section tickets [edu-u2w7]
Adds llm-from-scratch.md stub with 14 sections (GPT-1 style: character
tokenisation, self-attention, transformer block, candle model, training
loop, sampling). Creates beans edu-32xl through edu-9sb7 for each section.
3 months ago
Elijah Voigt 818444962c docs(edu): outline ML self-play chapter and create section tickets [edu-coqp]
Add edu/src/ml-self-play.md with 14 stubbed sections across 5 parts:
foundations (RL, MCTS, self-play), game engine (Tic-Tac-Toe), MCTS
implementation, neural network integration, and the full self-play loop.
Create one beans ticket per section (edu-wobk through edu-brtk).

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
3 months ago
Elijah Voigt 5a1fb26927 docs(edu): outline shader programming chapter and create section tickets [edu-4u7w]
Add shaders.md with 18 stub sections across 6 parts (GPU model,
wgpu setup, vertex/fragment shaders, textures, compute shaders,
going further). Create beans tickets edu-5g0l through edu-7m8d
for each section. Add # Graphics section to SUMMARY.md.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
3 months ago

@ -0,0 +1,11 @@
---
# edu-10m1
title: '§9 Exercise 2: draw a coloured triangle'
status: todo
type: task
created_at: 2026-03-13T19:54:52Z
updated_at: 2026-03-13T19:54:52Z
parent: edu-4u7w
---
Write the exercise to draw a hard-coded coloured triangle: define three vertices in a vertex buffer, write a vertex shader that passes colour through, write a fragment shader that outputs the interpolated colour. First rendered geometry. Part 3 of the Shader Programming chapter.

@ -0,0 +1,11 @@
---
# edu-1nox
title: §17 Signed Distance Fields for font rendering
status: todo
type: task
created_at: 2026-03-13T19:55:11Z
updated_at: 2026-03-13T19:55:11Z
parent: edu-4u7w
---
Write the conceptual section on SDFs for font rendering: what an SDF encodes, why it scales better than bitmaps, how to threshold and anti-alias in the fragment shader. Brief — reading and intuition only. Part 6 of the Shader Programming chapter.

@ -0,0 +1,11 @@
---
# edu-2ak3
title: §3 What is WGSL? Syntax overview
status: todo
type: task
created_at: 2026-03-13T19:54:41Z
updated_at: 2026-03-13T19:54:41Z
parent: edu-4u7w
---
Write the WGSL syntax overview: types (scalars, vectors, matrices), functions, entry points, built-in variables (@vertex, @fragment, @builtin), uniforms and bindings. Show annotated snippets of a minimal vertex+fragment shader pair. Part 1 of the Shader Programming chapter.

@ -0,0 +1,11 @@
---
# edu-2sqo
title: '§13 Compute pipelines: dispatching work groups'
status: todo
type: task
created_at: 2026-03-13T19:55:02Z
updated_at: 2026-03-13T19:55:02Z
parent: edu-4u7w
---
Write the lesson on compute shaders: ComputePipeline vs RenderPipeline, dispatch_workgroups, workgroup size declarations in WGSL, global_invocation_id and how threads are indexed. Part 5 of the Shader Programming chapter.

@ -0,0 +1,11 @@
---
# edu-32xl
title: 'Write §1: What is a language model?'
status: todo
type: task
created_at: 2026-03-13T22:01:47Z
updated_at: 2026-03-13T22:01:47Z
parent: edu-u2w7
---
Next-token prediction as the core task. Intuitive framing: a model that guesses what comes next, trained on raw text. GPT-1 context. No code.

@ -0,0 +1,11 @@
---
# edu-3l9h
title: §7 Vertices, buffers, and the vertex shader
status: todo
type: task
created_at: 2026-03-13T19:54:49Z
updated_at: 2026-03-13T19:54:49Z
parent: edu-4u7w
---
Write the lesson on vertex data: vertex structs in Rust, VertexBufferLayout, uploading a buffer to the GPU with wgpu::util::DeviceExt, and what the vertex shader receives (position, colour, normals). Part 3 of the Shader Programming chapter.

@ -0,0 +1,11 @@
---
# edu-3yw9
title: 'Write §2: Monte Carlo Tree Search — algorithm explained'
status: todo
type: task
created_at: 2026-03-13T20:03:17Z
updated_at: 2026-03-13T20:03:17Z
parent: edu-coqp
---
Step-by-step walkthrough of MCTS: selection (UCB1), expansion, simulation/rollout, backpropagation. Include a worked example on a small game tree.

@ -0,0 +1,11 @@
---
# edu-453h
title: 'Write §13: The full AlphaGo Zero training loop'
status: todo
type: task
created_at: 2026-03-13T20:03:17Z
updated_at: 2026-03-13T20:03:17Z
parent: edu-coqp
---
Reading lesson: generate → train → evaluate → promote. Discuss the ELO-based model selection step and why it matters.

@ -1,11 +1,11 @@
---
# edu-4u7w
title: 'edu: write chapter on shader programming'
status: todo
type: task
status: in-progress
type: feature
priority: low
created_at: 2026-03-10T23:30:00Z
updated_at: 2026-03-10T23:30:00Z
updated_at: 2026-03-13T19:54:32Z
---
## Background

@ -0,0 +1,11 @@
---
# edu-4v13
title: 'Write §8: Exercise 2 — play Tic-Tac-Toe with pure MCTS'
status: todo
type: task
created_at: 2026-03-13T20:03:17Z
updated_at: 2026-03-13T20:03:17Z
parent: edu-coqp
---
Exercise: wire MCTS to the game logic from Exercise 1 and run a match. Show sample output, discuss iteration count vs strength.

@ -0,0 +1,11 @@
---
# edu-5g0l
title: '§1 CPU vs GPU: parallel execution model'
status: todo
type: task
created_at: 2026-03-13T19:54:37Z
updated_at: 2026-03-13T19:54:37Z
parent: edu-4u7w
---
Write the lesson on the CPU vs GPU execution model: SIMD vs SIMT, thread hierarchies (threads, warps/waves, workgroups), why GPUs excel at data-parallel work and struggle with branching. Part 1 of the Shader Programming chapter.

@ -0,0 +1,11 @@
---
# edu-5go8
title: 'Write §3: Why self-play? The AlphaGo Zero insight'
status: todo
type: task
created_at: 2026-03-13T20:03:17Z
updated_at: 2026-03-13T20:03:17Z
parent: edu-coqp
---
Explain the key insight: a capable engine can be its own teacher. Historical context (AlphaGo vs AlphaGo Zero) and why the approach generalises.

@ -0,0 +1,11 @@
---
# edu-6jjp
title: '§5 Exercise 1: create a window and clear it to a colour'
status: todo
type: task
created_at: 2026-03-13T19:54:44Z
updated_at: 2026-03-13T19:54:44Z
parent: edu-4u7w
---
Write the first hands-on exercise: create a winit window, initialise a wgpu surface, and clear it to a solid colour each frame. Walk through Instance → Adapter → Device → Surface → RenderPass with annotated Rust code. The GPU hello world. Part 2 of the Shader Programming chapter.

@ -0,0 +1,11 @@
---
# edu-7do4
title: 'Write §2: Character-level tokenisation'
status: todo
type: task
created_at: 2026-03-13T22:01:48Z
updated_at: 2026-03-13T22:01:48Z
parent: edu-u2w7
---
Explain BPE vs byte-level vs character-level. Motivate character-level as the simplest choice for a from-scratch exercise. Show vocabulary construction.

@ -0,0 +1,11 @@
---
# edu-7lu6
title: 'Write §12: Exercise 4 — replace rollout with the value network'
status: todo
type: task
created_at: 2026-03-13T20:03:17Z
updated_at: 2026-03-13T20:03:17Z
parent: edu-coqp
---
Exercise: substitute random rollout in MCTS with a neural-network value estimate; compare strength before and after.

@ -0,0 +1,11 @@
---
# edu-7m8d
title: '§18 Resources: Learn WGPU, Shadertoy, The Book of Shaders'
status: todo
type: task
created_at: 2026-03-13T19:55:12Z
updated_at: 2026-03-13T19:55:12Z
parent: edu-4u7w
---
Write the resources and next-steps section: links and descriptions for the Learn WGPU tutorial, Shadertoy for experimentation, The Book of Shaders for mathematical foundations, and any other curated pointers. Part 6 of the Shader Programming chapter.

@ -0,0 +1,11 @@
---
# edu-9cnd
title: 'Write §6: The Transformer block'
status: todo
type: task
created_at: 2026-03-13T22:01:55Z
updated_at: 2026-03-13T22:01:55Z
parent: edu-u2w7
---
Attention sublayer + 2-layer feed-forward network + residual connections + layer norm. Describe the GPT-1 block layout. Diagrams encouraged.

@ -0,0 +1,11 @@
---
# edu-9lda
title: '§16 Post-processing effects (bloom, blur): conceptual overview'
status: todo
type: task
created_at: 2026-03-13T19:55:11Z
updated_at: 2026-03-13T19:55:11Z
parent: edu-4u7w
---
Write the conceptual overview of post-processing: render to texture (off-screen framebuffer), Gaussian blur as a separable two-pass compute shader, bloom as blur applied to bright regions. No full exercise — reading only. Part 6 of the Shader Programming chapter.

@ -0,0 +1,11 @@
---
# edu-9sb7
title: 'Write §14: Further reading'
status: todo
type: task
created_at: 2026-03-13T22:02:08Z
updated_at: 2026-03-13T22:02:08Z
parent: edu-u2w7
---
Curated pointers: Attention is All You Need paper, GPT-1 paper, Karpathy's nanoGPT, candle docs, The Illustrated Transformer blog post.

@ -0,0 +1,11 @@
---
# edu-abdu
title: 'Write §10: Cross-entropy loss and the training loop'
status: todo
type: task
created_at: 2026-03-13T22:02:02Z
updated_at: 2026-03-13T22:02:02Z
parent: edu-u2w7
---
Next-token prediction loss: cross-entropy over the vocab. Adam optimiser. Training loop structure: batch → forward → loss → backward → step. No bells and whistles.

@ -0,0 +1,11 @@
---
# edu-brtk
title: 'Write §14: Exercise 5 — 1000 self-play games; observe improvement'
status: todo
type: task
created_at: 2026-03-13T20:03:17Z
updated_at: 2026-03-13T20:03:17Z
parent: edu-coqp
---
Capstone exercise: run the full self-play loop for 1000 games; plot win-rate over iterations; discuss what worked and what didn't.

@ -0,0 +1,11 @@
---
# edu-bycd
title: §11 Texture coordinates (UVs), texture creation, sampler config
status: todo
type: task
created_at: 2026-03-13T19:54:56Z
updated_at: 2026-03-13T19:54:56Z
parent: edu-4u7w
---
Write the lesson on textures: UV coordinates, wgpu texture creation from image data, TextureView, Sampler configuration (filter modes, address modes), and bind group layout for textures. Part 4 of the Shader Programming chapter.

@ -1,11 +1,11 @@
---
# edu-coqp
title: 'edu: write Machine Learning chapter (self-play game AI, Alpha Go Zero style)'
status: todo
type: task
status: in-progress
type: feature
priority: low
created_at: 2026-03-10T23:30:01Z
updated_at: 2026-03-10T23:30:01Z
updated_at: 2026-03-13T20:03:44Z
---
## Background

@ -0,0 +1,11 @@
---
# edu-cr0w
title: '§10 Exercise 3: animate the triangle using a time uniform'
status: todo
type: task
created_at: 2026-03-13T19:54:54Z
updated_at: 2026-03-13T19:54:54Z
parent: edu-4u7w
---
Write the exercise to animate the coloured triangle: introduce uniform buffers, upload a time value each frame, rotate or pulse the triangle in the vertex shader using the time uniform. Introduces the uniform/bind-group pattern. Part 3 of the Shader Programming chapter.

@ -0,0 +1,11 @@
---
# edu-cw9v
title: 'Write §4: Embeddings and positional encoding'
status: todo
type: task
created_at: 2026-03-13T22:01:52Z
updated_at: 2026-03-13T22:01:52Z
parent: edu-u2w7
---
Token embedding table (vocab_size × d_model). Learned positional embeddings (GPT-1 style). Explain why position matters for attention.

@ -0,0 +1,11 @@
---
# edu-e39n
title: 'Write §5: Representing game state in Rust'
status: todo
type: task
created_at: 2026-03-13T20:03:17Z
updated_at: 2026-03-13T20:03:17Z
parent: edu-coqp
---
Reading lesson: design of Board, Player, Move types. Discuss representation trade-offs (bitboard vs array). Show the full type definitions.

@ -0,0 +1,11 @@
---
# edu-exby
title: '§15 Exercise 5: GPU-accelerate a particle simulation'
status: todo
type: task
created_at: 2026-03-13T19:55:05Z
updated_at: 2026-03-13T19:55:05Z
parent: edu-4u7w
---
Write the compute shader exercise: implement an N-body or simple gravity particle simulation. Store particle positions and velocities in storage buffers, update them in a compute shader each frame, render the result as points. Part 5 of the Shader Programming chapter.

@ -0,0 +1,11 @@
---
# edu-ga8p
title: §8 Interpolation and the fragment shader
status: todo
type: task
created_at: 2026-03-13T19:54:50Z
updated_at: 2026-03-13T19:54:50Z
parent: edu-4u7w
---
Write the lesson on rasterisation and interpolation: how values output from the vertex shader are interpolated across fragments, what the fragment shader receives and outputs (colour), and how the pipeline assembles a final image. Part 3 of the Shader Programming chapter.

@ -0,0 +1,11 @@
---
# edu-hrfy
title: '§6 The render loop: swap chains, frames, command encoders'
status: todo
type: task
created_at: 2026-03-13T19:54:44Z
updated_at: 2026-03-13T19:54:44Z
parent: edu-4u7w
---
Write the lesson on the wgpu render loop: SurfaceTexture acquisition, CommandEncoder, RenderPass, queue submission, present. Explain double/triple buffering conceptually. Part 2 of the Shader Programming chapter.

@ -0,0 +1,11 @@
---
# edu-hufe
title: 'Write §7: Exercise 2 — implement self-attention in Rust'
status: todo
type: task
created_at: 2026-03-13T22:01:56Z
updated_at: 2026-03-13T22:01:56Z
parent: edu-u2w7
---
Implement scaled dot-product attention using candle tensors. Single head, causal mask, softmax, output projection. Reader writes the core attention function.

@ -0,0 +1,11 @@
---
# edu-i76z
title: 'Write §12: Exercise 5 — sample from the model'
status: todo
type: task
created_at: 2026-03-13T22:02:05Z
updated_at: 2026-03-13T22:02:05Z
parent: edu-u2w7
---
Temperature sampling and greedy decoding. Prompt the trained model and decode character-by-character. Compare output at different training checkpoints.

@ -0,0 +1,11 @@
---
# edu-iv0k
title: 'Write §9: Neural network architecture overview'
status: todo
type: task
created_at: 2026-03-13T20:03:17Z
updated_at: 2026-03-13T20:03:17Z
parent: edu-coqp
---
Conceptual lesson: shared convolutional trunk, policy head (move probabilities), value head (win probability). Diagrams encouraged. No code yet.

@ -0,0 +1,11 @@
---
# edu-j35d
title: §4 What is wgpu? Cross-platform graphics API in Rust
status: todo
type: task
created_at: 2026-03-13T19:54:43Z
updated_at: 2026-03-13T19:54:43Z
parent: edu-4u7w
---
Write the wgpu introduction: what it is, how it maps to WebGPU/Vulkan/Metal/D3D12, the key types (Instance, Adapter, Device, Queue, Surface), and how it differs from OpenGL. Part 2 of the Shader Programming chapter.

@ -0,0 +1,11 @@
---
# edu-jybf
title: 'Write §11: Exercise 4 — train on a small text corpus'
status: todo
type: task
created_at: 2026-03-13T22:02:04Z
updated_at: 2026-03-13T22:02:04Z
parent: edu-u2w7
---
Use a small public-domain text (e.g. Shakespeare's sonnets or a children's book). Show data loading, batching with random windows, training loop, loss curve. Reader runs training and watches loss fall.

@ -0,0 +1,11 @@
---
# edu-k3tq
title: 'Write §4: Choosing a simple game — Tic-Tac-Toe'
status: todo
type: task
created_at: 2026-03-13T20:03:17Z
updated_at: 2026-03-13T20:03:17Z
parent: edu-coqp
---
Explain why Tic-Tac-Toe is ideal: small state space, deterministic, zero-sum, easily verifiable. Foreshadow how the same approach scales to Go/Chess.

@ -0,0 +1,11 @@
---
# edu-kkjc
title: 'Write §13: What limits this model?'
status: todo
type: task
created_at: 2026-03-13T22:02:07Z
updated_at: 2026-03-13T22:02:07Z
parent: edu-u2w7
---
Honest assessment: context length, data size, model capacity, compute. Explain why GPT-1 was a big deal in 2018 and what GPT-2/3/4 changed. No code.

@ -0,0 +1,11 @@
---
# edu-lqky
title: 'Write §11: Exercise 3 — train the network on MCTS data'
status: todo
type: task
created_at: 2026-03-13T20:03:17Z
updated_at: 2026-03-13T20:03:17Z
parent: edu-coqp
---
Exercise: generate training examples (state, policy vector, value) from pure MCTS self-play; run one training epoch; log loss.

@ -0,0 +1,11 @@
---
# edu-of9y
title: 'Write §7: Implementing MCTS in Rust'
status: todo
type: task
created_at: 2026-03-13T20:03:17Z
updated_at: 2026-03-13T20:03:17Z
parent: edu-coqp
---
Walk through selection (UCB1 formula), expansion, simulation (random rollout), backpropagation. Show Rust code for the node structure and the four phases.

@ -0,0 +1,11 @@
---
# edu-pvou
title: 'Write §10: Integrating a neural network crate'
status: todo
type: task
created_at: 2026-03-13T20:03:17Z
updated_at: 2026-03-13T20:03:17Z
parent: edu-coqp
---
Reading lesson: evaluate tch-rs vs candle for this use case; show how to define and initialise the network; basic forward-pass usage.

@ -0,0 +1,11 @@
---
# edu-r52d
title: '§2 The programmable pipeline: vertex, fragment, compute shaders'
status: todo
type: task
created_at: 2026-03-13T19:54:39Z
updated_at: 2026-03-13T19:54:39Z
parent: edu-4u7w
---
Write the lesson on the programmable graphics pipeline: what happens at each stage, which stages are programmable, what vertex and fragment shaders each receive and output, and where compute shaders fit. Part 1 of the Shader Programming chapter.

@ -0,0 +1,11 @@
---
# edu-s6mr
title: 'Write §5: Self-attention — queries, keys, and values'
status: todo
type: task
created_at: 2026-03-13T22:01:53Z
updated_at: 2026-03-13T22:01:53Z
parent: edu-u2w7
---
Derive the scaled dot-product attention formula from first principles. Single-head attention only (GPT-1 simplicity). Causal masking explained here.

@ -0,0 +1,11 @@
---
# edu-tufd
title: 'Write §3: Exercise 1 — build a character-level tokeniser in Rust'
status: todo
type: task
created_at: 2026-03-13T22:01:50Z
updated_at: 2026-03-13T22:01:50Z
parent: edu-u2w7
---
Implement encode/decode over a fixed character vocabulary. Read a text file, build vocab, encode to integers, decode back. No external crates.

@ -1,11 +1,11 @@
---
# edu-u2w7
title: 'edu: write chapter on creating and training a simple LLM'
status: todo
type: task
status: in-progress
type: feature
priority: low
created_at: 2026-03-10T23:30:00Z
updated_at: 2026-03-10T23:30:00Z
updated_at: 2026-03-13T22:01:43Z
---
## Background

@ -0,0 +1,11 @@
---
# edu-ujs5
title: 'Write §9: Exercise 3 — define the GPT-1-style model in candle'
status: todo
type: task
created_at: 2026-03-13T22:02:00Z
updated_at: 2026-03-13T22:02:00Z
parent: edu-u2w7
---
Full model struct in candle: embedding, N transformer blocks, layer norm, unembedding. Hyperparams close to GPT-1 mini (e.g. 24 layers, d_model=128). Reader assembles the forward pass.

@ -0,0 +1,11 @@
---
# edu-uxa1
title: §14 Storage buffers and read/write access from WGSL
status: todo
type: task
created_at: 2026-03-13T19:55:04Z
updated_at: 2026-03-13T19:55:04Z
parent: edu-4u7w
---
Write the lesson on storage buffers: var<storage, read_write> in WGSL, creating STORAGE | COPY_SRC buffers in Rust, reading results back to CPU, and the difference between uniform and storage buffers. Part 5 of the Shader Programming chapter.

@ -0,0 +1,11 @@
---
# edu-vqxk
title: 'Write §8: A decoder-only LM — stacking blocks and the causal mask'
status: todo
type: task
created_at: 2026-03-13T22:01:58Z
updated_at: 2026-03-13T22:01:58Z
parent: edu-u2w7
---
Explain how N transformer blocks are stacked. Causal mask ensures each position only attends to past tokens. Tie weights to the unembedding matrix (GPT-1 style). Final linear + softmax for logits.

@ -0,0 +1,11 @@
---
# edu-wobk
title: 'Write §1: What is reinforcement learning?'
status: todo
type: task
created_at: 2026-03-13T20:03:17Z
updated_at: 2026-03-13T20:03:17Z
parent: edu-coqp
---
Cover: state, action, reward, policy, value function. Intuitive explanation with a game-playing example. No code.

@ -0,0 +1,11 @@
---
# edu-xv9j
title: '§12 Exercise 4: render a textured quad'
status: todo
type: task
created_at: 2026-03-13T19:54:58Z
updated_at: 2026-03-13T19:54:58Z
parent: edu-4u7w
---
Write the exercise to render a textured quad: two triangles forming a rectangle, UV coordinates per vertex, load an image with the image crate, upload to a wgpu texture, sample it in the fragment shader. Part 4 of the Shader Programming chapter.

@ -0,0 +1,11 @@
---
# edu-ymux
title: 'Write §6: Exercise 1 — implement Tic-Tac-Toe game logic'
status: todo
type: task
created_at: 2026-03-13T20:03:17Z
updated_at: 2026-03-13T20:03:17Z
parent: edu-coqp
---
Hands-on exercise: move generation, win detection, terminal-state check, displaying the board. Include starter code and expected test output.

@ -17,3 +17,12 @@
# Compilers
- [Writing a Lisp-to-C Compiler in Rust](lisp-compiler.md)
# Graphics
- [Shader Programming with wgpu and WGSL](shaders.md)
# Machine Learning
- [Training a Game AI Through Self-Play](ml-self-play.md)
- [Building a Simple LLM from Scratch](llm-from-scratch.md)

@ -0,0 +1,79 @@
# Building a Simple LLM from Scratch
A hands-on course building a small GPT-1-style language model in Rust — from raw text to a trained, sampling transformer.
---
## Part 1 — Language Modeling Basics
### §1 What is a Language Model?
🚧 *To be written — see [edu-32xl]*
### §2 Character-Level Tokenisation
🚧 *To be written — see [edu-7do4]*
### §3 Exercise 1: Build a Character-Level Tokeniser in Rust
🚧 *To be written — see [edu-tufd]*
---
## Part 2 — The Transformer Architecture
### §4 Embeddings and Positional Encoding
🚧 *To be written — see [edu-cw9v]*
### §5 Self-Attention: Queries, Keys, and Values
🚧 *To be written — see [edu-s6mr]*
### §6 The Transformer Block
🚧 *To be written — see [edu-9cnd]*
### §7 Exercise 2: Implement Self-Attention in Rust
🚧 *To be written — see [edu-hufe]*
---
## Part 3 — Assembling the Model
### §8 A Decoder-Only LM: Stacking Blocks and the Causal Mask
🚧 *To be written — see [edu-vqxk]*
### §9 Exercise 3: Define the GPT-1-Style Model in `candle`
🚧 *To be written — see [edu-ujs5]*
---
## Part 4 — Training
### §10 Cross-Entropy Loss and the Training Loop
🚧 *To be written — see [edu-abdu]*
### §11 Exercise 4: Train on a Small Text Corpus
🚧 *To be written — see [edu-jybf]*
### §12 Exercise 5: Sample from the Model
🚧 *To be written — see [edu-i76z]*
---
## Part 5 — Reflection
### §13 What Limits This Model?
🚧 *To be written — see [edu-kkjc]*
### §14 Further Reading
🚧 *To be written — see [edu-9sb7]*

@ -0,0 +1,130 @@
# Machine Learning: Training a Game AI Through Self-Play
This is a self-guided course on reinforcement learning through the lens of a concrete goal: training a Rust program to play Tic-Tac-Toe by playing against itself, in the style of AlphaGo Zero. No prior ML experience is assumed. You will build everything from scratch — a game engine, a search algorithm, and eventually a neural network that guides that search. Sections marked 🚧 are stubs whose full content is tracked in a beans ticket.
---
## Table of Contents
**Part 1 — Foundations**
1. [What is reinforcement learning?](#1-what-is-reinforcement-learning)
2. [Monte Carlo Tree Search — algorithm explained](#2-monte-carlo-tree-search--algorithm-explained)
3. [Why self-play? The AlphaGo Zero insight](#3-why-self-play-the-alphago-zero-insight)
**Part 2 — The Game**
4. [Choosing a simple game: Tic-Tac-Toe](#4-choosing-a-simple-game-tic-tac-toe)
5. [Representing game state in Rust](#5-representing-game-state-in-rust)
6. [Exercise 1: implement the game logic](#6-exercise-1-implement-the-game-logic)
**Part 3 — MCTS**
7. [Implementing MCTS in Rust](#7-implementing-mcts-in-rust)
8. [Exercise 2: play Tic-Tac-Toe with pure MCTS](#8-exercise-2-play-tic-tac-toe-with-pure-mcts)
**Part 4 — Neural Network Policy/Value Head**
9. [Neural network architecture overview](#9-neural-network-architecture-overview)
10. [Integrating a neural network crate](#10-integrating-a-neural-network-crate)
11. [Exercise 3: train the network on MCTS data](#11-exercise-3-train-the-network-on-mcts-data)
12. [Exercise 4: replace rollout with the value network](#12-exercise-4-replace-rollout-with-the-value-network)
**Part 5 — Self-Play Loop**
13. [The full AlphaGo Zero training loop](#13-the-full-alphago-zero-training-loop)
14. [Exercise 5: 1000 self-play games; observe improvement](#14-exercise-5-1000-self-play-games-observe-improvement)
---
## Part 1 — Foundations
### 1. What is reinforcement learning?
🚧 This section is a stub. Full content tracked in [edu-wobk].
---
### 2. Monte Carlo Tree Search — algorithm explained
🚧 This section is a stub. Full content tracked in [edu-3yw9].
---
### 3. Why self-play? The AlphaGo Zero insight
🚧 This section is a stub. Full content tracked in [edu-5go8].
---
## Part 2 — The Game
### 4. Choosing a simple game: Tic-Tac-Toe
🚧 This section is a stub. Full content tracked in [edu-k3tq].
---
### 5. Representing game state in Rust
🚧 This section is a stub. Full content tracked in [edu-e39n].
---
### 6. Exercise 1: implement the game logic
🚧 This section is a stub. Full content tracked in [edu-ymux].
---
## Part 3 — MCTS
### 7. Implementing MCTS in Rust
🚧 This section is a stub. Full content tracked in [edu-of9y].
---
### 8. Exercise 2: play Tic-Tac-Toe with pure MCTS
🚧 This section is a stub. Full content tracked in [edu-4v13].
---
## Part 4 — Neural Network Policy/Value Head
### 9. Neural network architecture overview
🚧 This section is a stub. Full content tracked in [edu-iv0k].
---
### 10. Integrating a neural network crate
🚧 This section is a stub. Full content tracked in [edu-pvou].
---
### 11. Exercise 3: train the network on MCTS data
🚧 This section is a stub. Full content tracked in [edu-lqky].
---
### 12. Exercise 4: replace rollout with the value network
🚧 This section is a stub. Full content tracked in [edu-7lu6].
---
## Part 5 — Self-Play Loop
### 13. The full AlphaGo Zero training loop
🚧 This section is a stub. Full content tracked in [edu-453h].
---
### 14. Exercise 5: 1000 self-play games; observe improvement
🚧 This section is a stub. Full content tracked in [edu-brtk].

@ -0,0 +1,163 @@
# Shader Programming with wgpu and WGSL
This document is a self-guided course on GPU shader programming. It is organised into six parts: the GPU execution model, setting up with `wgpu`, vertex and fragment shaders, textures and samplers, compute shaders, and a look at where to go next. Each section is either a reading lesson or a hands-on Rust programming exercise. Sections marked 🚧 are stubs whose full content is tracked in a beans ticket — follow the ticket ID to find the detailed learning objectives and instructions.
---
## Table of Contents
**Part 1 — The GPU and the Graphics Pipeline**
1. [CPU vs GPU: parallel execution model](#1-cpu-vs-gpu-parallel-execution-model)
2. [The programmable pipeline: vertex, fragment, compute shaders](#2-the-programmable-pipeline-vertex-fragment-compute-shaders)
3. [What is WGSL? Syntax overview](#3-what-is-wgsl-syntax-overview)
**Part 2 — Setting Up with wgpu**
4. [What is wgpu? Cross-platform graphics API in Rust](#4-what-is-wgpu-cross-platform-graphics-api-in-rust)
5. [Exercise 1: create a window and clear it to a colour](#5-exercise-1-create-a-window-and-clear-it-to-a-colour)
6. [The render loop: swap chains, frames, command encoders](#6-the-render-loop-swap-chains-frames-command-encoders)
**Part 3 — Vertex and Fragment Shaders**
7. [Vertices, buffers, and the vertex shader](#7-vertices-buffers-and-the-vertex-shader)
8. [Interpolation and the fragment shader](#8-interpolation-and-the-fragment-shader)
9. [Exercise 2: draw a coloured triangle](#9-exercise-2-draw-a-coloured-triangle)
10. [Exercise 3: animate the triangle using a time uniform](#10-exercise-3-animate-the-triangle-using-a-time-uniform)
**Part 4 — Textures and Samplers**
11. [Texture coordinates (UVs), texture creation, sampler config](#11-texture-coordinates-uvs-texture-creation-sampler-config)
12. [Exercise 4: render a textured quad](#12-exercise-4-render-a-textured-quad)
**Part 5 — Compute Shaders**
13. [Compute pipelines: dispatching work groups](#13-compute-pipelines-dispatching-work-groups)
14. [Storage buffers and read/write access from WGSL](#14-storage-buffers-and-readwrite-access-from-wgsl)
15. [Exercise 5: GPU-accelerate a particle simulation](#15-exercise-5-gpu-accelerate-a-particle-simulation)
**Part 6 — Going Further**
16. [Post-processing effects (bloom, blur): conceptual overview](#16-post-processing-effects-bloom-blur-conceptual-overview)
17. [Signed Distance Fields for font rendering](#17-signed-distance-fields-for-font-rendering)
18. [Resources: Learn WGPU, Shadertoy, The Book of Shaders](#18-resources-learn-wgpu-shadertoy-the-book-of-shaders)
---
## Part 1 — The GPU and the Graphics Pipeline
### 1. CPU vs GPU: parallel execution model
🚧 This section is a stub. Full content tracked in [edu-5g0l].
---
### 2. The programmable pipeline: vertex, fragment, compute shaders
🚧 This section is a stub. Full content tracked in [edu-r52d].
---
### 3. What is WGSL? Syntax overview
🚧 This section is a stub. Full content tracked in [edu-2ak3].
---
## Part 2 — Setting Up with wgpu
### 4. What is wgpu? Cross-platform graphics API in Rust
🚧 This section is a stub. Full content tracked in [edu-j35d].
---
### 5. Exercise 1: create a window and clear it to a colour
🚧 This section is a stub. Full content tracked in [edu-6jjp].
---
### 6. The render loop: swap chains, frames, command encoders
🚧 This section is a stub. Full content tracked in [edu-hrfy].
---
## Part 3 — Vertex and Fragment Shaders
### 7. Vertices, buffers, and the vertex shader
🚧 This section is a stub. Full content tracked in [edu-3l9h].
---
### 8. Interpolation and the fragment shader
🚧 This section is a stub. Full content tracked in [edu-ga8p].
---
### 9. Exercise 2: draw a coloured triangle
🚧 This section is a stub. Full content tracked in [edu-10m1].
---
### 10. Exercise 3: animate the triangle using a time uniform
🚧 This section is a stub. Full content tracked in [edu-cr0w].
---
## Part 4 — Textures and Samplers
### 11. Texture coordinates (UVs), texture creation, sampler config
🚧 This section is a stub. Full content tracked in [edu-bycd].
---
### 12. Exercise 4: render a textured quad
🚧 This section is a stub. Full content tracked in [edu-xv9j].
---
## Part 5 — Compute Shaders
### 13. Compute pipelines: dispatching work groups
🚧 This section is a stub. Full content tracked in [edu-2sqo].
---
### 14. Storage buffers and read/write access from WGSL
🚧 This section is a stub. Full content tracked in [edu-uxa1].
---
### 15. Exercise 5: GPU-accelerate a particle simulation
🚧 This section is a stub. Full content tracked in [edu-exby].
---
## Part 6 — Going Further
### 16. Post-processing effects (bloom, blur): conceptual overview
🚧 This section is a stub. Full content tracked in [edu-9lda].
---
### 17. Signed Distance Fields for font rendering
🚧 This section is a stub. Full content tracked in [edu-1nox].
---
### 18. Resources: Learn WGPU, Shadertoy, The Book of Shaders
🚧 This section is a stub. Full content tracked in [edu-7m8d].
Loading…
Cancel
Save