mscroggs.co.uk
mscroggs.co.uk

subscribe

Blog

MENACE: Machine Educable Noughts And Crosses Engine

 2015-08-27 
In 1961, Donald Michie build MENACE (Machine Educable Noughts And Crosses Engine), a machine capable of learning to be a better player of Noughts and Crosses (or Tic-Tac-Toe if you're American). As computers were less widely available at the time, MENACE was built from from 304 matchboxes.
Taken from Trial and error by Donald Michie [2]
The original MENACE.
To save you from the long task of building a copy of MENACE, I have written a JavaScript version of MENACE, which you can play against here.

How to play against MENACE

To reduce the number of matchboxes required to build it, MENACE aways plays first. Each possible game position which MENACE could face is drawn on a matchbox. A range of coloured beads are placed in each box. Each colour corresponds to a possible move which MENACE could make from that position.
To make a move using MENACE, the box with the current board position must be found. The operator then shakes the box and opens it. MENACE plays in the position corresponding to the colour of the bead at the front of the box.
For example, in this game, the first matchbox is opened to reveal a red bead at its front. This means that MENACE (O) plays in the corner. The human player (X) then plays in the centre. To make its next move, MENACE's operator finds the matchbox with the current position on, then opens it. This time it gives a blue bead which means MENACE plays in the bottom middle.
The human player then plays bottom right. Again MENACE's operator finds the box for the current position, it gives an orange bead and MENACE plays in the left middle. Finally the human player wins by playing top right.
MENACE has been beaten, but all is not lost. MENACE can now learn from its mistakes to stop the happening again.

How MENACE learns

MENACE lost the game above, so the beads that were chosen are removed from the boxes. This means that MENACE will be less likely to pick the same colours again and has learned. If MENACE had won, three beads of the chosen colour would have been added to each box, encouraging MENACE to do the same again. If a game is a draw, one bead is added to each box.
Initially, MENACE begins with four beads of each colour in the first move box, three in the third move boxes, two in the fifth move boxes and one in the final move boxes. Removing one bead from each box on losing means that later moves are more heavily discouraged. This helps MENACE learn more quickly, as the later moves are more likely to have led to the loss.
After a few games have been played, it is possible that some boxes may end up empty. If one of these boxes is to be used, then MENACE resigns. When playing against skilled players, it is possible that the first move box runs out of beads. In this case, MENACE should be reset with more beads in the earlier boxes to give it more time to learn before it starts resigning.

How MENACE performs

In Donald Michie's original tournament against MENACE, which lasted 220 games and 16 hours, MENACE drew consistently after 20 games.
Taken from Trial and error by Donald Michie [2]
Graph showing MENACE's performance in the original tournament. Edit: Added the redrawn graph on the left.
After a while, Michie tried playing some more unusual games. For a while he was able to defeat MENACE, but MENACE quickly learnt to stop losing. You can read more about the original MENACE in A matchbox game learning-machine by Martin Gardner [1] and Trial and error by Donald Michie [2].
You may like to experiment with different tactics against MENACE yourself.

Play against MENACE

I have written a JavaScript implemenation of MENACE for you to play against. The source code for this implementation is available on GitHub.
When playing this version of MENACE, the contents of the matchboxes are shown on the right hand side of the page. The numbers shown on the boxes show how many beads corresponding to that move remain in the box. The red numbers show which beads have been picked in the current game.
The initial numbers of beads in the boxes and the incentives can be adjusted by clicking Adjust MENACE's settings above the matchboxes. My version of MENACE starts with more beads in each box than the original MENACE to prevent the early boxes from running out of beads, causing MENACE to resign.
Additionally, next to the board, you can set MENACE to play against random, or a player 2 version of MENACE.
Edit: After hearing me do a lightning talk about MENACE at CCC, Oliver Child built a copy of MENACE. Here are some pictures he sent me:
Edit: Oliver has written about MENACE and the version he built in issue 03 of Chalkdust Magazine.
Edit: Inspired by Oliver, I have built my own MENACE. I took it to the MathsJam Conference 2016. It looks like this:

A matchbox game learning-machine by Martin Gardner. Scientific American, March 1962. [link]
Trial and error by Donald Michie. Penguin Science Survey, 1961.

Similar posts

Building MENACEs for other games
MENACE at Manchester Science Festival
MENACE in fiction
The Mathematical Games of Martin Gardner

Comments

Comments in green were written by me. Comments in blue were not written by me.
 2019-07-06 
Can you make a version where the ai goes second?
Reply
Nukey
 2019-04-09 
@Sterling: To make a MENACE to play chess, you'd need to draw every possible position in chess. As I wrote in this blog post, if you had a matchbox for each possible chess position, your pile of matchboxes would be this big:



This number of positions is too big for this method of learning to work for chess, so you'd need a more advanced method...
Reply
Matthew
 2019-04-08 
After watching the video with yourself and Matt, you commented on teaching it chess are there any PDFs on how to teach, the machine chess. Ie what are the mechanics
Reply
Sterling
 2019-03-27 
@Alex: You can find the pdfs here. boxes0.pdf to boxes3.pdf are the states for a MENACE that goes first. second_boxes0.pdf to second_boxes2.pdf are the states for a MENACE that goes second.
Reply
Matthew
 2019-03-26 
I know this has been asked a lot but would it be possible if you could make a pdf of all possible states of the game on your website? If not please just send them to me directly. Thank you, alex
Reply
Alex
 Add a Comment 


I will only use your email address to reply to your comment (if a reply is needed).

Allowed HTML tags: <br> <a> <small> <b> <i> <s> <sup> <sub> <u> <spoiler> <ul> <ol> <li>
To prove you are not a spam bot, please type "nogaced" backwards in the box below (case sensitive):

Archive

Show me a random blog post
 2019 

Jul 2019

Big Internet Math-Off stickers

Jun 2019

Proving a conjecture

Apr 2019

Harriss and other spirals

Mar 2019

realhats

Jan 2019

Christmas (2018) is over
 2018 
▼ show ▼
 2017 
▼ show ▼
 2016 
▼ show ▼
 2015 
▼ show ▼
 2014 
▼ show ▼
 2013 
▼ show ▼
 2012 
▼ show ▼

Tags

golden ratio mathsteroids matt parker speed the aperiodical bodmas national lottery games dragon curves electromagnetic field golden spiral asteroids latex big internet math-off weather station trigonometry propositional calculus harriss spiral palindromes curvature geometry chess realhats gerry anderson tennis pythagoras arithmetic manchester rugby menace wool light twitter chebyshev frobel royal baby bubble bobble statistics machine learning error bars cross stitch approximation game of life video games people maths books reddit logic christmas card game show probability braiding world cup sound sport nine men's morris mathslogicbot football christmas ternary javascript london draughts triangles platonic solids plastic ratio mathsjam data hats hexapawn binary martin gardner london underground estimation chalkdust magazine craft folding paper sorting countdown news noughts and crosses radio 4 dataset interpolation graph theory rhombicuboctahedron raspberry pi oeis puzzles coins pizza cutting misleading statistics folding tube maps probability flexagons polynomials a gamut of games map projections stickers dates accuracy european cup programming final fantasy pac-man manchester science festival php go reuleaux polygons inline code python fractals captain scarlet

Archive

Show me a random blog post
▼ show ▼
© Matthew Scroggs 2019