#Trying to make conway's game of life (3D) (Struggles with entities exchanging information)

1 messages · Page 1 of 1 (latest)

dense vine
#

I'm still stuck on square one.

I'm not sure how to proceed with structuring this.
My current thought is to create a grid that is an entity/entity-archetype, which holds say 64^3 render mesh components, or blobassets (alive or dead). It also holds a regular matrix to track the state of the grid. Then I'll just change the approriate render mesh based on dead/alive.

But, if I want to have more grids, they must communicate with each other, and exchange information (fill in if there's alive neighbor cell)... How do you do that?
I want to eventually expand this one into fluid/pressure simulation, so I want to be able to do the neighbor check by matrix convolution.

marble tendon
#

Entities don't exchange information because they don't act. Entities are just pieces of data stay there in the memory. System is the one gives meaning to the entities. System dictates how entity data is transformed and represented. Think of system as a domino artist and each entity as a domino piece, or a puppeteer and his puppet.

#

Basically, your system determines which entity is neighboured to which entity, which entity is considered alive or dead. Systems read, transform and write back into the entity data storage (chunk) to give a sense that entities are "alive".

mild cave
#

Conway's is unfortunately not a game that's super good to use with entities, since it's always going to be primarily optimal to have them stored as a grid of on and off positions.

heavy totem
# dense vine I'm still stuck on square one. I'm not sure how to proceed with structuring thi...

Just an idea but you could have your own component that represents a position inside YourChunk and your own YourChunk component that defines a position of a whole chunk (sort of like voxel world chunking system). You could have a dynamic buffer of visible chunks ( grids) that you update when your camera moves. In an ISystem you could query this DynamicBuffer and if it holds 8x8 Entities and you are trying to access the neighbour outside the grid you would just access the YourChunk that is in the direction of the entity ? I have never done this in ECS so it might be a stupid idea 😅

mild cave
dense vine
dense vine
dense vine
marble tendon
#

You're still thinking in OOP which certainly won't help you in ECS. They are totally different.

dense vine
marble tendon
#

To look up a cell for its alive/dead state, you can build a hashmap before running the propagation logic. For this approach, yes, you have to iterate over all entities. But by using a job you can split it up into multiple parts running parallely.

#

Another approach is using component lookup. But it could lead to random access which can destroy cache utility if the neighbour entity is from another chunk.

marble tendon
dense vine
#

I think what I wanted was "IJobEntityBatch"

#

instead of being forced to do foreach every time (Or not, doesn't seem to be much different at all, still limited to yes/no if component exist, rather than value)

marble tendon
marble tendon