Enter the maze

Build a brain to play snap


Want to build a working brain? All you need are a bunch of brain cells. Our cs4fn brain applet lets you build a brain that plays the game of red-black snap. Two reds make snap, two blacks make snap, but anything else isn't snap.

Our brains are made of neurons. They are simple computing units, each following a very simple rule. Each is connected to lots of other neurons. Any particular neuron will receive chemical messages from the neurons it is connected to. Eventually the number of messages reaches some threshold. When that happens, the neuron fires. It's a bit like a balloon that pops when eventually it is pumped up too much. A neuron firing just means it sends a message to the neurons its connected to, starting the process all over again.

Watching TV, playing football, reading a book, falling in love: it's all just neurons doing that over and over again!

The artificial brain you will make is made of neurons too. Different neurons are specialised to do different things. Look at our brain building kit. There are 7 neurons all together. The four down the left are all specialised to connect to the eyes of the brain. After all a brain that has no way to sense the world will not be much use. They fire when the eyes see a particular stimulus. You can program each to look for either red or black and also to look either in position one or position two. Each will fire only when it's particular stimulus (like red in position 1) is seen.

That's the eyes sorted. Next we go deep into the brain. The middle two neurons are called interneurons. They can't sense the outside world. All they can do is react to the messages they get from the eye neurons. Program them by setting their threshold. Should they fire even if they get no message, if they get one message or only if they have got two messages? Its your choice, but get the programming wrong and the brain won't play snap properly!

Finally, the right hand neuron gives a way for our brain to act in the world. It is connected to the mouth and can make it shout "Snap!". Again you decide the threshold. How many messages shoud it receive before it fires?

Try programming the brain and then randomly deal some cards to see if your brain behaves as expected. When you think you have got it right, try the "Test all card deals" button to check all combinations of red and black. Does it work whatever cards are turned over?

Click here to start building your brain.

Once we understand the biology of brains enough to build a physical one we can, as computer scientists, start thinking about programming virtual ones. They are called neural networks and maybe if we build ones complex enough, one day we will accept one of them as being as intelligent as us.

Of course real brains don't need to be programmed, they learn from experience. It turns out artificial neurons can be created to learn too. Blade, an emotional robot built by a Queen Mary student has such a neural network brain that was trained a little like you might train a dog. Watch the video.