Commit Graph

12 Commits

Author SHA1 Message Date
Chris Proctor
d83a3b7e4b Update questions 2026-06-26 21:30:22 -04:00
Chris Proctor
482f4f6cfa Updates 2026-06-26 20:59:25 -04:00
Chris Proctor
a9385f8296 Refactoring lab 2026-06-26 13:27:11 -04:00
Chris Proctor
e752bb848b Refactor lab 2026-06-25 21:10:13 -04:00
Chris Proctor
8294311d4b Make the board bigger 2026-06-25 13:01:56 -04:00
Chris Proctor
048cb1c02b Babysnake training works 2026-06-25 13:00:03 -04:00
Chris Proctor
aeb610d04b Pin published retro-gamer 0.2.0 and retro-games 2.4.0
Drop the local editable path overrides now that retro-gamer 0.2.0
(with observation_function) is published, and bump retro-games to the
version it requires.
2026-06-24 07:50:46 -04:00
Chris Proctor
edbf76071e Migrate snake example to observation_function and refresh its training run
The egocentric/egocentric_player/egocentric_radius flags were removed
from retro_gamer in favor of an explicit observation_function.
snake_observation.py reproduces the old egocentric+board+extras
behavior by calling egocentric_board/encode_board/encode_state
directly, and runs/snake/config.toml now points at it.

That config change made the prior 12,000-episode checkpoint history
incompatible (retro_gamer's checkpoint compatibility checker can't
verify a new observation_function is behaviorally equivalent to the
old flags, so it conservatively refuses to resume), so the old
checkpoints were deleted and a fresh 20,000-episode run was recorded.
Track only the four checkpoints the lab actually references
(ep_1300, ep_2300, ep_4000, ep_20000) instead of all 200, and update
.gitignore so future student runs of runs/snake aren't committed by
default. snake_training.md's Q5 training-curve table and Q6 checkpoint
episodes are updated to match the real numbers from this run.
2026-06-24 07:50:41 -04:00
Chris Proctor
e8a24ae7be Split q_learning.py into algorithm, environment glue, and a training script
q_learning.py mixed a bespoke BabySnake environment wrapper, the two
functions students implement, a training loop, and a terminal watch
routine in one file, with no tests and no single command to run
training.

- q_learning.py / q_learning_solution.py now hold only choose_action
  and update_q, with actions as an explicit parameter instead of a
  module-global, so the file has no babysnake/retro/retro_gamer
  imports at all.
- train_babysnake.py builds GameEnvironment directly from babysnake's
  pyproject metadata, trains, and watches the trained agent in one
  command: `python train_babysnake.py`. It also caps steps per
  episode, since a lucky random walk that keeps finding food can
  otherwise make an episode run unboundedly long.
- test_q_learning.py adds unittest coverage for both functions with no
  game dependency.
- questions.md adds a checkpoint instructing students to get the tests
  passing before training, and points the post-training step at
  train_babysnake.py.
2026-06-24 07:50:28 -04:00
Chris Proctor
7788e34ebd Migrate babysnake to retro_gamer's observation_function
BabySnake's tabular Q-learning exercise needs a small discrete state,
not the flattened board encoding retro_gamer normally produces. Define
get_state(game) in babysnake_env.py, returning a plain
(agent_x, agent_y, food_x, food_y) tuple, and point babysnake's
observation_function at it instead of declaring a character_set.
Disable the on-screen state overlay so it doesn't clutter the
terminal watch view.
2026-06-24 07:50:20 -04:00
Chris Proctor
3d42de7b12 Give forager an energy mechanic so episodes terminate naturally
Previously the game ran indefinitely and relied entirely on
max_turns_per_episode to end an episode. Add start/food energy values
so an episode ends on its own when energy runs out, and mention
retro-gamer plot in the lab's training log instructions.
2026-06-24 07:50:14 -04:00
Chris Proctor
42bc2e7a50 Initial commit 2026-06-22 16:14:58 -04:00