Robot Wars, One Day Later – From Game to Typing, Math and Degrees

📐 Robot Wars, One Day Later – From Game to Typing, Math and Degrees

Yesterday I published Robot Wars: a two-player game where you steer a robot by typing simple Dutch commands, CT-3000 style, and try to shoot down the other player's tower. It started as "let's build a game with the CT-3000 feeling, but with towers and bridges like Clash Royale".

One day later, the game is still the game. But watching Wessel (8) play, I noticed what the thing is actually for. It's not the towers. It's three things that piggyback on the towers:

  1. Typing — properly, both hands.
  2. Programming — commands, queues, loops, hints instead of errors.
  3. Maths — and this is the one I didn't plan: coordinates, relative positions, negative numbers, and soon angles.

Every feature we added since yesterday leans on one of those. This post is about the third one.


⌨️ Typing first

The cheapest observation, and the most important one: a robot that only moves when you spell vooruit correctly is a better typing course than any typing course.

There is no Enter key. The line freezes with a green ✓ the moment it is a valid command, and a red ! with a hint the moment it can never become one. So the feedback loop is: type a letter, look at the marker. And the motivation is built in: you want to fire before Robo does, so you learn where the keys are.

Nobody told him he was practising typing. He was playing.


📍 Shields: (x, y) is an axis system

The first command that needs numbers is the shield:

schild = (4, 2)

In the first version, the rows counted from the top, like a spreadsheet. That works for adults, but it's the wrong model for a kid: in school, an axis system has the origin at the bottom left and y goes up. omhoog should mean a higher number.

So we changed it. The field now has the x-axis along the bottom and the y-axis along the left, exactly like the axis systems he'll get in maths class in a few years:

  7  .  .  .  .  .  .  ~  .  .  .  .  .  .
  6  .  .  .  .  .  .  =  .  .  .  .  .  .   bridge
  5  .  .  .  .  .  .  ~  .  .  .  .  .  .
  4  B  R  .  .  .  .  ~  .  .  .  .  R  B   towers + start squares
  3  .  .  .  .  .  .  ~  .  .  .  .  .  .
  2  .  .  .  .  .  .  =  .  .  .  .  .  .   bridge
  1  .  .  .  .  .  .  ~  .  .  .  .  .  .
     1  2  3  4  5  6  7  8  9 10 11 12 13
  • x counts from your own side: 1 at your tower, 13 at the enemy tower.
  • y counts from the bottom (1) to the top (7).
  • robot = omhoog is y + 1. robot = vooruit is x + 1.

Now "put a shield at (4, 2)" means: four to the right along the bottom, two up. That's reading coordinates. In the game it's just "putting a shield in front of the bridge".

(Player 2 sees the field mirrored, so x = 1 is always your tower. Nobody has to think about which side they're on.)


💣 Bombs: relative coordinates and negative numbers

Yesterday's post had shoot, move, shield and a loop. Today there's a bomb:

bom = (1, 0)

The bomb is the maths jump. A shield takes an absolute position: where on the field. A bomb takes a relative one: from where I am. (dx, dy), each −1, 0 or 1.

Command Where the bomb goes
bom = (1, 0) the square in front of you
bom = (0, 1) the square above you
bom = (-1, 0) the square behind you
bom = (-1, 1) diagonally behind you, one up
bom = (0, 0) your own square (don't)

Two things happen here that no worksheet manages as smoothly:

"Where" versus "from here". The same pair of numbers means different things in schild = (1, 0) (impossible, that's not even on the field) and bom = (1, 0) (just ahead of me). You learn that difference fast, because a bomb that lands where you didn't expect blows up your own robot.

Negative numbers. -1 isn't a scary concept if it means "one step back". An eight-year-old hasn't met the minus sign at school yet, but bom = (-1, 0) to drop a mine behind you while you run from Robo is a negative number used correctly, with intent. It's not a sum, it's a trap.

The rules, for completeness:

  • 3 bombs per game, same as shields.
  • If a robot is on the target square, it's destroyed immediately (yes, your own too).
  • Otherwise the bomb stays on the field as a mine, visible to both players. Any robot that steps on it is destroyed — your own mine included.
  • Drop a bomb on a square that already has a mine and both go off harmlessly. That's how you clear an enemy mine, at the cost of one of your own bombs.
  • Bullets fly over mines. Shields can't be placed on a mine.
  • Robo doesn't lay bombs, but he does walk around mines, and picks the other bridge if his route has one.

Since yesterday shields also got tougher (8 hits instead of 3), and the command queue is capped at 500 steps — enough for a herhaal 20 keer inside a herhaal 20 keer, and a friendly message instead of a frozen game if a nested loop gets bigger than that.


🔄 Next up: degrees

Right now the robot can only shoot forward. If Robo is above or below you, there's nothing you can do about it. The fix we've decided on, and which I'm building next, is rotation:

robot = draai 90        (turn 90° left)
robot = draai -90       (turn 90° right)
robot = draai 180       (turn around)
robot = schiet          (shoot in whatever direction you're facing)

This isn't built yet — it's the plan for the coming days. But it is the third maths layer, and it falls out naturally:

  • a shield is a position: (x, y)
  • a bomb is a displacement: (dx, dy)
  • a turn is an angle: 90, -90, 180

Position, displacement, rotation. If you'd told me on Saturday that I'd be sneaking a coordinate-geometry curriculum into a Clash Royale clone, I'd have laughed. But that's what the game wants. Every real gameplay problem ("I can't hit him from here") has a maths concept as its answer, and the kid asks for the concept himself.

The interesting design question is which way is positive. In maths, +90° is counter-clockwise. For a kid, "turn left" and "turn right" are what matter, and the number is decoration. We'll try the maths convention first, with the hint spelling it out: draai 90 is naar links, draai -90 is naar rechts. If it doesn't stick, the hint changes, not the maths.


🧒 What changed for Wessel

Yesterday I wrote that he was learning to type and picking up the basics of programming without noticing. One day later I'd add: he's doing maths without noticing.

He doesn't think of (4, 2) as a coordinate. It's where the shield goes. He doesn't think of -1 as a negative number. It's "behind me". And in a few days he won't think of 180 as an angle. It's "turn around and shoot".

None of it is a lesson. All of it sticks, because every number he types makes something happen on the screen within a second, and a wrong number blows up his own robot.


🎯 Try it

Go to robot.schut.me, type your name, pick Speel tegen de computer, and try the combination:

herhaal 4 keer
  robot = vooruit
klaar
schild = (3, 4)
bom = (-1, 0)
robot = schiet

Walk to the river, then put a shield in front of your tower (after you've walked past that square, or you'll block yourself), leave a mine behind you for when Robo follows, and fire. The source is at github.com/martijnschut/robotwars.

If you've got a kid who has just met CT-3000 at school and you want to smuggle in an axis system: this is one way to do it.