Skip to content
Nat Lee

Keyboard shortcuts

Turn these off if they get in the way of a screen reader or voice control. The setting is saved in this browser.

1
Home
2
Work
3
Projects
4
About
5
Experience
/
Search projects
?
Show this panel

AI/ML

QWOP with PPO

Learning to finish, one knee-scoot at a time

A PyTorch PPO agent plays the real QWOP browser game through Playwright. Six evaluation races, six 100 m finishes. Grace was not part of the reward function.

Role
Creator & Maintainer
Period
2020.01 – 2026.11
Status
Completed
Categories
AI & machine learning
Stack
  • Python
  • PyTorch
  • Stable-Baselines3
  • Gymnasium
  • Playwright
  • PPO
QWOP with PPO, screenshot 1

Overview

Rebuilt in 2026 with Stable-Baselines3 PPO, PyTorch and a Gymnasium environment driving the official browser game through Playwright. Eight browser environments trained for 22 minutes. The recorded evaluation finished all six races; the best normal-speed game time was 193.8 seconds.

What it's good for

Shows how to train against a real browser game without a simulator or a modified game: Playwright presses the keys, a virtual clock makes every step exactly six frames, and the same keys replay the same race. A busy machine just plays slower, not differently.

Diagrams

Main paths only. The edge cases stayed in the code.

The finish screen said 19.4 seconds. It was 193.8.

Point at a box to see what it connects to.

  1. Look at the runner(84x84 grayscale, last 4 stacked) → Hold one of nine key combos
  2. Hold one of nine key combos(Q/W thighs, O/P calves) → Advance exactly six frames
  3. Advance exactly six frames(0.1 s on a virtual clock) → Read the distance with OCR
  4. Read the distance with OCR(Jumps over 2 m ignored) → Reward metres gained, minus time
  5. Reward metres gained, minus time(+1 a metre, -0.002 a step) → Race over?
  6. Race over?(End panel, stall or 15 min) → yes: How did it end? → no: 256 steps per browser yet?
  7. How did it end? → finished: Add 50 for the finish → fell: Subtract 2 for the fall → cut short: Press R, race again
  8. Add 50 for the finish → Third finish?
  9. Third finish? → yes: Stop training → not yet: Press R, race again
  10. Subtract 2 for the fall(Small, or it freezes) → Press R, race again
  11. Press R, race again(Same page, no reload) → 256 steps per browser yet?
  12. 256 steps per browser yet? → yes: PPO updates the policy → no: Look at the runner
  13. PPO updates the policy(4 epochs, batches of 512) → Look at the runner
  14. Stop training(Main run: 22 minutes)

Features

  • Official QWOP game in headless Chromium
  • Eight parallel training environments
  • OCR distance feedback and shaped rewards
  • Training curves, checkpoints and run GIFs

The problem

  • Learning a stable gait from browser-game observations
  • Measuring normal-speed game time consistently

What I did

  • PPO with a Gymnasium environment and Playwright controls
  • Fixed 60-frame game seconds and explicit evaluation records

Results

  • Completed 100 m in all six recorded evaluation races
  • Best normal-speed game time: 193.8 seconds
  • Training run: 22 minutes across eight browser environments
A 200.2-second race at 4x speed: the trained agent knee-scoots the whole 100 m
A 200.2-second race at 4x speed: the trained agent knee-scoots the whole 100 m

What I learned

  • The finish screen shows a tenth of the real time, so '19.4 seconds' was a 193.8-second race.
  • Judging a finish by the score at the top booked 7 races that ended at 99.5 to 99.9 m as falls; now the end screen decides.
  • Skipping WebGL draw calls on frames between observations made stepping about 40% faster without changing the race.
  • First 20 seconds: after 2 minutes of training it does the splits; after 22 it moves on
    First 20 seconds: after 2 minutes of training it does the splits; after 22 it moves on
  • Learning curve: the best race reaches 100 m after 16 minutes; the average nears 60 m
    Learning curve: the best race reaches 100 m after 16 minutes; the average nears 60 m
  • The 2020 agent's finish screen: 592.1 on it, probably about 99 real minutes
    The 2020 agent's finish screen: 592.1 on it, probably about 99 real minutes
  • Work · HD Renewables
    Energy & forecastingAI & machine learning

    Solar Power Prediction System

    Time-series models that forecast solar output for an energy-storage demonstration site, scheduled with Airflow. The sun is punctual; the clouds are the problem. The dashboards here are redrawn on simulated data.

    2023Completed
  • Work · HD Renewables
    Energy & forecastingAI & machine learning

    Japan Power Trading Dashboard

    Spot-price forecasting and trading strategies for the Japanese power market, later extended to Australia.

    2024Active
  • Vision & imagingAI & machine learning11 stars on GitHub

    Street Scene OCR

    Compare EasyOCR, RapidOCR and PaddleOCR on Traditional Chinese street signs, with text boxes, timings and a small public-domain benchmark.

    2026Completed