A learning mouse

Unfortunately this browser does not support the Canvas element... Unfortunately this browser does not support the Canvas element...

What's happening?

The moving grey object in the left panel represents a mouse, bouncing around forever in its rectangular world. Besides the mouse, this world contains two plants, represented by circles. To the mouse, the green plant tastes good, while the red one has a foul taste. When the simulation starts, the mouse moves rather billiard ball-like (with a small random component). But if you muster the patience to observe its behaviour for some time, you'll notice that the mouse develops a growing aversion to the red plant and an increasing attraction to the green one.


The mouse is equipped with a neural network that learns to translate color perceptions into steering commands. While the mouse moves around, the network stores associations between perception and steering as correlations between neuron activities. Every time the mouse hits a plant (marked by a beeping sound) its taste provides a binary feedback about its previous movement sequence: "Well done!" or "Not good!". Guided by that feedback, the network strengthens or weakens connections between neurons, in order to enhance or counter the existing relation between perception and steering.

Behind the scenes

The panel on the right shows the inner workings of the mouse. The visual input is shown in the rectangle at top left; the mouse perceives no images, but just colors: red / green, left / right. These same signals are also displayed in the bar graph at top right. (Apparently the human eye is better at judging relative bar heights than brightnesses, especially when different colors are involved.)

Below the visual input is the neural network. At left a schematic diagram of its anatomy is drawn, with neurons represented by circles and connections between neurons by lines. The bar graphs beside this diagram monitor the signal processing by the neural network. The activities of neurons are shown by broad, black, fast-changing bars. The strengths of the connections between the neurons are shown as narrow bars (vertical lines).

Points to note:

Below the neural network and its activity, the number of times the mouse hits each plant is counted (in corresponding color), the percentage of collisions with the green plant is computed (in black), and this percentage is graphed to visualize the learning process.


This simulation is programmed in JavaScript by Gerard Vriens of the HCC Artificial Intelligence interest group, after a Pascal program by Aad Hogervorst. The bar graphs were copied from the original program; the neural network diagram was included by Patrick Molenaar in an earlier Java version; the "camera image" and learning graph were added by Gerard Vriens. The source code is quick and dirty, with identifiers and (sparse) comments in Dutch. Copyright (c) 2019.

GV 27-07-2020

back to main()