Sign in to follow this  
Numsgil

Designing the Architecture

Recommended Posts

I'm working on a sort of proof-of-concept/prototype for a game somewhat similar to SimEarth. I need an architecture that keeps details of the 3D engine, sound, artwork, etc. (henceforth called the "engine") entirely seperate from the simulation's algorithmic details. As I see it, there are three aspects to every object in the world: a) representation details (mesh, textures, etc. probably a mesh, texture, etc. are shared between multiple objects) b) simulation details (health, movement speed, location, etc.) c) Simulation algorithms that effect the simulation details (things like KillAnimal() or ErodeLandscape()) Hope I've been clear so far. I've come up with the following three design possibilities, I'd like some comments on practicality and feasibility. 1. The "engine" polls the simulation for information on the simulation details it needs (position, etc.). The simulation combines the data (simulation details) and simulation algorithms in a more Object Oriented manner. The downside is that the engine has to somehow know how to connect representation details to simulation objects. I'm not sure how this would be done in a sane manner. For simplicity I'll call this a "Polling" methodology. 2. The "engine" and the simulation both interact with a passive repository of data. The data in this case is the objects. Sort of a data driven design. "Objects" would in reality be a sort of cache of pointers to the various details that make up the object. I'm not very comfortable with this solution, it seems it would get unweildly very fast and reduce the OO nature of the program. This is the "data driven" design. 3. The "engine" and the "simulation" both contain their own respective data. The engine and simulation communicate with each other through classes which act as bridges, taking and converting signals so the implementation details of the engine doesn't effect the simulation and vice versa. I'm favoring this approach, but I still don't know how to connect the representation details with the simulation details. Probably have the bridge classes work out the details. I'd appreciate any ideas people have.

Share this post


Link to post
Share on other sites
Two quick questions....

First off, how important is accuracy of your sim model? Can the sim afford to lag a few frames behind the game?

Second, how much data is shared between the two pieces. For example, on physics simulations, you need to keep in a relative lockstep between the game engine and the simulation engine.


Finally, idea 1 is a no no. A simulation component can afford to lag behind, the end user doesnt see it. However, making your rendering dependant to the fidelity of the simulation component, means if one breaks down, they both do.

As to suggestions 2 and 3, I am not sure there is that much of a difference. Once is merely a code based solution, while the other is data driven. Either way, you need some form of proxy between the two subsystems. My money says the data driven solution works more efficently in the end though.

Share this post


Link to post
Share on other sites
Quote:
Original post by Serapth
Two quick questions....

First off, how important is accuracy of your sim model? Can the sim afford to lag a few frames behind the game?


Yes, the simulation is going to be somewhat threaded. Basically the simulation's parts are going to update at different speeds. The calculations like erosion could take a while, so it might only update every few seconds. Animals, on the otherhand, need to update every frame or two.

Quote:

Second, how much data is shared between the two pieces. For example, on physics simulations, you need to keep in a relative lockstep between the game engine and the simulation engine.


Depends how you mean shared. The "engine" feeds events to the simulation from the user (User causes a volcano, for instance). The simulation feeds to the engine position and size data primarily, although most of the simulation data might at some point be needed by the engine for graphs and things. For any average frame, there's probably only a few floats per object being shared (position data, size, etc.) from the simulation to the engine.

Share this post


Link to post
Share on other sites
Hey.

Using your terminology, I suggest the engine (and the representation details) doesn't know anything about neither the simulation-details nor the simulation-algorithms.

Use your "algorithms" to modify your simulation-details... Then modify the representation details with those sim-data.

I hope I'm not misunderstanding your question or task at hand :)

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
I think you need four layers for this project, all running at different rates

1)Logic lowest level of priority changes to landscape, creature seeding
buildings, etc.

2)Animation fixed frame rate animate all objects

3)Display high priority render everything

4)User interaction event based


I know getting a fixed frame rate would be tricky on pc's, so you would have to base all the animations on the real frame rate, i.e. use accurate timers to control the animation.

I think the best way to do this is with a data based approach, though I can see problems with the display engine trying to display objects that are being modified.

Honestly, if you can get your code fast enough the BEST approach would be

handle user interaction
do the logic
do the animation
do the rendering
loop

Back in the days when we measured time in raster lines this was really the only approach we could use. Makes for some very late nights optomising tiny parts of the game :>

All my graphics routines on the Atari ST ended up as self modding code.

Now I'm just showing my age......

Stainless

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this