Is separate past/present game state always necessary?

Started by
0 comments, last by Ravyne 11 years, 8 months ago
By game state, I just mean data, such as object positions and attributes, active players, etc.

I know for FPS games, having separate past/present (or, more likely, current/next) states is useful, because things happen so fast and you want to allow multiple things to happen at once rather than sequentially. For example, two players shoot each other at the exact same time. If you have only one game state, player 2's shot could get ignored, since it gets processed after player 1's shot, by which time player 2 is marked as dead. If you have separate current/next game states, the shots fired are read from the "current" state but the players are marked as dead in the "next" state, which doesn't go into effect until the next cycle.

However, for other games such as RTS games, things happen at a much slower pace, and I can think of situations where separate game states might be weird. For example, two units are gathering a resource. If you have separate states, and both units happen to arrive at the resource at the same time, they will both get it, since there is no immediate knowledge if the resource being removed. Whereas with a single game state, one of the units would grab it and the other would find it missing and need to look for another.

I always assumed separate game states would be necessary, no matter what, to maintain the integrity of the simulation, but now I'm not so sure if that is true. Thoughts?
Advertisement
It's really a design issue more than anything -- double-buffering the state is one way of dealing with it, a careful ordering of update events is another, keeping things decoupled is yet another.

For example, most projectiles in most FPS games today aren't instantaneous (meaning, they travel and are affected by drop, and aren't just a simple ray-test) so they should be entities in their own right, and continue to exist even if the player that fired them has died. That's an example of de-coupling.

throw table_exception("(? ???)? ? ???");

This topic is closed to new replies.

Advertisement