Re: Traversable Game State/Engine Code
I'll be creating a new Player interface (or adapting existing ones—I haven't looked into it yet) that will be implemented to handle input from various sources, one of which is networked players. The game will ask for an action from a player when priority is given. A UI player will simply get actions locally from the UI. A networked player will pass a serialized GameEvent (or occasionally a GameAction in the case of passing priority) back to the game that's requesting input. The networked player will negotiate the connection between clients, exposing none of the details to the UI or game state. As far as all of that is concerned it'll just be an AI player.silly freak wrote:Cool! Yeah, it's great how many things suddenly become possible when the game logic is organized into GameEvents - undo, network play, spectators, game recording, AI...
Speaking of network, how are you serializing GameEvents? Are you including the GameActions, or are you re-running the GameActions on the other side? Do you identify game states as well, or only events, i.e., will two engines be aware whether they are in the same state or not at a given moment?
The received GameEvents will be executed on each Game (since they contain all the necessary actions already).
The engines won't be aware of the state of other engines (except for perhaps some sanity checking of the game state every so often to make sure everyone's playing the same game.
All of this is completely subject to change since I've hardly worked out any of the details since a lot of it depends on how the game will work and I haven't really gotten that far into it yet.
Unfortunately I don't have Photoshop at work, so here's a quick outline put together in GIMP (my apologies for the awfulness):