Simulation Concepts

Hadean Simulate Cells and Entities

Simulate divides the physical space represented by a simulation into a number of cells, with each cell assigned a Cell Worker Process to manage entities interacting within that space. Created cells do not need to be adjacent, with cells only being created where Entities are present either managed by the cell or as Ghost Entities.
Example: Cell Workers are only created to manage regions containing Entities
Entities possess a position and state. Simulate uses the position to correctly assign an entity to a Cell Worker managing the region of space holding the entity. Should an entity move into a region not currently assigned to a Cell Worker, a new one will be created. Similarly, Cell Workers will be deallocated if they no longer have any entities to simulate.
When a region of space managed by a single Cell Worker becomes too populated causing the work load to exceed what a single process can handle, Simulate divides this region assigning new Cell workers to each division allowing for more processing capacity to be made available for that region. Conversely when a region becomes underpopulated Simulate is able to recombine multiple Cells to reduce the number of Cell Workers assigned, thereby saving resources.

Viewing Entities Across Cell Borders

Entities require visibility of each other if they are to interact. While those in the same cell are immediately aware of one another, they would not automatically have visibility of entities across their cell border in another cell even if that entity is very close in physical space.
To solve this Simulate is able to populate a cell with data about entities from neighbouring cells during a process called Handover. Entities of interest to a particular cell are mirrored based on an area of interest called the Handover Radius. If a Handover Radius extends into another cell Simulate considers this to be a Entity of interest. These mirrored entities are referred to as as Ghost Entities
The state of Ghost Entities can not be edited by the cells that receive them. It is only possible for an Simulate worker to modify the state of entities located in the region of space it manages.
The Handover Radius is defined by a bounding box around the position of an entity. If this bounding box overlaps the space managed by another Cell Worker, that Cell Worker will receive a Ghost Entity copy of the entity. The bounding boxes areas can be defined on a per entity basis; for example, larger entities may need to be seen or interacted with at further ranges than smaller ones.
Currently in Simulate, an entity a can see an entity b if either of the following two conditions are met:
  1. 1.
    Entities a and b are located within the same cell.
  2. 2.
    Entity b's bounding box covers any region of the cell in which entity a is located.
In the diagram above two different types of entity have been created each with a different Handover Radius' where bounding boxes are denoted by dashed lines.
  • Entity E1 is visible in all cells as its Handover Radius extends into all the other cells
  • Additional cells 5 & 6 have been created as the Handover Radius for E1 now extends across previous unmanaged space even though those cells do not manage any entities. They will only contain Ghost Entities
  • E3 and E4 are visible to Cell 2 but E2 and E5 are not. This would mean that Although E5 was aware of E1, E1 would not be aware of E5
  • Entity locations are within the bounding boxes but do not need to be at the centre

Moving Entities Between Cells

Entities may move around during the life of a simulation. If the position of an entity moves beyond the edge of of the region of spaced managed by its current Cell Worker, the entity ownership will be transferred to the Cell Worker responsible for the region it has moved into. This will create a new Cell if necessary, however if the Entity had a non-zero Handover Radius defined it is likely this cell would already have been created.

Describing Entity Locations

The only requirements Simulate places on an entity is that it has a physical position provided using integer co-ordinates. The Handover Radius is define as an axis aligned bounding box (AABB) around the entity, but can be set to zero. Simulate requires that an entities location needs to be within its defined AABB, however does not need to be positioned at the centre.
Using integer co-ordinates ensures that Simulate is capable of deciding in which cell an entity is located reliably, since floating point arithmetic is avoided. This does not constrain entities using floating point arithmetic for their position representation (and all existing Simulate demos do this) within a cell. Since Simulate only partitions a simulation on integer co-ordinate boundaries, it does not require knowledge of fractional co-ordinates.


Handover Radius
Bounding box around an entity. When a bounding box overlaps another cell a Ghost Entity will be created in the neighbouring cell
Ghost Entity
A read only copy of an entity that is managed by another cell and updated every tick
A region of physical space represented in the simulation
Cell Worker
A Hadean Process assigned to manage a Cell
A Simulate operation executed every tick to pass information for entities between cells
A representation of some data within the simulation. Typically a car, person, molecule etc but can represent any data tied to a physical location