This study has explored the use of entity component systems (ECS) in the design of scalable crowd simulators. The procedural aspect of the envisaged crowd simulator is such that the system would be able to intelligently reduce the load, density, and quality of the active crowd to suit the underlying hardware, while still generating believable agent behaviour.
Crowd simulation for virtual environments poses a number of interesting challenges. Particularly in the case of rich open-world games, which immerse the player in large sprawling cities, the
actualisation of agents incurs costs in term of memory and computational – not only to model their respective behaviours but also to store, animate and visualise the assets tied to these behaviours. On memory and/or performance-constrained devices, this could result in a reduction in crowd variety to the extent of breaking user immersion.
The accompanying image shows how a simple ECS would function. The Person and Vehicle entities both have a Translation component, which is used by the Move system. The Vehicle entity also has a DriveTo component. The MoveVehicle system makes use of both the Translation component and the DriveTo component, meaning that only the Vehicle entity would be affected by this system.
This project also explores the benefits of using data-oriented programming (DOP) and ECS over object-oriented programming (OOP). Such benefits include: the performance advantages of scaling with entities rather than scaling with objects, and the principle of composition over inheritance in order to solve the hierarchy issues caused by OOP. In this work, the Unity ECS implementation was used by making use of Unity’s Data-Oriented Technology Stack (DOTS), thus
facilitating the writing of thread-safe code, due to its checks. Furthermore, it also enhances the performance of the system significantly.
A case study was developed to tie in crowd simulation and the hierarchy issues with OOP, through the interaction of a crowd of people and a fleet of cars. The people could be equipped with a gun to
be able to damage the cars or harm other people. However, a car with a gun attached to it would be as simple as adding a gun component to it. The people could also have a sword with different elemental powers, and combining them would be as simple as adding the respective elemental components. This example was then built upon to create more complexity and further showing how using DOP/ECS tends to be more efficient than using OOP.
Lastly, given the nature of DOP/ECS, the developed code is very modular and expandable. Moreover, since the systems and components are relatively isolated and independent (decoupled), the code also allows for new features to be added easily.
Student: Kyle Camilleri
Course: B.Sc. (Hons.) Computing Science
Supervisor: Dr Sandro Spina
Co-supervisor: Dr Keith Bugeja