# Introduction to Complex Systems

Prof. Dirk Brockmann, Winter Term 2021

# Practical Problem 13: Chemotaxis

The goal of this problem is to design a simulation of chemotaxis. In chemotaxis bacteria or other single cell organisms emit a chemical that diffuses and other individuals sense it. The other individuals move up the gradient of the chemical and also start emiting the chemical.

## Simulation 1

Write a simulation in which turtles move around randomly (speed and wiggle, you know the drill).

Turtles should have a turtles-own variable that we call emissionrate that is the probability at which a turtle emits a chemical into the environment.

Patches should have a patches-own variable that is the concentration of the chemical at the patch, we can call it smell.

When turtles emit a chemical the concentration of the chemical is set to 1 on the patch that is hosting the turtle. You can implement this like so

ask turtles [
if random-float 1 < emissionrate
[
]

## ]

Because the smell diffuses you should have a command diffuse smell D in the go function where D is the diffusion parameter for which we need a slider. The smell chemical should also decay with a certain factor which you can accomplish like so:

ask patches [
set smell smell * (1 - decay)
]
]

where the decay is also a parameter (slider) between 0 and 1.

Color the patches according to the local concentration of smell. You may want to check out the command scale-color in the manual.

When the program runs you should have turtles moving around that leave traces of smell that washes away, becomes blurry and disappears.

## Simulation 2

Now we want turtles to respond to the smell concentration. In addition to the wiggle movement turtles should investigate patches in a radius $R$ and see where the concentration of smell is highest and turn their heading into that direction. And implementation could look like this:

ask turtles [
let p max-one-of patches in-radius R [smell] ; this identifies the patch with the highest smell
if [smell] of p > smell  [ ; if the smell at p is larger than the smell where the turtle is turn towards it
face p
]
]

Play with the parameters and see if you can find a scenario where all the turtles accumulate.