Apps ← obsidianwolf.app
Lumen Run › DevNotes

Racing a Toddler: How I Taught Lumen Run's Rivals to Plan Their Whole Lap

How Lumen Run's AI rivals learned to plan a whole lap, the two sneaky bugs that made them drive badly, and why every boss races differently.

I haven't forgotten the day I sat down to play my own game and felt a little insulted.

I'd set the opponents to Easy, and it was like racing a toddler. On Extreme they were somewhat of a challenge, but only if I didn't use my boost. Even the simple test driver I keep for checking things was beating them. So I went looking for why.

The problem: rivals who don't know the road

A good human driver studies a track. They know where the corners are, where to brake, and where to save their boost for a long straight. So my brief was simple: the rivals should know the whole route ahead of time, and then the only difference between a beginner and a master is how well they drive along the best path.

Teaching them to plan a lap

Before a race starts, every rival now works out a plan for the entire lap, for its own car. A heavy cruiser plans differently from a light, slidey one.

Think of a GPS that doesn't just tell you the next turn, but works out the ideal speed for every metre of road. Each rival works out:

  • how fast it can take each corner before the tires lose their grip;

  • where it has to start braking to be slow enough when it gets there;

  • how quickly it can accelerate out of that corner;

  • and where to spend its boost. It only refills slowly, so it's best spent at the start of the longest straights.

All of it follows the racing line: the smooth, sweeping path fast drivers take through a corner, swinging wide, cutting in tight, then swinging wide again. It's the way to carry the most speed.

The bug that made them drive in a mirror

I built it, and it still wasn't right. The rivals were weaving, swinging across the road and back, steering hard from one side to the other. Even my best rivals lapped slower than that humble test driver.

So I built a lab that races drivers on lots of tracks with no screen, all in the same car, and times them. Then I found it. The part of the game that works out the racing line had a sign error. In everyday terms: it had left and right flipped. Imagine a GPS saying "turn left" every time the road turns right. Every rival was aiming at the mirror image of the perfect line, then fighting its own steering to get back onto the road. On every corner of every track.

The fix was two tiny changes. On its own it shaved roughly two and a half seconds off a lap that had taken about 45. The weaving stopped, and suddenly the rivals looked like they knew where they were going.

The second bug: corners half as sharp

With the faster cars, rivals started running wide in fast corners and scraping the outside wall for a big chunk of every lap.

It was a cousin of the first bug. The game was measuring how sharp each bend was and getting half the real answer. So rivals planned corners too fast and turned in only half as much as they needed to.

After the fix, time spent against the walls fell from many seconds a lap to hardly any, and lap times got about a second slower. That makes sense: the walls had been quietly handing out free time.

There's a sneaky footnote: when I let the lab tune rivals purely by lap time, it rediscovered the cheat, so now it counts every second spent against a wall as a second lost.

Skill is a dial, not a switch

With rivals that could drive properly, I could finally turn them down on purpose.

Skill in Lumen Run is a single dial from beginner to master. Turn it down, and a driver plans well inside its car's limits: it takes corners cautiously, brakes earlier, uses less of its boost, reacts a little late, and now and then makes a mistake going into a corner. Turn it up, and the plan creeps towards what the car can really do.

I measured it in lap times: every skill level in the same car, across twenty tracks. The gap between the weakest and strongest driver is several seconds a lap. The very best now edge out a quick human driver, and the simple test driver that used to beat them now sits somewhere in the middle.

On desktop, each race builds its rivals around your car's top speed, so a faster car means meeting faster rivals.

Every boss drives differently

A boss isn't just a faster car. Each has its own driving style, and they get better as the chapters go on.

  • Viper (chapter 1) is aggressive: late braking, deep dives up the inside, constant pressure.

  • Shiftwave (chapter 2) hunts slipstreams: it tucks in behind you, then slingshots past.

  • Rime (chapter 3) is a precision driver: clean lines, early braking.

  • Obsidian (chapter 4) is aggressive again, only sharper.

  • The Lumen Runner (chapter 5) is a precision driver with the biggest edge of all.

A boss turns up in every race of its chapter, at the back of the grid, so you can see it coming long before the boss race.

I also ran a test I'm proud of: simulated races of a fully upgraded Obsidian against the Lumen Runner, to be sure the finale can be won with the car you've earned. At first, the Obsidian lost every one. So I eased the Runner down until a well-driven Obsidian could win most of them.

Little lessons along the way

  • Steering in mid-air just twists a car sideways, and rivals kept landing into walls. Now they stay straight in the air and aim for where the road will be when they come down.

  • Ramming. At first the rivals tried to crash into me and each other. My first fix made them so polite nobody ever overtook. The rule I landed on: race hard, and only give way when a crash is about to happen.

  • A mystery. A car right behind me looked like it was driving under mine. The real cause was drawing: my car was being painted on top of cars closer to the camera.

  • Catch-up is one-way. A rival behind you gets a small helping hand. A rival in front is never slowed down to wait for you.

What this means when you race

When you race now, rivals are doing what you're doing: braking for corners, saving boost for straights, getting a good run out of a bend. They defend, they make mistakes, and the bosses push back in their own way. That's what I wanted: not a rival that cheats, but one that races.

Try it yourself

The free demo is chapter 1 of the Story, ending with the Viper boss race, and you can play it right in your browser:

Play the free demo →

If it hooks you, the full game, with 50 races, five bosses and ten worlds, is on Windows.

Tell me which boss gives you the most trouble. I'm curious.

Obsidian Wolf

Comments

No comments yet. Be the first to say hello.

Leave a comment

No email needed. We read every comment before it shows up. Please leave web links out.