Physarum polycephalum, commonly known as slime mold, is a unicellular, multinucleate organism with remarkable problem-solving abilities. It uses a unique form of decentralized decision-making to locate nutrients and optimize its movement paths. These behaviors have significant relevance to modern challenges in fields ranging from biology to computational modeling. The goal of this project is to model these unique behaviors using a cellular automaton. A cellular automaton is a type of discrete model that relies on simple, local rules to generate complex patterns. This approach is particularly well-suited for simulating slime mold because neither system relies on centralized intelligence. A key feature of this simulation is its ability to reproduce maze navigation, a well-known demonstration of slime mold’s intelligence. The organism exhibits both pathfinding and efficient optimization behaviors when navigating mazes. Studying this form of decentralized intelligence could have broad implications across various fields. As new forms of computing emerge, it becomes increasingly important to match each problem with the most suitable model. Slime mold-inspired computing may offer valuable insights for areas such as bio-inspired algorithms, optimization techniques, and potentially even advanced algorithmic design.
Introduction
Introduction
Slime mold, specifically Physarum polycephalum, is a unicellular but multinucleate eukaryotic organism. Despite lacking a nervous system, brain, or any centralized control structure, this organism has gained considerable attention in recent years for its intelligent-seeming behaviors. Slime mold is capable of decentralized problem-solving, spatial memory, and efficient path optimization. These tasks are typically associated with higher-order organisms or artificial intelligence systems.
These behaviors are not only biologically intriguing but also offer inspiration for computational modeling. In this project, a Cellular Automaton (CA) is used to replicate these capabilities in a simplified, discrete environment. The simulation focuses on capturing how slime mold moves toward nutrient sources by responding to chemical gradients, a process known as chemotaxis. Additionally, it aims to reproduce the organism’s ability to navigate mazes and form optimized transport networks, mimicking the shortest or most efficient paths between multiple points.
These behaviors are not only biologically intriguing but also offer inspiration for computational modeling. In this project, a Cellular Automaton (CA) is used to replicate these capabilities in a simplified, discrete environment. The simulation focuses on capturing how slime mold moves toward nutrient sources by responding to chemical gradients, a process known as chemotaxis. Additionally, it aims to reproduce the organism’s ability to navigate mazes and form optimized transport networks, mimicking the shortest or most efficient paths between multiple points.
Begin by setting up the computational environment with reproducible random seeds and utility functions.
In[]:=
SeedRandom[8476531907503659865796934659734698634985698346596349856496]
Out[]=
RandomGeneratorState
The Biological Foundation
The Biological Foundation
Physarum behavior consists of two main parts. Find the food and optimizing it’s path. More scientifically it moves by extending pseudopodia in response to chemical gradients. Then, forms dynamic protoplasmic networks to connect food sources. The biological phenomena to be modeled are chemotaxis and network optimization. As a benchmark for this, the simulation slime is placed inside of a maze. A maze test shows off the tube formation and shortest path finding behavior of the slime mold. As previously stated, the slime mold does not have a central nervous system. The implication of this is that all ‘decision making’ is localized. A cellular automata model is a distributed model of intelligence, like the slime mold. The abstraction, behavior, of slime mold can be rather simplified, making it a perfect candidate for a cellular automata (CA).
Cellular Automata as a Modeling Framework
Cellular Automata as a Modeling Framework
Cellular automata is an ideal framework for modeling distributed biological systems. Each cell’s next state depends only on its current state and immediate neighbors, yet complex patterns can come from these simple local rules.This approach imitates how slime molds make decisions based on local chemical information.
getNeighbors takes a grid of states and an index and returns a list of the values in neighboring cells respecting grid boundaries.
In[]:=
getNeighbors[grid_,{i_,j_}]:=Module[{rows,cols,neighbors},{rows,cols}=Dimensions[grid];neighbors=Flatten[Table[If[1<=i+di<=rows&&1<=j+dj<=cols,grid[[i+di,j+dj]],3],{di,-1,1},{dj,-1,1}]];Delete[neighbors,5]]
analyzeNeighborhood takes a list of neighboring cell values and a signal strength, returning an association summarizing the presence and counts of slime, food, and pheromones.
In[]:=
analyzeNeighborhood[neighbors_,signalStrength_]:=<|"slimeCount"->Count[neighbors,1],"foodCount"->Count[neighbors,2],"pheromoneCount"->Count[neighbors,4],"hasFood"->MemberQ[neighbors,2],"hasPheromone"->MemberQ[neighbors,4],"signalStrength"->signalStrength|>
Behavioral Classification System
Behavioral Classification System
Each cell on the grid can be in one of five distinct states, each representing a component of slime mold behavior :
◼
Empty–A neutral, unoccupied space with no slime mold or chemical signals .
◼
Slime–Currently part of the active slime mold, capable of sensing and moving .
◼
Food–A nutrient source that continuously emits a chemoattractant to guide slime movement .
◼
Wall–An impassable obstacle that blocks both slime mold growth and chemical diffusion .
◼
Pheromone–A cell recently occupied by slime, retaining a fading chemical trail .
These five states collectively represent the biological and environmental features necessary to simulate the slime mold' s growth, navigation, and decision.
Determines the state of a slime-occupied cell based on neighborhood analysis, returning a label like “nearFood” or “deadEnd” according to slime density and presence of food or pheromones.
In[]:=
classifySlimeState[analysis_]:=With[{s=analysis["slimeCount"],hasFood=analysis["hasFood"],hasPheromone=analysis["hasPheromone"],p=analysis["pheromoneCount"]},Which[hasFood,"nearFood",s>=4,"denseNetwork",s>=3&&hasPheromone,"guidedNetwork",s==2&&hasFood,"foodPathway",s==2&&p>=2,"pheromonePathway",s==1&&!hasFood&&p==0,"deadEnd",s<=1&&!hasFood,"isolated",s==2&&!hasFood&&!hasPheromone,"weakConnection",True,"retract"]]
The active slime cells are a direct parallel to the pseudopodia front. In the CA there are two distinction of slime, slime active and slim trail. One is currently apart of the slime mold and the second is where slime recently was. In the model this decaying cytoplasmic residue is called pheromone. It is called pheromone because when the mold interacts with the slime trail it releases a pheromone. Pheromones are also released in the presence of nutrient stimuli, the food source.
Determines the growth behavior of an empty cell based on surrounding slime, food, pheromones, and signal strength, returning a label such as “growToFood” or “stayEmpty”.
In[]:=
classifyEmptyState[analysis_]:=With[{s=analysis["slimeCount"],f=analysis["foodCount"],hasFood=analysis["hasFood"],hasPheromone=analysis["hasPheromone"],p=analysis["pheromoneCount"],sig=analysis["signalStrength"]},Which[hasFood&&s>=1,"growToFood",f>=2&&s>=2,"growToMultipleFood",s>=4&&hasPheromone,"denseGrowth",s>=3&&hasPheromone,"moderateGrowth",s>=2&&f>=1&&hasPheromone,"guidedGrowth",s>=3&&RandomReal[]<0.1,"exploration",True,"stayEmpty"]]
Transition Rules and Biological Plausibility
Transition Rules and Biological Plausibility
In this model, a Moore neighborhood is used. A Moore neighborhood is the 8 surrounding cells of the one being evaluated. The rules that dictate the state of the cell are called transition rules. Transition conditions are based on the neighbor states and chemical strength.
Defines how slime-occupied cells transition based on their classified state, with most continuing as slime (1), while less favorable states (like “deadEnd” or “isolated”) probabilistically retract to empty (4).
In[]:=
slimeTransitionRules=<|"nearFood"->1,"denseNetwork"->1,"guidedNetwork"->1,"foodPathway"->1,"pheromonePathway"->1,"deadEnd"->If[RandomReal[]<0.8,4,1],"isolated"->If[RandomReal[]<0.95,4,1],"weakConnection"->If[RandomReal[]<0.9,4,1],"retract"->4|>
Out[]=
nearFood1,denseNetwork1,guidedNetwork1,foodPathway1,pheromonePathway1,deadEnd1,isolated4,weakConnection4,retract4
A slime ‘moves’ towards higher concentrations of the chemoattractant let off by the food. This is where the randomness comes in. Parts of slime mold exploration are random, they are not when all possible direction have the same level of chemoattractant it becomes a random choice which it chooses. This leads to the pseudopodia expanding multiple different directions.
Specifies how empty cells transition based on their classified state, where promising growth states become slime (1), and unpromising ones remain empty (0).
In[]:=
emptyTransitionRules=<|"growToFood"->1,"growToMultipleFood"->1,"denseGrowth"->1,"moderateGrowth"->1,"guidedGrowth"->1,"signalGrowth"->1,"exploration"->1,"stayEmpty"->0|>
Out[]=
growToFood1,growToMultipleFood1,denseGrowth1,moderateGrowth1,guidedGrowth1,signalGrowth1,exploration1,stayEmpty0
When a cell becomes active, it leaves a pheromone behind. This pheromone makes that cell more desirable for the next cell that comes across it. It will fade over unless it is reinforced. This is analogous to the feedback loops of pseudopodia. The stochastic and probabilistic components mimic the environmental variability.
Core Update Mechanism
Core Update Mechanism
In a CA, it is a synchronous update of the entire grid at each time step. Each cell decides it’s next state based, its current state, the chemical gradient, states of neighboring cells. The update rules are as such:
◼
Solid cell: Stays the same
◼
Food cell: Stays the same
◼
Pheromone cell: Probabilistic decay
◼
Slime cell: Analyze and classify
◼
Empty cell: Analyze and classify
The analyze and classify call back to the previous function that have more rules for slime growth.
Determines the next state of a cell based on its current value, the values of its neighbors, and signal strength, applying appropriate transition rules depending on whether the cell contains slime, is empty, or holds food, signal, or a wall.
In[]:=
updateCell[center_,neighbors_,signalStrength_]:=Module[{analysis,classification},Switch[center,3,3,2,2,4,If[RandomReal[]<0.95,4,0],1,(analysis=analyzeNeighborhood[neighbors,signalStrength];classification=classifySlimeState[analysis];Lookup[slimeTransitionRules,classification,4]),0,(analysis=analyzeNeighborhood[neighbors,signalStrength];classification=classifyEmptyState[analysis];Lookup[emptyTransitionRules,classification,0]),_,center]]
Applies updateCell to every cell in the grid, using corresponding positions in the signal grid to produce the next generation of the cellular automaton.
In[]:=
updateGrid[grid_,signalGrid_]:=Module[{dims=Dimensions[grid]},Table[updateCell[grid[[i,j]],getNeighbors[grid,{i,j}],signalGrid[[i,j]]],{i,1,dims[[1]]},{j,1,dims[[2]]}]]
Runs the cellular automaton for a given number of steps starting from an initial grid, returning a list of grid states over time.
In[]:=
simulateCA[initialGrid_,signalGrid_,steps_]:=NestList[Function[g,updateGrid[g,signalGrid]],initialGrid,steps]
Chemical Gradient Implementation
Chemical Gradient Implementation
The chemoattractant logic is as such. Food sources emit chemicals, those chemicals diffuse across the grid. The higher the percentage of the chemical the more the slime is attracted to it. In the main example, the slime is placed in a maze. This means the signal gradient must become barrier aware. Where the walls are, state 3, the signal cannot reach. To find the approximate strength of the signal, it first finds the length of the shortest path to the desired cell. This length then becomes the signal percentage. Slime cells will deposit pheromones as additional chemo-attractants. Movement becomes biased by the local gradient values.
This function computes a normalized gradient matrix over a grid, indicating the relative proximity of each empty cell to a fixed food location, while avoiding walls.
In[]:=
createSignalGradient[initialGrid_]:=Module[{gridSize,foodPosition,wallPositions,emptyPositions,gridGraph,prunedGraph,distances,maxDistance,gradient,flatIndex,dist,row,col},gridSize=Dimensions[initialGrid];foodPosition=15+(5-1)*gridSize[[1]];wallPositions=Flatten[Position[Flatten[initialGrid],3]];emptyPositions=Flatten[Position[Flatten[initialGrid],0]];gridGraph=GridGraph[gridSize];prunedGraph=VertexDelete[gridGraph,wallPositions];distances=Association[Table[pos->GraphDistance[prunedGraph,foodPosition,pos],{pos,emptyPositions}]];maxDistance=Max[Select[Values[distances],#=!=Infinity&]];gradient=ConstantArray[0.,gridSize];Do[flatIndex=key;dist=distances[key];If[dist=!=Infinity,row=Mod[flatIndex-1,gridSize[[1]]]+1;col=Quotient[flatIndex-1,gridSize[[1]]]+1;gradient[[row,col]]=(1.-dist/maxDistance)*100.;],{key,Keys[distances]}];gradient]
Maze Environment Construction
Maze Environment Construction
First in the maze construction is the getting the predefined maze. This is found by using the RandomMaze function from the wolfram repository. That maze is converted to binary so the states of the CA can be encoded.
In[]:=
Generates a randomized maze grid of a specified size, converts it to a custom format marking walls, then adds designated slime and food blocks at given positions:
In[]:=
createMaze[size_,slimePos_,foodPos_]:=Module{maze,pic,imageData,slimeBlock,foodBlock},maze=BlockRandom[SeedRandom[6];RandomMaze[4]];pic=Binarize[ImageResize[Image[maze],{size,size}]];imageData=ImageData[pic];imageData=Round[Replace[imageData,{0->3,1->0},{2}]];;foodBlock={{foodPos[[1]],foodPos[[2]]},{foodPos[[1]],foodPos[[2]]+1},{foodPos[[1]]+1,foodPos[[2]]},{foodPos[[1]]+1,foodPos[[2]]+1}};imageData=ReplacePart[imageData,Thread[slimeBlock->1]];imageData=ReplacePart[imageData,Thread[foodBlock->2]];imageData
The maze is an important simulation for the slime to be tested in. It is easy to identify it’s strengths in navigation and path optimization through this maze.
Visualization Functions
Visualization Functions
The cellular automaton represents this biological system using five discrete states: empty space, active slime, food sources, walls,and pheromone trails.
Visualization functions to display the cellular automaton states and the evolution process.
Simulation Execution and Evolution
Simulation Execution and Evolution
Here is where the code comes together. The maze must be called and the signal gradient. Then they must be applied to each other. Then once the evolutions begin to run each one must find the strength of signal gradient, apply the transition rules, update cell states, render and save frame.
Set the size of the grid and number of generations:
Set the signal grid over the maze and then begin the simulation:
Visualization of Results
Visualization of Results
Visualize evolution 0 of the simulation:
The chemical gradient is displayed by this heat-map. Red is closest to the food source and purple is the farthest away, or impassable.
A color graph showing the varying strength the food signal:
Animation and Pattern Analysis
Animation and Pattern Analysis
The animation is an important demonstration of this model. It can be seen how the slime grows and detracts. It takes over 3000 generations to reach the food source.
Creates animated visualizations to show the temporal evolution of slime mold navigation:
Performance Evaluation
Performance Evaluation
The final state of the evolution is the solved maze. This maze is rather simple so it can be visually found what the shortest path is. The slime retracted from redundant paths and had adaptive exploration based on the signal gradient. An overall success.
Analyze and display the final states to evaluate pathfinding success and efficiency:
Biological Correspondence and Limitations
Biological Correspondence and Limitations
All the behaviors that were aimed to be captured have been. Though it is not all the behavior of a slime mold. Slime mold has time based oscillations which were not incorporated for simplicity.
Implications for Distributed Intelligence
Implications for Distributed Intelligence
Distributed intelligence is equivalent to a decentralized decision making. Local rules with feedback create a complex problem solving model. This model can now be applied to routing algorithm, swarm robotics, and self-organizing systems. All would benefit from distributed intelligence.
Conclusion
Conclusion
This project successfully modeled key aspects of slime mold behavior using cellular automata (CA), demonstrating its path optimization in solving mazes. The simulation demonstrated how simple local rules can give rise to complex, goal-directed behavior, closely resembling biological phenomena.
Reflecting on the results, CA proves to be a robust yet lightweight framework for simulating natural systems. The experiment highlights that even minimal rule sets can lead to surprisingly intelligent outcomes, reinforcing the potential of CA in studying and replicating life-like processes.
Future Directions
Future Directions
To further improve the accuracy and biological realism of the model, multiple enhancements are planned. One important addition is the simulation of nutrient depletion, which would allow the slime mold to metabolize nutrients over time. This change would introduce a dynamic feedback mechanism, increasing the urgency or “motivation” for the slime mold to find and refine the most efficient paths to remaining resources. By adding this metabolic component, the model could better capture the adaptive foraging behavior observed in real slime molds.
Another promising direction is incorporating agent-based modeling (ABM) principles, not for the slime mold itself, which is already well represented by cellular automata, but for the chemical signaling gradients that guide its movement. Treating chemical cues as autonomous, interacting agents could create more nuanced and responsive gradients, enhancing the realism of the slime mold’s navigation and decision-making processes.
In addition, introducing learning mechanisms could allow the model to reinforce successful pathfinding behaviors over time. For instance, rules could be adapted to favor previously successful paths, creating a form of memory or habituation in the system. This would move the model closer to emulating the kind of adaptive intelligence slime molds display in nature.
A particularly intriguing feature to be implemented next is oscillatory behavior. In real slime molds, rhythmic contractions drive movement and influence directional choices. Simulating these oscillations may significantly alter how growth and path selection unfold. An open question remains: To what extent will the addition of oscillatory dynamics effect it’s effectiveness?
Beyond maze solving, the applications of this model span a wide range of fields. For example, its principles could create adaptive infrastructure design, where road or utility networks self-optimize based on usage patterns. In crowd dynamics, similar rules could simulate how groups of individuals collectively respond to environmental changes. Furthermore, the model may inform energy-efficient routing algorithms, offering bio-inspired solutions to network optimization challenges in computing, logistics, or telecommunications.
Another promising direction is incorporating agent-based modeling (ABM) principles, not for the slime mold itself, which is already well represented by cellular automata, but for the chemical signaling gradients that guide its movement. Treating chemical cues as autonomous, interacting agents could create more nuanced and responsive gradients, enhancing the realism of the slime mold’s navigation and decision-making processes.
In addition, introducing learning mechanisms could allow the model to reinforce successful pathfinding behaviors over time. For instance, rules could be adapted to favor previously successful paths, creating a form of memory or habituation in the system. This would move the model closer to emulating the kind of adaptive intelligence slime molds display in nature.
A particularly intriguing feature to be implemented next is oscillatory behavior. In real slime molds, rhythmic contractions drive movement and influence directional choices. Simulating these oscillations may significantly alter how growth and path selection unfold. An open question remains: To what extent will the addition of oscillatory dynamics effect it’s effectiveness?
Beyond maze solving, the applications of this model span a wide range of fields. For example, its principles could create adaptive infrastructure design, where road or utility networks self-optimize based on usage patterns. In crowd dynamics, similar rules could simulate how groups of individuals collectively respond to environmental changes. Furthermore, the model may inform energy-efficient routing algorithms, offering bio-inspired solutions to network optimization challenges in computing, logistics, or telecommunications.
References
References
◼
Adamatzky, A., Kalogeiton, V. S., Papadopoulos, D. P., Georgilas, I. P., & Sirakoulis, G. Ch. (2015). Cellular automaton model of crowd evacuation inspired by slime mould. International Journal of General Systems, 44(3), 354–391. https://doi.org/10.1080/03081079.2014.997527
◼
Barbieux, A., & Canaan, R. (2023). EINCASM: Emergent Intelligence in Neural Cellular Automaton Slime Molds. arXiv. https://arxiv.org/abs/2305.13425
◼
Gharehchopogh, F. S., Ucan, A., Ibrikci, T., Arasteh, B., & Isik, G. (2023). Slime mould algorithm: A comprehensive survey of its variants and applications. Archives of Computational Methods in Engineering, 30(4), 2683–2723. https://doi.org/10.1007/s11831-023-09883-3
◼
Li, X.-L., Mirjalili, S., & Chen, H. (2020). Slime mould algorithm: A new method for stochastic optimization. Soft Computing. https://doi.org/10.1007/s00500-020-05258-3
◼
Wei, Y., Othman, Z., Daud, K. M., Luo, Q., & Zhou, Y. (2024). Advances in Slime Mould Algorithm: A comprehensive Survey. Biomimetics, 9(1), 31. https://doi.org/10.3390/biomimetics9010031
◼
Sirakoulis, G. Ch., & Bandini, S. (Eds.). (2012). Cellular automata models simulating slime mould computing. In Lecture Notes in Computer Science: Vol. 7495. Cellular Automata ACRI 2012 (pp. 563–594). Springer. https://doi.org/10.1007/978-3-642-33374-3_60
◼
University of Toronto. (2023). Researchers use virtual slime mould design TTC subway network less prone to disruption. University of Toronto News. https://www.utoronto.ca/news/researchers-use-virtual-slime-mould-design-ttc-subway-network-less-prone-disruption
◼
Adamatzky, A. (2011). Slime mould computes planar shapes. arXiv. https://arxiv.org/abs/1106.5020
◼
Adamatzky, A. (2014). Slime mould electronic oscillators. arXiv. https://arxiv.org/abs/1401.1647
◼
Adamatzky, A. (2015). Applications of Multi-Agent Slime Mould Computing. arXiv. https://arxiv.org/abs/1506.03661
◼
Tero, A., Takagi, S., Saigusa, T., Ito, K., Bebber, D. P., Fricker, M. D., Yumiki, K., Kobayashi, R., & Nakagaki, T. (2010). Rules for biologically inspired adaptive network design. Science, 327(5964), 439–442. https://doi.org/10.1126/science.1177894
◼
Wired. (2011). Slime mold maps out Iberian highways. Wired UK. https://www.wired.co.uk/article/slime-mould-roads
◼
Wolfram Research, Inc. (2019, April 19). RandomMaze. Wolfram Function Repository. Retrieved July 10, 2025, from https://resources.wolframcloud.com/FunctionRepository/resources/RandomMaze
Acknowledgements
Acknowledgements
◼
Rory Foulger, Program Director
◼
Eryn Gillam, Academic Director
◼
Megan Davis, Academic Director
◼
Lyman Hurd, Mentor
CITE THIS NOTEBOOK
CITE THIS NOTEBOOK
Modeling slime mold intelligence through cellular automata
by Jordana Wilkes
Wolfram Community, STAFF PICKS, July 11, 2025
https://community.wolfram.com/groups/-/m/t/3500639
by Jordana Wilkes
Wolfram Community, STAFF PICKS, July 11, 2025
https://community.wolfram.com/groups/-/m/t/3500639