Paul's Python CoursePPC

Project 12 of 12, for Caitlin

Arcade League

The capstone: a crab that learns whatever course Caitlin's generator lays out, on a budget of practice, judged on courses nobody has seen, and entered in the weekly Arcade League.

About 10 hours, in 9 steps.

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

  • CaitlinWelcome to the Arcade League, where everyone's crab races every week on one leaderboard.
  • CaitlinTerm ends with the final, on a new course made that morning from a seed nobody knows.
  • AaeshaYou get five thousand practice moves before the races, and the fewest moves wins. It's all in the rules.
  • YahyaI've been practising.
  • PaulSo the crab can't learn the course beforehand, it has to learn how to learn one.

A crab that races well on a course nobody has seen, in three files.

  1. course.py, the League's rules. generate(seed, rows=7, cols=9) lays out rocks, rock pools and two groynes, the same course for the same seed, always with a way through. Course(layout) knows its rules; race(course, policy, rng) counts the moves of one race; Practice(course, budget, rng) is the course as the crab meets it, with no map and a budget of moves.
  2. crab.py. train(practice, rng) practises until the League says stop, and returns a policy: rows of actions from 0 to 3, a move for every tile.
  3. race_day.py. Two baselines, the gull line and the shortest line; a table of results on courses it trained on and on courses kept back; a race to watch; and league.json, its entry for the Arcade League on the League course.

On a course it has never seen, given 5000 practice moves, it must finish at least 190 races in 200, and average within a quarter of par: the moves the shortest line takes.

Entering the Arcade League is up to you. Any league.json you save appears on the league page, /league, and only goes into the weekly table if you enter it.

What it prints
Training courses
Course 1: 19.1 moves, 200 of 200 finished (par 18.9, the gull 98.3)
Course 2: 17.4 moves, 200 of 200 finished (par 18.1, the gull 92.5)
Course 3: 12.7 moves, 200 of 200 finished (par 14.2, the gull 43.1)
Courses it has never seen
Course 101: 18.1 moves, 200 of 200 finished (par 18.0, the gull 99.1)
Course 102: 13.6 moves, 200 of 200 finished (par 14.1, the gull 81.1)
The League course: 15.5 moves, 200 of 200 finished
Saved league.json for the Arcade League.

What's in it

  1. Race-day rules
  2. The course
  3. A hopeful first guess
  4. More lessons from every move
  5. The crab
  6. Race day
  7. Aaesha's race-day checklist
  8. Ship it