Write-up 01 / AI

How Visi thinks

Visi is the agent playing Tiltit on the main page. No AI service is called and nothing is sent anywhere: two small neural networks I trained run on your own device, and before every move Visi imagines what could happen next.

Weights, both networks
4,028
Games played in training
552,000
Delivered on unseen routes
96.8%
Size on the wire
23 KB

What it sees

Thirty numbers, and nothing else. Twelve rays round the courier, each as far as it reaches before a hedge, a tree, a crate or the cottage. Four points of the route ahead. The delivery pad, and how much route is left. Its own speed. And what it did a moment ago: its last push and whether it braked.

Everything is turned to the courier’s own direction, so what it learned facing one way holds facing any.

Two networks

How it thinks

Every quarter of a second Visi imagines twenty futures: what its instinct would do, and the same pushed a little left, right, slower, faster or braking. Each is played a second and a half forward in the game’s own physics, on a copy of the game, and scored: progress along the route, a delivery, every knock, and its judgment of where the future ends.

It takes the best one, and holds to it unless another is clearly better. The futures are imagined five a frame, so a thought takes a few frames and no frame ever waits on it.

How it learned

The instinct learned by evolution strategies, in plain JavaScript on every core of my machine: 950 generations of 96 copies of the network, each nudged by noise one way and the other, all playing the same six games on random routes. Each generation moved the network toward whatever delivered sooner and cleaner. Crates came in after the first fifty generations.

The judgment learned afterwards, by regression on 21,234 moments of the instinct’s own games. In all, 552,000 games.

What went wrong

  • Teaching the instinct from its own thinking made it faster and worse. Part of the way through I had its planner teach its instinct: 64,139 moments where the instinct learned to answer as its thinking would. On 800 fresh routes it got quicker (6.8 s from 7.3 s) and less reliable (91.6% delivered, from 94.6%). It took 150 more generations of evolution on top to keep the pace and win the deliveries back.
  • A newborn network that barely pushes learns nothing. The courier only rolls once the stick is pushed past 0.15, and a network that holds the brake half the time goes nowhere, so its first games teach it nothing. The network you can train on the main page starts with a bolder last layer and off the brake, and learns when to brake.
  • It had no memory. The first version saw 27 numbers and treated every moment as its first, so it could not tell it had been pushing at a crate or swinging from side to side. Feeding back what it did a moment ago took it from 95.4% delivered in 7.3 s to 96.6% in 6.8 s.

The exam

On 400 routes it had never seen: 96.8% delivered thinking ahead, in 5.5 seconds, without a knock. On instinct alone: 96.0%, in 6.8 seconds, with a knock in one game out of five. Thinking delivers about as often as instinct does; what it adds is the second it saves and the knocks it does not take.

Do it yourself

On the main page, Teach from scratch throws both trained networks away and trains new ones on your device, by the same method, in about a minute. You watch each generation take the stick.