(note: this is slide 10 of the nulstein plog)
The traditional approach to tuning code is to look for hot spots and squeeze them. It usually turns out to be the inner loop of some iterative process: loops or recursions. Parallelizing code is the contrary: looking for large iterations and breaking them into chunks, at the outer loop (opposites are exactly the same, but for one thing...)
If you look at how you code for the GPU, you provide shader code for what ultimately are inner loops of bigger processes. You don't loop on vertices, you don't rasterize triangles or loop on pixels, all the outer work remains hidden and this is what makes it possible to have everything run in parallel efficiently. Here, we want to do the same: the engine is responsible for running the outer loops and the game code only deals with each entity's behaviour. This implies that there must be no special-case: the world must be an entity, rooms must be entities, sounds, the UI, everything must be implemented as entities. And we shouldn't be scared about that, the notion of entity in nulstein is really a boundary, an interface between the engine and the game. The definition of an entity comes down to "something that updates and/or draws".
In nulstein, each entity holds two pieces of data. First, its State, which together with all the other entities represents all of the game's state. And second, it's Mind, which is an area totally private to itself. I'm not talking "C++ private" here, where every instance of the same class could have access to the data, I'm saying data that only this instance would have access to. I'm also not implying that there is any language construct to help enforce this rule, it must be thought of as part of a contract: "nobody reads anybody else's mind, ever". This rule makes it safe for an entity to read from and write to its Mind at any point in time because, the entity being the unit of subdivision, we can assume there is only one thread accessing it at a time.
With this, you have the three pillars that serve as foundation for this engine:
- a task scheduler to dispatch work
- entities that constitute the game state and define its behaviour
- dissociation between State that is shared, and Mind that is not