# Mechanical computer uses matchboxes and beans to learn Tic-Tac-Toe

James sez, "I just completed a working build of Donald Michie's MENACE (Matchbox Educable Noughts And Crosses Engine), an early (1960) example of machine learning. MENACE uses 304 matchboxes to play Noughts and Crosses (or Tic Tac Toe in the US) - and learns over time to play it better. I built it for a talk at the UK games conference Playful, about Awesomeness and Miracles, particularly focussing on the work of Charles Babbage - and culminating in a surprisingly large version for playing Go..."

MENACE is a machine that plays noughts and crosses, built out of 304 matchboxes. Each matchbox corresponds to one of the 304 board layouts that the opening player might face (there are actually 19,683 possible board layouts, but we only need to calculate the opening player's first four moves, and many are rotationally or reflectively identical). In turn, each matchbox contains a number of glass beads corresponding to each possible next move. When it is MENACE's turn to play, the operator simply selects the matchbox corresponding to the current state of play, shakes it, and opens it to see which move has been chosen. Each matchbox contains a small nook into which one bead falls--and MENACE plays in the square corresponding to that bead.

But what's really clever is that MENACE learns. Every time it wins a game, an additional bead is added to each matchbox played, corresponding to each winning move. Likewise, every time it loses, a bead corresponding to each losing move is removed. As a result, over time, MENACE becomes more likely to play moves that have previously resulted in wins and less likely to play moves that have resulted in losses.

A New THEORY of AWESOMENESS and MIRACLES Being NOTES and SLIDES on a talk given at PLAYFUL 09, concerning CHARLES BABBAGE, HEATH ROBINSON, MENACE and MAGE