Matrical simulation
This concept has a specific meaning to me in general and in the context of this project.
The word matrical means there is a matrix, or grid, or multi-dimensional array. The word simulation means that the state of the matrix is evolving over time.
Quantization
- Spatial: space is divided into regular cells.
- Temporal: time is divided into regular cycles.
- State: each cell has a state, with a finite number of possibilities.
The choice of the resolution for spatial, temporal and state data is probably a huge factor for the performance and scale of the simulation.
Notes:
- Even with a high temporal resolution, with a partial evaluation of cells what matters the most seems to be the actual number of events executed for each cycle. E.g. the simulation of light may use the highest update frequency, whereas the simulation of water may be slower. But, it still increases the potential cost of the simulation.
- Similarly, high spatial resolution can be mitigated by compression, but increases the potential cost.
- For states, a lower resolution may help to reach stability in parts of the simulation more quickly, avoiding their computation.
(I like the idea of a regular, low resolution, semantically loaded1 piece of data like Pixel Art; the project reflects that way of thinking.)
Partial vs. Full
In the idea of a full simulation, everything would be simulated at every cycle and it would have the scale and optimizations suited for that.
This project aims for partial simulation, where there is a huge world and only a fraction of it is simulated. To me, it puts more emphasis on exploration and less on having a complex living world2.
Hybrid
The simulation is not purely matrical, other data structures can be simulated on top of it (e.g. a graph for an electric network). Things simulated outside of the matrix can also interact with it (e.g. objects of a physic engine).
However, the matrical aspect is still fundamental.
Simulation
The aimed method for computation is as follow:
- The next cycle state is computed from the last cycle state.
- The unit of computation is the cell. Each cell is computed in function of the cells (or other states) of the last cycle state. Application of the effects are aggregated per cell: the cell applies its incoming effects to itself instead of applying its outgoing effects to other cells.
It is very similar (or the same) to cellular automata.
This avoids issues with the order of effects/computations:
- Relative to the simulation time, every cells is computed simultaneously.
- It allows for parallel computation of cells.
- It may simplify the process of designing the rules of the simulation. E.g. conflicts with the order of effects are resolved per cell.
Framework
DAG / LoD
One key aspect of the framework is to work with levels of details or LoDs.
The goal is to use a directed acyclic graph (DAG) as the main data structure to manipulate a matrix of the simulation. This allows compression and aggregation of the matrix's data at different levels of details and to ideally exploit those properties at every step (storage, memory, generation, simulation/logic, networking and rendering).
Updating the matrix as a DAG might be less efficient than with a chunk oriented design, but this matches the idea of a partial simulation with a huge world and seldom updates.
Some algorithms might benefit from that structure, others might suffer in terms of performance or complexity. Consequently, the framework will probably expose different interfaces to the same data. But, working with a DAG is a core concept and not just an implementation detail.
Abstraction
The framework aims to provide a useful abstraction for building those huge partial matrical simulations.
Examples are:
- A way to quickly implement the rules of the simulation.
- Ability to make snapshots and compute delta, e.g. for networking.
- Ability to embed the framework and define its parts, e.g. how it interacts with the storage.