Hyphae simulation

25 Nov 2010 Code on Github

[This is a blog post about a Python simulation I wrote some time ago. You can get the code by clicking the Github link above. I have Javascript version you can edit here.]

I've started work on a simulation of fungus-like hyphae, based on project I saw called Mycelium.

The simulation starts with a single growing point. This point has a speed, a direction, and an curvature. In each tick of the simulation, its direction changes based on its curvature and its position changes based on its angle and speed. Currently its speed is fixed. The pixel it is on is coloured in. Each tick there a probability of its curvature changing and/or it splitting into two growing points (each with an angle 45 degrees to the parent's, and with opposite curvatures). Then the two points continue independently.

Below is a video of my first attempt, which only took about an hour to code, most of which was spent playing with the parameters.

Below is a slight update, changing the colours, and making the hyphae translucent, so points that overlap are brighter:

There is a lot of scope for improvements. I need to have some way to kill growing points, ideally based on a lack of food (i.e. high density of hyphae). You can see that by the end of the video, the simulation is slowing due the the exponential growth of growing points. I'd also like to try using an image to represent food. It might be fun to evolve the parameters, such as splitting probability, but I'm not sure what fitness function would be suitable, perhaps one to maximise the coverage of screen.

Comments (4)

Anonymous on 3 Feb 2013, 3:29 p.m.

Any chance you can share the code?

Jesse on 27 Mar 2013, 5:48 p.m.

Hey this is a cool idea! Nice work! I've been working with genetic programming and would like to merge it with something like this. Could you post the source or email it to me?

Peter on 29 Mar 2013, 3:45 p.m.

If you email me via the Contact Me button on the left side of this page, I can email you the code.

Jasper on 12 Sep 2017, 4:05 a.m.

Hi Peter I am a student doing master of architecture in Hong Kong. I am studying on the growth of mycelium and wonder if you mind sharing or giving me hints on how to code that. It is really amazing and I have no idea how to start. Hope you can help! Thanks