How to play

  • Space ↑ click or tap: the stork flaps once.
  • Let go and it glides down. Gravity never stops.
  • Fly through the gap between the minaret and the storm cloud. Touch either one, the ground or the top of the sky, and it's over.
  • M sound on or off · Esc back to the menu
  • Race the AI: a see-through stork flies next to you. It's an AI I trained, and it sees only 5 numbers. Pick your opponent, from Beginner to Seasoned.
  • Watch the AI: the AI flies alone. Turn on Lab view (below) to see what it's thinking.

Lab view

Curious how the AI thinks? Lab view shows the 5 numbers it sees, the gap it's aiming for, a trail of where it flapped, the reward it's trying to maximise and the real hitboxes. Press L at any time.

Medals

  • Bronze10 minarets
  • Silver20 minarets
  • Gold30 minarets
  • Emerald40 minarets

Each medal is the eight-pointed star from Moroccan zellige tiles.

Levels

GapSpeed
Easy180 px3 px per step
Medium155 px3.5 px per step
Hard130 px4 px per step

Tip: tap in small, steady rhythms. Big panicky bursts shoot you into the clouds.

Your stork

Win medals to unlock new storks. A medal on any level counts. Skins only change how your stork looks: the hitbox and the physics stay exactly the same.

About this game

Stork Flight is part of Morocco in Data, a set of projects where I use data and code to test ideas.

This game is an experiment in reinforcement learning. The exact same rules run in a Python environment, where an AI learned to fly from rewards alone: +1 for each minaret, −1 for a crash. Nobody told it to flap.

Same world, two players

The physics here match the training environment step for step: 30 steps per second, the same gravity, the same gaps. So your score and the AI's score mean the same thing.

The AIs in this game are real snapshots from training, running right in your browser. Beginner is an AI early in its training, and Seasoned is the best snapshot after up to a million steps of practice. Every opponent is a real point in the learning process; none of them was made worse on purpose.

The opponents in numbers

Average minarets passed on the same 20 test courses (the most possible in 100 seconds is 41 on Easy, 49 on Medium and 56 on Hard):

EasyMediumHard
Beginner13.811.116.4
Intermediate20.628.335.6
Experienced36.940.144.8
Seasoned41.049.047.9
My one-line rule41.043.026.9

The full experiment, with the training code and learning curves, is in the notebook on GitHub.

Made from scratch

Every drawing is made with code, the storks, minarets and medina wall. Every sound is made with code too, using the Web Audio API, with no recordings. White storks really do nest on minarets in Morocco, which is where the idea came from.

I wrote it with help from an AI coding assistant. The project idea, the experiments and the decisions are mine.

Code on GitHub ↗