The presented Spiking Neural Network (SNN) model is built in the framework of generalized Integrate-and-fire models which recreate to some extend the phenomenological dynamics of neurons while abstracting the biophysical processes behind them. The Spike Timing Dependent Plasticity (STDP) learning approach proposed by (Gerstner and al. 1996, Kempter et al. 1999) has been implemented and used as the underlying learning mechanism for the experimental neural circuit.

The neural circuit implemented in this model enables a simulated agent representing a virtual insect to move in a two dimensional world, learning to visually identify and avoid noxious stimuli while moving towards perceived rewarding stimuli. At the beginning, the agent is not aware of which stimuli are to be avoided or followed. Learning occurs through Reward-and-punishment classical conditioning. Here the agent learns to associate different colours with unconditioned reflex responses.


The experimental virtual-insect is able to process three types of sensorial information: (1) visual, (2) pain and (3) pleasant or rewarding sensation.  The visual information  is acquired through three photoreceptors where each one of them is sensitive to one specific color (white, red or green). Each photoreceptor is connected with one afferent neuron which propagates the input pulses towards two Motoneurons identified by the labels 21 and 22. Pain is elicited by a nociceptor (labeled 4) whenever the insect collides with a wall or a noxious stimulus. A rewarding or pleasant sensation is elicited by a pheromone (or nutrient smell) sensor (labeled 5) when the insect gets in direct contact with the originating stimulus.

The motor system allows the virtual insect to move forward (neuron labeled 31) or rotate in one direction (neuron labeled 32) according to the reflexive behaviour associated to it. In order to keep the insect moving even in the absence of external stimuli, the motoneuron 22 is connected to a neural oscillator sub-circuit composed of two neurons (identified by the labels 23 and 24)  performing the function of a pacemaker which sends a periodic pulse to Motoneuron 22. The pacemaker is initiated by a pulse from an input neuron (labeled 6) which represents an external input current (i.e; intracellular electrode).


  1. Press Setup to create: a. the neural circuit (on the left of the view) b. the insect and its virtual world (on the right of the view)
  2. Press go-forever to continually run the simulation.
  3. Press re-draw world to change the virtual world by adding random patches.
  4. Press relocate insect to bring the insect to its initial (center) position.
  5. Use the awake creature switch to enable or disable the movement of the insect.
  6. Use the colours switches to indicate which colours are associated to harmful stimuli.
  7. Use the insectviewdistance slider to indicate the number of patches the insect can look ahead.
  8. Use the leavetrailon? switch to follow the movement of the insect.

On the circuit side:
Input neurons are depicted with green squares. Normal neurons are represented with pink circles. When a neuron fires its colour changes to red for a short time (for 1 tick or iteration). Synapses are represented by links (grey lines) between neurons. Inhibitory synapses are depicted by red lines.

If istrainingmode? is on then the training phase is active. During the training phase, the insect is moved one patch forward everytime it is on a patch associated with a noxious stimulus. Otherwise, the insect would keep rotating over the noxious patch. Also, the insect is repositioned in its initial coordinates every time it reaches the virtual-world boundaries.


At the beginning the insect moves along the virtual-world in a seemingly random way colliding equally with all types of coloured patches. This demonstrates the initial inability of the insect to discriminate and react in response to visual stimuli. However, after a few thousands iterations (depending on the learning parameters), it can be seen that the trajectories lengthen as the learning of the insect progresses and more obstacles (walls and harmful stimuli) are avoided.


Follow the dynamic of single neurons by monitoring the membrane potential plots while running the simulation step by step.

Set different view distances to see if the behaviour of the insect changes.

Manipulate the STDP learning parameters. Which parameters speed up or slow down the adaptation to the environment?


Use different kernels for the decay() and epsp() functions to make the model more accurate in biological terms.


Use of link and list primitives.


If you mention this model in a publication, we ask that you include these citations for the model itself and for the NetLogo software:

  • Jimenez-Romero, C and Johnson J. (2015). SpikingLab. Modelling agents controlled by Spiking Neural Networks in Netlogo
    Department of Engineering and Innovation, The Open University, Milton Keynes, UK.


SpikingLab_Demo_Artificial_Insect_and_STDP_03052016.nlogo (83 downloads)

If you have any question regarding the model please contact me at  cristian.jimenez-romero@open.ac.uk

Comments are closed.