Brilliant Solution in a Maze: The Marangoni Effect and Surface Tension
Polish version is here |
The following article was originally published in the journal for educators Chemia w Szkole (eng. Chemistry in School) (4/2021):


We typically describe a maze as a structure or a building characterized by a complex arrangement of numerous rooms and interconnecting corridors. Scaled-down models of such edifices can also serve as mazes. These constructions date back to ancient times — for example, in Mesopotamia and Egypt — where they functioned as security measures and impediments to richly adorned, treasure-filled tombs. In Greek and Roman art, representations of mazes (often symbolic and highly stylized) were common in vase paintings, mosaics, and coinage.
One of the most frequently recounted labyrinth is said to have been built by the legendary Greek architect and inventor Daedalus. According to tradition, this structure stood in Knossos on Crete and was used to confine the Minotaur, a creature portrayed as a giant with the head of a bull.
The labyrinth motif also appeared as an ornamental design featuring intricate, usually spiral or meandering patterns. In Gothic cathedrals, such mazes were often inlaid into the flooring. A 12th-century example can be seen in the cathedral at Chartres in northern France. These designs were not purely decorative; walking the intricate path on the cathedral floor symbolized undertaking a pilgrimage.
Mazes continue to be created today as attractions or forms of entertainment, for instance in parks and gardens where hedges are planted and shaped to form maze-like passages.
The complex structure of a maze serves both as a puzzle and as a test of problem-solving ability. Thus, many of us are familiar with biological experiments in which animals — mice, rats, guinea pigs, and others — are placed in mazes. Such experiments have been conducted historically and sometimes continue in contemporary research. I myself have described some simplified experiments in neurobiology and behaviorism that can be performed in a school laboratory; these used the rough woodlouse Porcellio scaber [1].

Solving the problem of navigating a maze by the shortest route is far from trivial and has attracted researchers from various fields. The first practical solution was a device built in 1953 by American cybernetics pioneer Claude E. Shannon — dubbed “Shannon’s mouse” by others and “Theseus” by the inventor himself. The apparatus comprised three main components: a maze with a moving mouse model, an electromagnetic system controlling the mouse’s movements, and a memory system based on electromechanical relays. Theseus demonstrated memory mechanisms inspired by nature and illustrated the practical possibility of building a device capable of learning by trial and error.
Today, maze-related and analogous problems remain highly relevant and are typically solved by specialized computer programs.
Before moving on, I would like to recall a passage from Stanisław Lem’s “Star Diaries”, in which during the Twenty-First Voyage, Ijon Tichy visits the planet Dichotica. The inhabitants there advanced artificial thinking to such an extent that they could produce “minds and intelligences in liquids. Sentient, reasoning solutions were synthesized, and these could be bottled, poured, mixed, and each time you would end up with a new personality, often more spiritual and wiser than all the Dichoticans put together” [2].
Lem’s bold imagination ventured into realms of science we have yet to explore, and it is difficult to envision how such a thinking solution might be realized. However, I can confidently assert that after reading this article, you — Dear Reader — will be able to create a solution that, under appropriate conditions, will find the shortest path through a maze from start to finish. While it may not be as ingenious a liquid as Lem described, the experimental results will demonstrate that an artificial information-processing construct (i.e., intelligent in a limited sense) need not take the form of an electronic device or computer program, but can be a relatively simple physicochemical system, as in our case.
Experiment
To carry out the experiment, gather the following chemicals:
- potassium hydroxide KOH (or sodium hydroxide NaOH),
- oleic acid C17H33COOH,
- hydrochloric acid HCl(aq),
- a dye such as bromothymol blue C27H28Br2O5S or methyl red C15H15N3O2,
- agar-agar (optional).
Oleic acid is an unsaturated fatty acid, a colorless liquid under normal conditions, gradually yellowing and then darkening on exposure to air (Photo 1).
This compound occurs naturally in fats and is a major component of olive oil and cod liver oil [3]. Due to its double bond, oleic acid can be hydrogenated to stearic acid, a process known as fat hardening. It is used in the production of lubricants and detergents.
Oleic acid itself is not highly toxic, but the other reagents require caution. Both sodium hydroxide and hydrochloric acid are corrosive and can cause severe, hard-to-heal burns. Bromothymol blue (Fig. 1) and methyl red (Fig. 2) are carcinogens. As always in the laboratory, appropriate personal protective equipment is mandatory.


