Aug 21, 2025
2 min read
The Simulation
A dynamic ecosystem that you can use to study predator-prey-plant interactions.

This simulation project integrates multiple components to create a dynamic ecosystem that a researcher can use to study predator-prey-plant interactions, with the ability to add or remove any species or environmental factors easily by editing the given JSON file. Infact, almost every aspect of the simulation can be controlled in the JSON file. The simulation is designed to simulate without any grid-based restrictions, allowing entities to move freely in a continuous space. The entities also have their own genetics, which are inherited from parent and may mutate, all of which are initialised in the JSON file, where it is intended for all users of the program to modify it to play with the simulation parameters.
Even though this was a coursework, we went, like the other time, above, beyond, and even more! We added a genetics system , weather, time of day, sexual production, quadtree optimisation, and a fully fledged out customisation system with the JSON file.
Web sockets!
That wasn’t enough for me; I wanted to create a frontend with the backend sending data, so the simulation runs on the backend, and only the visualisation is done on the browser.
At first, I decided to use Redis, but soon realised that just wouldn’t work, as I was fetching data from Redis every 30ms and writing data every frame from the backend — there wasn’t a “subscription” kind of callback.
I was skeptical of web sockets at first because I had to write out a full server code in Java and I was just unsure. Until I tried it out. Surprisingly, it wasn’t that difficult — mostly following MDN docs and just creating it. With this approach, I can sign ids to different connections and create multiple Engine
objects for each client.
Surprisingly, it works really well: see for yourself. Seemingly, the only issue arises when the entity count is over 10K. At that point, even with all of the improvements, the payload exceeds 200KB. And at 60FPS, we need internet speeds of up to . This slows down the simulation by a noticeable factor, so I would need some more tricks to lower the payload size .
§