# Total Mudflat Algorithm

The simulation of a horse race in the Wadden Sea required the development of several new individual algorithms that form the Total Mudflat Algorithm (TMA, German: Gesamtwattalgorithmus, GWA). Therefore a Lugworm Algorithm (LWA, German: Wattwurmalgorithmus, WWA) and a Splashwater Algorithm (SplashWA, German: Spritzwasseralgorithmus, SpritzWA) had to be developed and united with the Hoopfrint Algorithm and the Slipstream Algorithms. The development took several weeks. The first use is planned for GaloppSim version 149.10 (release expected in October / November 2018).

This post shows the individual steps during the development of the SplashWA, including the full integration into the Total Mudflat Algorithm.

At first, the Squirt Pattern (SQP) was defined in various forms and the range of the Squirt Length (SQL) was set. Each SQP is determined randomly from three patterns (xlGray8, xlGray25 and xlCrissCross) and the SQL by a random integer between 4 and 8. It was initially assumed that the mudflat is consistently covered with water. The splashwater analysis screenshot material was achieved using a multiple-exposure, cross-fade technique.

At the beginning of the algorithm development, the Squirt Colour (SQCol) was calculated randomly from the colours black, white and blue (which was changed at a later stage of development).

The idea to consider the splashwater width as a fourth factor was soon discarded, as the analysis of real mudflat races showed a rather constant width.

The simulation without the crossfading picture technique shows splashing water in various random patterns, lengths, widths and colours behind each horse.

From this, a pure three-factor simulation was derived with random SQL, SQP and SQCol and a constant width.

Next, the splashing water behind a horse was partially drawn into the horse, as also the front hoof pair splashes slightly. The simulation horses therefore ran a few laps at low water level.

Thus the intermediate state at this development time was as shown in the next screenshot with multiple exposure …

… and without the crossfade technique.

After video analysis of real races, the squirt colour was revised and replaced by the complete tint-and-shade range of the xlThemeColorDark1 colour theme. Hereby the blue tones disappear because splash water, unlike silent water has no blue colour and varies depending on the splash angle and the light refraction between saturated black and pale white in a range of Fifteen Shades of Grey.

Thus, the Splashwater Algorithm was finished in its basic form and could be graphically displayed in a realistic manner.

Next, the tidal range caused by the gravitational forces had to be taken into account, which means that the mudflats are covered with different water levels exerted by the moon and the sun. The range extends from dry mudflats at low tide over puddles to a fully covered seabed at high tide. The light reflection of the water in the Wadden Sea is represented by a brighter, lighter grey.

The test horses ran through the seabed at a simulated water level of about 4 inches.

The next step was to develop a logic that only triggers the Splashwater Algorithm when a horse runs through water. For this purpose, the water was marked, …

… the horse run was registered …

… and the marks were finally removed.

So the splash logic can be described mathematically with the formula
Log(S) = Water ⇒ (( Rnd (SQL) Rnd (SQP) Rnd (SQCol) ))
and can be integrated into the basic splashwater algorithm.

Based on this, lugworms from the Latin, Cyrillic, Greek and Coptic Unicode blocks as well as special lugworm characters were placed in the Wadden Sea, which should be visible on dry ground but not under water. Lugworms can be crushed under hoofs which is realized by the UTF lugworm crush character 1154 (decimal) aka “Cyrillic Thousands Sign”.

Thus, all mudflat specific conditions were considered in the pure mudflat algorithm.

The last step to the Total Mudflat Algorithm was to consider the optional hoof prints as well as the slipstream visualisation.

Hoof prints under water are not visible, and a crushed lugworm overrides a pure hoof print in the mudflat.

A slipstream effect is visualised in dry ground, but can be overridden by splashing water.

The last figure shows the TMA with all mandatory and optional subalgorithms as it could be used in a mudflat racing simulatior.