Random Fractal Generator
by Mark Graves

NOTE: Before running the application, check that you have at least 160K of screen memory in the Task Manager's display (obtained by clicking Menu over the Task Manager's icon and choosing Task Display).

This mouse controlled random fractal generator application is very easy to use, and can produce some amazing fractal patterns. You can exit at any stage by clicking on the middle mouse button.

By clicking on the seed value tablet, you can enter a fractal seed value between 1 and 99,999. This number is used by an algorithm which produces pseudo-random numbers for the main fractal generator to use. If you particularly like one fractal, or simply want to see the effects of altering the seed value to specific values, enter the relevant number in the space provided and press Return. The fractal will then be generated.

The sea level (the size of blank areas within the fractal) can be altered two ways. Firstly, clicking on the bar indicator will set the level to the nearest value. Secondly, the left and right arrow icons can be used for fine adjustment, and the box icon will centre the bar indicator - set it to 128. This parameter is so named because of the obvious similarity between a 3D random landscape and its sea level, looking from above.

The start colour (the colour right next to the sea areas) can be set and adjusted in exactly the same way.

There are 8 default sea level and start colour settings already programmed into the application. These have been chosen because of the interesting and colourful fractals they produce, and are well worth examining. The left mouse button will proceed in ascending order through the settings, whilst the right mouse button does the opposite.

The last tablet will generate fractals, in either of 2 ways. If the left mouse button is clicked then a seed value will be picked at random, and the fractal generated. If the right mouse button is clicked, the current fractal will be regenerated. This is particularly useful for seeing the effects of changing the sea level and start colour for a particular fractal.

Technical Details
-----------------
The application uses a fairly straightforward method to produce the (pseudo) random fractals. The main algorithm is only given the value (representing the colour) of the four corners of the square.

The centre value of the square is calculated by finding the average of the surrounding corner values, plus or minus a random amount which is scaled to suit the resolution: when calculating this for the first time, the scaling factor will be large, but when the fractal is nearly complete this will be much lower.

The four side values are then calculated by taking the average of their two adjacent corner values, again plus or minus a random amount that is scaled.

At this stage, four smaller squares have now been generated inside the main square. Therefore the above procedure can be used again and again until a full fractal has been generated.

The diagram below demonstrates this method:

C1  S1  C2

S2  M1  S3

C3  S4  C4

M1 = (C1 + C2 + C3 + C4) / 4  +  rnd% * scale%
S1 = (C1 + C2) / 2  +  rnd% * scale%
S2 = (C1 + C3) / 2  +  rnd% * scale%
S3 = (C2 + C4) / 2  +  rnd% * scale%
S4 = (C3 + C4) / 2  +  rnd% * scale%

The program has been extensively documented, especially the assembly language sections, which should help anyone to look into the method of implementation further.

It is worth noting that even though the above method seems quite simple to implement, the Basic program that was used to create the assembly program was quite complex, since it was designed to be as quick as possible. The translation to assembler reduced the time to produce a fractal from around 3 minutes to approximately one second!

 RISC User 1992
