Cellular Automata

Complex behaviour arises out of very simple rules. Here’s a simple set of rules for your “ant” to follow that makes an interesting display. 1. If the ant is on a black square, it turns right 90° and moves forward one unit. 2. If the ant is on a white square, it turns left 90° and moves forward one unit. 3. When the ant leaves a square, it inverts the color.

Task 1

Write a program to simulate the ant that includes a parameter to make the ant larger or smaller. This can be achieved using the Python Tkinter Canvas or similar. If you are attempting this, a good test for correctness is to run the model from an all white world for 386 steps and check it against the example given on http://mathworld.wolfram.com/LangtonsAnt.html shown below:

Task 2

Write a program to simulate the behaviour of ants. Ant colonies are very complex organisms, but a single ant has a small range of behaviours. An ant behaves as follows:

  • When you encounter food, take it home, marking a trail.
  • If you cross a trail and you have no food, follow the trail to the food.
  • If you return home with food, put it down, and return up the trail.
  • Otherwise, wander at random looking for food.

Use a 2D array as the ant’s world. Position the nest at the centre. All ants emerge from the nest. Place food randomly around the world.

References

Credit Blundell@MonktonCoombe

IMAGE CREDIT: https://en.wikipedia.org/wiki/Cellular_automaton

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.