Haferman Carpet

The Haferman Carpet is a fractal, which kind of looks like a woven carpet. To generate it, you start with a single black pixel and apply in each cycle a set of rules.
In each generation every pixel in the carpet will be replaced by nine pixels according to the rules. A black pixel is represented by a 0, a white one by a 1.

The rules

  • 0 \rightarrow \left( \begin{array}{ccc}1&0&1\\0&1&0\\1&0&1\end{array} \right) \text{and } 1 \rightarrow \left( \begin{array}{ccc}0&0&0\\0&0&0\\0&0&0\end{array} \right)

6 iterations of the Haferman Carpet


# Python 2.7.7 Code
# Pygame 1.9.1 (for Python 2.7.7)
# Jonathan Frech 26th of February, 2016

Continue reading

Langton’s Ant

This program is a simulation of Langton’s Ant. The following image shows the ant on its highway.

Controls

  • F1 takes a screenshot
  • Space stops and resumes the ant’s movement

The highway is infinite...


# Python 2.7.7 Code
# Pygame 1.9.1 (for Python 2.7.7)
# Jonathan Frech 27th of October, 2015
#         edited 29th of October, 2015

Continue reading