14 August 2011

Game architecture

I'll begin by showing a very crude diagram of the game's architecture:

Here's a brief explanation of each part of the engine along with some arguments for some technical decisions

1. World Manager

This is the most obvious, there's not much to tell here. It keeps the blocks, the chunks and implements all operations on blocks (like digging and constructions). Pathfinder is implemented here too.

2. Entity Manager & Item Manager

In our game, every piece is either an agent or an item. The difference is in the AI, each agents has its own type of AI while the items are passive.
We have decided to split the data in 2 parts: one managed by the entity/item manager and one managed by each agent's AI (the state) for easier serialization and providing a common set of data for everyone. The manager has instance data while the state keeps 2 sets of data: AI internal states and agent internal state.

For example, lets take a robot:
  • the instance data keeps its identification data, its position in the world and a common access interface.
  • the AI state has 2 levels of FSM data, AI timers and flags
  • the agent state keeps miscellaneous data like "if we're doing a job which requires animation, at what frame we are currently".
All this allows us saving and re-computing exact state with ease (almost; we still have to deserialize the entities graph)

3. Job Manager

Jobs posted by all agents have a lot of data attached, allowing a whole range of job dispatching optimizations; an agent could require the transport of some items from exactly one point to another or from any point to itself or a specific set of items, and so on.

Jobs are internally processed by the agent's AI and may be splitted in multiple operations. Let's take the seemingly simple example of a job: a repair station needs power so it posts a job of type "recharge", passing its coordinates. Then it waits.
A robot with a compatible chip will pick the job and analyze it. To recharge an agent, it needs filled batteries. The steps go a bit like this:
 I did not try to present all the steps involved because it's quite a bit more difficult than that, but that's the general idea. Diagramming takes too much time :)

In the next article, I'll talk more about the robot's AI and agent-to-agent interaction.

No comments:

Post a Comment