Chaos game

One of the most well known mathematical creatures is the Sierpinski triangle. A funny way to create this type of fractal is the chaos game, by choosing initially an arbitrary point P and then randomly choosing one of the vertices of a given triangle, finally compute the midpoint of P and the randomly chosen vertex: this will be the new point P. Now the set of traces of P will look like the Sierpinski triangle.
It is surprisingly easy to create such an applet with GeoGebra:
  1. Create a slider and start animating it.
  2. Create the point P and set its trace on.
  3. Create the triangle ABC.
  4. Add this piece of code to the Scipting > On Update setting for the slider: T=If[RandomBetween[1,3]==1,A,If[RandomBetween[1,2]==1,B,C]] P=Midpoint[T,P]