Is there the concept of a safe read time for data consistency?

Is there the concept of a safe read time for data consistency?

Suppose you’re careful to place the systems in order in manager.ex so that at the end of any tick the data about the world is consistent. (i.e. no one is still moving despite being out of fuel or targeting a dead enemy.) Reading data while the systems are running might get data that doesn’t make sense. E.g. The monster I attacked previously has been marked dead but my targeting system hasn’t run yet and picked the next monster, so I attack the dead monster again.

Is the idea that the system will be close enough to correct for reading due to the high ticks per second?

  • or -
    Is it an indication I’ve modelled my data and systems improperly?

E.g. The monster I attacked previously has been marked dead but my targeting system hasn’t run yet and picked the next monster, so I attack the dead monster again.

Why would you attack again? It should run through the list of all your other systems (including the targeting system) before cycling back around to the attack system.

Is it an indication I’ve modelled my data and systems improperly?

I’m thinking this may be the case, but would have to see more of the code to say for sure.

Thank you for replying. I’ll infer that the safe read concept doesn’t exist - you would have said yes if it did.

I agree that looping over a well ordered set of systems will provide good results for all of the processing internal to the ECS.

In my original post I was thinking about external systems using data from ECS. I was envisioning the human or some other ML bot brain making decisions based on a set of data from ECS. Especially if those systems aren’t refreshed as fast as the ECS can change data.

As I don’t have code to submit that illustrates the problem we can leave it as an academic question.

Do you mean that you want to ensure data reads in-between ticks, once the previous tick has finished all work but before the next tick has started? That is how the persistence system works. Perhaps the “ML bot brain” reads from the persistent store instead of calling Component.get ?

Yes! That’s the idea.