Walk - A Random Walk Fractal

by Richard Taylor


Walk is a very short program which produces a random but elegant fractal. (Look at the sprite 'Example' inside the application directory to see a typical end result. This directory is opened by holding down Shift while double clicking on the !Walk icon.)

Click on the icon in the RISC User master menu system in the normal manner to run the program - the screen will clear and you should see a circle with a small dot placed at the centre.

Another dot, beginning at a random place around the cicumference of the circle, now starts to move rapidly in a random walk - that is, at each step it is equally likely to move left, right, up or down on the screen (you may press and hold down the Space Bar at any point if you wish to slow things down). If, as is quite probable, the dot leaves the circle, either straight away or after some time, then it is removed and another dot is started off, this time at a different point on the circumference. If however, the dot moves all the way into the circle and eventually touches the central dot, it will stick to it, and another dot will begin its journey from the circumference.

Gradually a shape will emerge as more and more dots collide with the group already at the centre and stick on to it. The fern-like structure of the fractal that appears is due to the fact that a wandering dot is more likely to collide with outreaching branches than make it to the centre.

After every 25 dots that successfully find the central group, the current colour is changed to make the pattern visually more interesting. As the pattern grows (more rapidly than it did at first), the surrounding circle will be enlarged and the dots, while still moving randomly, now take multiple steps in the same direction. This allows the fractal to be created more quickly than if the circle started at full size and the dot only moved a step at a time, as was the case in the original description (see below).   As it is, it will take around an hour (on an ARM 2 machine) to produce a fractal similar to the example sprite file.

The program comes to a stop when the circle gets near to the edge of the screen. Press Escape to finish before this. If you run the program from the BASIC command line, then you can '*SCREENSAVE' the picture on exit.



 Copyright RISC User, 1995