Contributions are welcome! Feel free to open a pull request or submit an issue if you find any bugs or have any suggestions for new features.
Emergent behavior is a fascinating phenomenon that can be observed in a variety of complex systems. By simulating these systems, we can gain a better understanding of how they work and how emergent behavior arises.
This project is a simulation of emergent behaviour, with particles that interact with each other and their environment. In this simulation, I start off with particles that move and bounce around at a constant speed. Then one after the other we start adding simple interaction rules. At the end we find that even with an extremely small set of rules, the emerging behaviour is seeming chaotic but oddly organised.






TODO: Better GIFs to be added here later.
https://user-images.githubusercontent.com/95016059/222963837-e8ee8f93-9801-4724-95ba-d5fdd2b2f799.mov
https://user-images.githubusercontent.com/95016059/222963862-7694d343-2658-421c-ae9e-ea5b7686f50f.mov
https://user-images.githubusercontent.com/95016059/223040045-1a34ad97-63f3-4325-9cc7-e44061713d26.mov
https://user-images.githubusercontent.com/95016059/223040070-bec16136-0791-455a-84ab-9abf429b69cb.mov
The following decisions were made during the implementation of the simulation:
The simulation is written in Python, using the Pygame library for graphics. The particles are represented as circles on the screen, and their movement and interactions are determined by a series of simple physics calculations.
Each particle is assigned a force value, which determines how strongly it repels or attracts other particles. The force value is randomized at the start of the simulation within a defined range. The particles also lose a small amount of energy over time, causing them to eventually slow down and come to a stop.
The walls of the screen exert a heat force on the particles, which pulls them towards the centre of the screen. This force is also randomized at the start of the simulation. The walls themselves can be set to be either hard boundaries or elastic, causing particles to either bounce off of them or be attracted to them.
The simulation consists of several particles that move around a 2D environment. Each particle follows basic laws of physics: it moves with constant velocity unless acted on by an external force, and it experiences a force proportional to the inverse square of the distance to other particles. The particles are also affected by the boundaries of the simulation environment, which exert a repulsive force to keep them from leaving.
The particles are also affected by a global “heat” value, representing the system’s overall energy. As the heat increases, particles move more rapidly and collide with each other more frequently. Conversely, as the heat decreases, particles slow down and collisions become less common. The user can adjust this heat value to control the behaviour of the system.
The particles are displayed as coloured circles on the screen, and the user can adjust their size and colour. Additionally, the user can adjust the number of particles in the system and their initial velocity.
Other details about the rules are skipped here.
git clone https://github.com/vishalpaudel/emergent-garden.gitcd emergent-gardenpython3.11 -m venv .venv --prompt="emergent-garden"source ./.venv/bin/activatepython -m pip install -r requirements.txtpython main.py./src/constants.pyTo run the simulation, navigate to the directory containing the main.py code and run the following command:
python main.py
There are several constants defined in the constants.py file that control various aspects of the simulation:
For advanced users, the simulation includes a number of additional controls:
The current implementation of the simulation provides a solid foundation for exploring emergent behaviour in complex systems. However, there is always room for improvement and expansion. Some potential areas for future work include:
This simulation provides a simple but powerful tool for exploring emergent behaviour in particle systems and can be expanded upon in a variety of ways to explore even more complex systems.
BrainXYZ (YouTube)
This project is licensed under the MIT License. See the LICENSE file for more information.
@vishalpaudel