← berkaykoklu.com

Difficulty depends on
who is playing

Studios tune level difficulty by watching bots play, because waiting for real players means shipping the wall before you know it is there. So I built the game, trained an agent on it, and asked how hard each level is. The answer was not a number. It was a number per player.

CLEAR RATE BY LEVEL

0%25%50%75%100%110203040
Randompicks any legal swapPPO 200ktrained 200,000 stepsPPO 2Mtrained 2,000,000 stepsGreedyone-move lookahead

RANDOM

49%

across all 40 levels

PPO 200K

56%

across all 40 levels

PPO 2M

59%

across all 40 levels

GREEDY

83%

across all 40 levels

Ten times the training moved the agent from 56% to 59%. A twenty-line greedy rule, which simply takes whichever swap clears the most target tiles right now, still reaches 83%. That gap is the honest result: PPO learns, more training helps, and in this environment a one-move heuristic is still ahead of it.

Watch the gap

Every player below is dealt the identical starting board, so what differs is the choices, not the luck. Averages hide what that looks like; the boards do not. These three deals are picked rather than drawn — an arbitrary seed gave three levels where everyone won or everyone lost, which illustrates nothing. The curves above are the measurement; these are one episode inside them.

LEVEL 324 TILES IN 25 MOVES

Random

picks any legal swap

cleared
0 / 24 tiles24 moves left

PPO 2M

trained 2,000,000 steps

cleared
0 / 24 tiles24 moves left

Greedy

one-move lookahead

cleared
0 / 24 tiles24 moves left

LEVEL 2042 TILES IN 21 MOVES

Random

picks any legal swap

cleared
0 / 42 tiles20 moves left

PPO 2M

trained 2,000,000 steps

cleared
0 / 42 tiles20 moves left

Greedy

one-move lookahead

cleared
0 / 42 tiles20 moves left

LEVEL 3148 TILES IN 18 MOVES

Random

picks any legal swap

ran out
0 / 48 tiles17 moves left

PPO 2M

trained 2,000,000 steps

ran out
0 / 48 tiles17 moves left

Greedy

one-move lookahead

ran out
0 / 48 tiles17 moves left

Which levels reward playing well

Subtracting the random player’s clear rate from the greedy player’s gives a number per level: how much skill is worth there. It peaks at 63% on level 27. On 8 levels it is under five points — those levels cannot tell a careful player from a careless one, which is worth knowing before shipping them as a tutorial.

03570110203040
Percentage points between the greedy player and the random one, level by level.

The walls that were not there

A spike detector looks for a level-to-level drop too large to be chance. My first version used one fixed threshold for every curve, and flagged three walls on the greedy curve. They were measured with sixty episodes against the others’ two hundred; re-measured with five times as many, those drops fell from twenty-odd points to single digits. They were never levels. They were the sample size.

The threshold now scales with the measurement behind it — 3 standard errors of a difference in proportions, so a curve built from fewer episodes has to clear a higher bar.

RANDOM

200 episodes/level

threshold 0.150

spikes: 19

PPO 200K

200 episodes/level

threshold 0.149

no spikes

PPO 2M

200 episodes/level

threshold 0.147

no spikes

GREEDY

300 episodes/level

threshold 0.093

spikes: 30

2 drops clear the threshold. The level table was built as a straight line, so anything flagged is worth opening before it is believed.

The PPO is mine, and checked

Every number above rests on an agent, so the algorithm behind it had to be verified rather than trusted. I wrote PPO out — actor and critic, advantage estimation, the clipped objective, action masking — and trained it on the same environment as stable-baselines3, for the same number of steps, from the same seed.

MINE

1.471

mean episode reward, last half

REFERENCE

1.460

stable-baselines3

UPDATES

97

compared point for point

The verdict was decided before the run: the two agree if the mean gap between the curves is smaller than the spread of the reference curve itself. It was.