Considerations about a simulation game

simulation

The kind of simulation game that I have in mind is the kind where you have things to build in various locations and workers/transporters that connect such locations.

Something more like the Settlers series.

Let's assume I don't want any graphics at the moment, that I think I can manage.

So my doubts are the following:

  1. Should every entity be a class and each one have a thread?
  2. Should entities be grouped in lists inside classes and each one have a thread?

If one takes implementation 1, it's going to be very hard to run on low spec machines and does not scale well for large numbers.

If one takes implementation 2, it's going to be better in terms of resources but then…

How should I group the entities?

  1. Have a class for houses in general and have an Interface List to manage that?
  2. Have a class for specific groups of houses and have an Object List to manage that?

and what about threads?

  1. Should I have the simplistic main game loop?
  2. Should I have a thread for each class group?
  3. How do workers/transporters fit in the picture?

Best Answer

The normal approach does not use threading at all, but rather implements entities as state-machines. Then your mainloop looks like this:

 while( 1 )
{
    foreach( entity in entlist )
    {
        entity->update();
    }

    render();
}
Related Topic