We put an AI inside a Game Boy Advance

DrawIt is a game for a handheld console from 2001 in which you doodle with the arrow buttons and the console guesses what you are drawing. The guessing is done by a small AI that lives entirely inside the game: no internet, no server, nothing but the console's own 16.78 MHz processor.

Words in the game
330
Right on the easy words
about 7 in 10
Time to answer
under half a second
Size of the AI
about 200 KB

The game

The game gives you a word, such as HOUSE or LADDER, and a blank grid of 28 by 28 squares. You move a cursor with the arrow buttons and hold A to paint. A second tool draws straight lines between two points, because diagonals are miserable on arrow buttons.

The start of a round in DrawIt: the word to draw across the top, a blank grid, the clock and the list of controls A round begins: a word, a blank grid and the clock.

While you draw, the right side of the screen shows the console’s three best guesses, each with a percentage. As soon as its top guess is your word, you win the round. A game is six words.

Four moments from one drawing in the game. Two lines: not sure, 31%. A box: square, 36%. With a roof: house, 98%. With a door: house, 93%.

There are three word lists. EASY has the 70 things the AI recognises most reliably and gives you 60 seconds. NORMAL has 150 and HARD has all 330; both give you 99. In a round only the words on your list compete as answers, so the shorter the list, the surer the guesses. A third mode has no word and no clock: you draw whatever you like and watch it guess among all 330.

Bar chart of rounds won on simulated player-style drawings. Easy, 70 words: 68% for small drawings, 78% for full-size ones. Normal, 150 words: 47% and 62%. Hard, all 330 words: 20% and 33%.

When it has too little to go on, it says so. One short line gets the answer “not sure”, not a confident wrong guess. A single dot gets no answer at all.

One short line on an otherwise empty grid. The console answers: not sure, 87% One short line is not enough to go on, and it says so.

The model

The AI is a list of about 200,000 numbers and a fixed recipe for multiplying and adding with them. Nobody wrote rules like “a house has a triangle on a square”. The numbers were found by showing the recipe a great many drawings and correcting it each time it was wrong.

Each guess follows the same steps:

  1. Tidy up. The drawing is cut out, enlarged to fill the grid and centred, so a small house in the corner looks the same as a big one in the middle.
  2. Look for strokes. Sixteen tiny stencils slide over the picture. Each reacts to its own small pattern of ink and empty squares.
  3. Combine strokes into shapes. Forty-eight detectors look at which strokes sit next to each other.
  4. Note what is where. The result is boiled down to 256 clues about the whole picture.
  5. Vote. Each possible answer, plus “not sure”, weighs the clues and gives itself a score. The three highest are shown.

The sixteen stencils of the first layer, each a grid of three by three squares. Blue squares want ink there, orange squares want none, grey ones do not care.

The percentages are tuned against drawings held back from training so that, on average, the console is as confident as it is correct.

How it learned

The drawings come from Quick, Draw!, a public collection of doodles that people around the world made for a Google experiment. We used 6,000 drawings for each thing, about two million in total, and kept two more sets of 1,000 of each aside: one to tune the game on, and one looked at only once, at the very end, for the numbers on this page.

Thirty of the 330 words, from apple to wine glass. For each, a doodle from the dataset beside the same doodle redrawn thin and small, the way a player with arrow buttons draws.

Training took about 33 minutes on a single graphics card in the cloud. The model saw every drawing twenty-four times. Each time it guessed wrong, its numbers were nudged slightly towards the right answer.

“Not sure” was taught as an answer of its own, from scribbles and from real drawings with most of their ink removed.

Three rows of drawings. Scribbles from the dataset, such as lines, squiggles and zigzags: the right answer is “not sure”. Finished doodles of a house, bicycle, butterfly, sailboat, umbrella, snowman and camera: the right answer is the word. The same doodles barely started, with 8% to 35% of the ink kept: the right answer is “not sure”.

What we got wrong first

The first version with 330 words passed every test we wrote and was close to unplayable. Our test drawings filled the whole grid, as the training drawings do. A person with arrow buttons draws small, thin and off to one side.

Six doodles shown three ways: a house, umbrella, snowman, sailboat, butterfly and eyeglasses. As it is in the dataset, filling the picture. As a player draws it, with thin lines, smaller, anywhere on the grid. What the console hands the network: cut out, enlarged and centred.

On drawings two-thirds the usual size, the model’s first guess was right about 1 time in 30. It had never seen a small drawing, so it did not recognise one.

Two changes fixed it. The console now tidies every drawing before looking at it, which is step 1 above. And the model was trained again with most of its drawings redrawn the way a player draws: thin lines, smaller, anywhere on the grid. On the same small drawings its first guess is now right about 1 time in 3 across all 330 words, and in the game it wins about 2 rounds in 3 on the easy list. HARD is hard for the console too: with every word in play it wins roughly 1 round in 5 on small drawings.

Bar chart of how often the first guess is right, before and after retraining on player-style drawings, with all 330 answers competing. Dataset style: 50% before and after. Thin lines at full size: 42% then 44%. At 80% size: 22% then 35%. At two-thirds size: 18% then 33%. At half size: 14% then 28%.

A small house drawn in the top left corner of the grid. The console’s top guess: house, 73% A small house up in one corner, read as a house.

Making it fit

The console has a 16.78 MHz processor, 288 KB of working memory, and no ability to do arithmetic with decimals. The model was trained on a modern machine with none of those limits, then squeezed.

  • One byte per number. Each of the 200,000 numbers is stored as a whole number between -127 and 127. The AI takes about 200 KB; the whole game is about 240 KB, smaller than one phone photo.
  • Whole-number arithmetic only. Every step was rewritten to avoid decimals. The squeezed version picks the same answer as the original on 97.7% of 4,000 test drawings.
  • A shortcut for the first step. A square is either inked or empty, so the first layer needs no multiplication at all, only addition.
  • Thinking between frames. A guess takes about half a million multiply-and-adds, because the stencils are reused at every position of the picture. The console does them in small slices in the idle moments of each screen refresh, so the cursor never stutters while it thinks.

Beyond the game

Nobody needs a doodle game on a 25-year-old console. The point is the constraint. If a model that tells hundreds of everyday things apart from a rough sketch runs on this hardware, the same kind of model runs on the small, cheap chips already inside appliances, tools, toys and sensors.

If it fits in a game cartridge from 2001, it fits in your device.

Recognising a doodle is close kin to recognising a gesture on a touchpad, a handwritten digit on a form, or a symbol on a label. Done on the device itself, that works with no connection, answers at once, and sends nothing anywhere.

That is what Miraku does: we compact and fit AI models inside devices offline, no cloud needed.

What we have not shown

The accuracy figures come from test drawings altered by a program to look like a player’s, not from many people playing. On all 330 words with full-size drawings from the original collection, the first guess is right half the time and the right answer is in the top three 7 times in 10. Some things it rarely gets: a dog, a bird and a frog look alike at this size.

Credits

Game Boy Advance is a trademark of Nintendo. Miraku is not affiliated with Nintendo.