DangerousDave wrote:Hey,
I've been trying to find some details on how the game works a bit more 'under the hood', but really can't find much.
Specifically (for now):
- How the economy currently works.
This is written in python and is part of the dynamic universe system (I believe all of the dynamic-ness is done in "trading.py" but for the most part the economy is a few small numbers added onto some defaults for each base type--really isn't very interesting the way it is done right now.
- The level of persistency in the universe - are individual ships simulated at all out-of-system?
The use of level-of-detail - how are battles between ships represented at large distances or out-of-system? How many LOD levels are there? (I'm certain there's a more technically accurate word than LOD, but fail to remember...?).
NPC (flight) AI - purely reactive? path following? how intelligent is high level decision making?
As safemode said, there are multiple levels of simulation.
Highest level: Dynamic Universe. This operates solely based on knowledge in the savegame about all flightgroups in the universe, and information in milky_way.xml about all systems in the universe and an overview of what planets exist in each one.
System level: Ships exist in space and each one runs an AI script, as well as has a target. The AI acts on a reactive level (though not as well as it can, and ships will often have head-on collisions). However, the ships's target and flightgroup directive act as a goal (e.g. I'm going to fly to this base and dock)
The current system as well as the last (1-3) systems you have been in are simulated at any given time.
In addition, there is a priority given to each ship, that is the number of frames between each simulation. For example, The player is 1, the player's target is very low, and planets are 64 or 128 or something high.
I will check out the source code as soon as possible, but no doubt it's gonna take a while to sift through! So, if anyone can give an overview, or even better point me to a wiki page or forum thread with this sort of stuff, I would be most grateful...
I can't give you a general overview page if that's what you are asking for... I'm sure there is some information around but you have to hunt for it. It might be easier if you have some specific projects in mind that you want to start out with.
File organization is somewhat straightforward. First, most files have a something_generic.cpp, something.cpp and something_server.cpp
The _generic is usually a base class or common functions. The subclass will be without _generic and will have client-specific code. _server will usually have stubs for graphics functions.
I don't know if this is what you are looking for, but here goes...
Python code is in data/modules and data/bases.
In C++, there is one instance of Universe (universe_generic.h)
each Universe has multiple Cockpits, though in recent times there is no split screen so clients only have one Cockpit (gfx/cockpit_generic.h).
Each Universe also has multiple running StarSystems (star_system_generic.h).
Each StarSystem has many Units (cmd/unit_generic.h) which is subclassed by Planet, Missile, Nebula, and others. However, Unit is the class that is used for fighter ships.
Each Unit has an AI class (Order, CommunicatingAI, and other subclasses), which is in its "aistate".
Also, most functions in unit_generic are exported to Python, and everything inside of faction_util.h, universe_util.h and cmd/unit_util.h are exported to Python, and so you can also use the same functions in C++ code.
I'd like to help out the project in any small way I can. I am a fair C++ coder with experience of some techniques involved in this project (some OpenGL/DirectX, multi-agent AI, rigid body and fluid dynamics simulations). But, as I'm sure the developers must have heard a million times, I really can't spare the time to commit - a mistake I've made before, ultimately letting people down.
But if I can contribute some more technical ideas, documentation, testing, etc, that can be done on the fly without too much commitment, I will do.
Cheers.
I don't want to let you down, maybe it has something to do with the organization of the project, but in general it is not easy to do something 'on the fly'... but feel free to post on the forum and we can help you along.
Also, the Wiki is in constant need of updating... a lot of stuff in there is 0.4.3-era out of date, or altogether nonexistent.