Project 4 of 12, for Aaesha
Value Estimator
The worth of every tile, learned from races alone with no map, the way animals learn from surprise: Monte Carlo and temporal difference learning.
Sign up free to open itLog in
Act 8 needs a free account, so your work is saved as you go. Act 1 is open to everyone.
The brief
- AaeshaYour figures for the grid are right, on paper anyway.
- AaeshaBut the crab in the cabinet never sees the paper, it just races and adjusts whenever something surprises it.
- YahyaThen let it race and check the races against the paper, because that's how you'll actually know.
- PaulThere are two ways to learn from races alone, and both of them should end up near the map.
Write learn.py. The crab gets no map: nothing in it may read outcomes. All it has is step(tile, action, rng) from track.py, which takes one real step and tells it where it landed, what it earned, and whether the race is over. Practice races start on a random tile, random_start(rng).
episode(policy, rng, start, limit=100): one race, as a list of(tile, action, reward).returns_from(rewards, gamma=0.9): the return from every step of a race.mc_evaluate(policy, races, rng, gamma=0.9): Monte Carlo. A tile's worth is the average of every return that followed it.td_update(values, tile, reward, after, over, alpha=0.1, gamma=0.9): one TD(0) update, in place; returns the TD error.td_evaluate(policy, races, rng, alpha=0.1, gamma=0.9, limit=100): TD(0), updating after every step.
Run as a program, it learns the traditional line's values both ways from 2000 races each, and compares them with the values evaluate (from your dp.py) works out from the map.
The traditional line, worked out from the map 4.5 6.7 9.1 0.0 2.7 # 5.1 0.0 -7.6 -8.6 -8.4 -9.8 Monte Carlo, 2000 races 4.4 6.7 9.1 0.0 2.6 # 5.2 0.0 -7.5 -8.6 -8.6 -9.9 Furthest from the map: 0.18 TD(0), 2000 races 4.6 6.7 8.8 0.0 2.8 # 3.6 0.0 -6.9 -8.9 -9.2 -10.0 Furthest from the map: 1.45
What you learn
What's in it
- Racing without the map
- Race to the end, then look back
- What followed each tile
- Learning from a guess
- Learning from a guess
- How the news travels
- How Paul would do it
- Fix Caitlin's version
- Make it learn by racing
- The wobble
- Ship it