You will also need to fabricate a suitable maze. The channels should be relatively narrow, approximately 1–2 mm (0.04–0.08 in) wide. Various fabrication methods are possible, such as milling or engraving in plastic, but 3D printing is particularly convenient.
I used an FDM (fused deposition modeling) 3D printer, which deposits molten material layer by layer. Such desktop units are readily available both commercially and as DIY kits, and many schools and university labs have acquired them through funding programs. The filament is extruded through a nozzle heated to its melting temperature, forming the object one layer at a time.
In my works, I used polylactic acid (PLA), a polyester of lactic acid with repeating unit −[−CH(CH3)C(O)O−]−. This biodegradable polymer is made from renewable resources such as corn starch and finds applications in biomedicine.
PLA degrades faster under UV light, moisture, and other environmental factors, so printed parts should be stored appropriately if long-term use is intended. Of course, other nonbiodegradable filaments could also be used, but printing parameters would need adjustment.
I designed the maze in FreeCAD (ver. 0.19.2) and exported it as an *.stl file compatible with most slicers. Photo 2 shows the maze design rendered in Blender (ver. 2.93.1). Both programs are free and open-source, so anyone can create their own layout. For initial experiments, you can download the maze file here.
Print settings were standard for PLA: white filament, a 0.4 mm (0.016 in) nozzle, and a 0.2 mm (0.008 in) layer height. Higher resolution was unnecessary. Scale the model to your requirements—in my case, the side length was 55 mm (2.17 in). The print took approximately 45 minutes, yielding a ready-to-use maze (Photo 3).
As you can see, the maze is simple, but let’s see how our solution handles it.
To prepare the agar gel, dissolve 2 % (w/w) agar-agar in boiling water, pour the mixture into Petri dishes, and let it set at room temperature. Once firm, you can cut out uniform disks (Photo 4).
Cut the disks into small fragments that fit the maze exit area, then immerse them in ~3.7 % HCl solution for 5-6 hours (Photo 5).
If agar is unavailable, a small acid-soaked sponge or cloth works similarly.
Next, prepare the solution by dissolving 0.28 g (0.01 oz) KOH in 100 cm3 (3.4 fl oz) distilled water, then adding ~0.2 cm3 (0.007 fl oz) oleic acid with vigorous stirring. The result is a clear, foaming solution (Photo 6).
Level the maze carefully, then fill its channels to half height with the solution (Photo 7A).
Place an acid-soaked agar fragment at the maze end (M), then quickly introduce a small amount of solid bromothymol blue at the start (S), ensuring the powder rests on the liquid surface. Within moments, the colored streak flows not randomly but along the shortest path to the finish (Photo 7C), changing hue from blue through green to yellow as it proceeds.

You may also use methyl red (Photo 8), although its color change — from yellow-orange to red — is slightly less pronounced.
A time-lapse sequence (Photo 9) using a different but similar maze and bromothymol blue further illustrates the effect with one-second intervals between frames.
Explanation
The observed effect and the system’s “ability” to solve the shortest-path problem stem from surface-tension phenomena [4]. Surface tension is the physical energy per unit area at the interface between a liquid and a solid, gas, or another liquid; it behaves like an elastic membrane covering the liquid surface. Quantitatively, it equals the work required to increase the surface area by one unit.
Surface tension arises from cohesive forces between liquid molecules exceeding adhesive forces at the interface. One key factor influencing tension is the presence of surface-active agents (surfactants), which accumulate at interfaces and facilitate contact between phases. These molecules feature a hydrophilic (polar) “head” and a hydrophobic (nonpolar) “tail”. A surfactant that reduces the water-air interfacial tension must contain both elements.
One manifestation of tension gradients is the Marangoni effect, which drives fluid flow from regions of low to high surface tension. You can observe this by adding a drop of soap to a talc- or pepper-covered water surface: particles are suddenly propelled away from the drop due to the local tension reduction [5].
In our system, oleic acid (HR, with R denoting its hydrocarbon chain) deprotonates in the alkaline solution:
This reversible equilibrium shifts toward deprotonation in basic conditions and toward protonation in acidic conditions. Oleate ions (R−) are excellent surfactants: their polar head carries a negative charge (hydrophilic), while their long hydrocarbon tail is hydrophobic, enabling foam formation (Photo 6).
Filling the maze with this solution establishes uniform surface tension throughout the channels. Introducing the acid-soaked agar at the start creates a pH gradient — higher pH near S and lower pH near M. Consequently, the surfactant concentration and thus the surface tension increase toward the finish. The Marangoni effect then drives a surface flow carrying dye particles along the shortest route from S to M. Note that the flow is confined to the surface; the underlying liquid moves oppositely, so dye application must target the interface.
The color transitions of the pH indicators visualize the environmental gradient. Crucially, if two paths exist, the dye stream chooses the shorter one first, illustrating the system’s inherent path-finding property.
References:
- [1] Ples M., In the Maze: How Woodlice Make Decisions, Biologia w Szkole (eng. Biology in School), 4 (2019), Forum Media Polska Sp. z o.o., pp. 56-62 back
- [2] Lem S., Dzienniki Gwiazdowe, Czytelnik, Warszawa, 1976, pp. 235 back
- [3] Hassa R., Mrzigod J., Podręczny słownik chemiczny, Videograf II, Katowice, 2004, pp. 213 back
- [4] Suzuno K., Ueyama D., Branicki M., Tóth R., Braun A., Lagzi I., Maze Solving Using Fatty Acid Chemistry, Langmuir, 2014, 30(31), pp. 9251-9255 back
- [5] Thomson J., On certain curious Motions observable at the Surfaces of Wine and other Alcoholic Liquors, Edinburgh and Dublin Philosophical Magazine and Journal of Science, Londyn, 1855, pp. 330-333 back
All photographs and illustrations were created by the author.
Marek Ples