Fractal Softworks Forum

Starsector => General Discussion => Topic started by: PCCL on October 19, 2013, 02:31:43 PM

Title: OOS simulation
Post by: PCCL on October 19, 2013, 02:31:43 PM
I'm wondering, as is right now, how is OOS (Out Of System) simulations handled? Are they being ran at full detail? What kind of resources are they taking up? 2 systems seem ok so far, and ironclad's 24-ish (?) works fine at least on my comp (albeit taxing on memory), but alex was talking about 1000 or at least 200-300 systems, is full detail simulation still gonna work at that point?

idk, it just came to me while playing X3 earlier today... not quite sure how things are gonna work or if plans are in place for things like this
Title: Re: OOS simulation
Post by: Alex on October 19, 2013, 02:56:23 PM
It's a good question; I don't have a definitive answer for exactly how things will work when there are a few hundred systems in play. Will see just how big a strain it is to run the way it's running now, and do whatever seems appropriate :)

Right now what it does is run every location the player's not in at 10x the step size. For example, if the player's location is running at 60fps, everything else is running at 6 fps (staggered, and with 10x the duration advanced each frame). So it's lower fidelity but not to the point where that should make a noticeable difference.
Title: Re: OOS simulation
Post by: Gothars on October 19, 2013, 03:33:05 PM
That leads me to the question: What will happen with hyperspace once there a hundreds of systems it has to connect? As it is now it would be awfully overcrowded with inter-system traffic, would it not? Will there be multiple hyperspace instances? Or will it simply only render things up to a certain distance from the player with full framerate?
Title: Re: OOS simulation
Post by: Alex on October 19, 2013, 03:39:44 PM
Or will it simply only render things up to a certain distance from the player with full framerate?

As far as rendering, it already only renders things that are on-screen.

The main potential problem there is if there's so much stuff in hyperspace that advancing it a normal step size/frame rate wouldn't work. That, in turn, depends on how long, on average, fleets spend in hyperspace vs in-system. But, you know, we'll see if it's an actual issue. Performance-related things can be pretty difficult to predict, oftentimes what you initially expect to cost a lot is actually trivial for one reason or another.
Title: Re: OOS simulation
Post by: miljan on October 19, 2013, 03:51:36 PM
Hmm, will we be able to chose how many system are there, or the size of the "map" so we can have some control to chose small maps for people that have bad comps?
Hope my crappy comp will be able to run it
Title: Re: OOS simulation
Post by: VerifiedN on October 19, 2013, 05:42:25 PM
The current method will undoubtedly not scale well. Though you can simulate 'inactive' sectors fairly easily by boiling activity down to sparingly processing a numerical fleet type/faction/power/speed/depletion/target entity/position list (and then just randomizing details such as exact fleet status if the sector becomes 'active'). You lose detail there, but nothing noticeable considering it'd only be done for distant sectors the player can't reach quickly (nearby sectors could continue using the current method).

The issue of the hyperspace map becoming overcrowded (and possibly laggy due to that) could be resolved by introducing a distance beyond which other fleets are non-detectable and switch to the list method, and back should their coordinates update to coincide with the player's detection range (at which point they're placed at the edge of that range as close as possible to their listed position).

No idea how difficult that could be to put together, but it's food for thought.
Title: Re: OOS simulation
Post by: PCCL on October 19, 2013, 05:51:01 PM
I don't know, it might scale well enough. as it stands, in OOS 6fps is a lot, if need be, maybe even 10 times that step size (0.6fps/1.67spf) actually sounds reasonable, therefore from a purely simulation standpoint 300 systems will have about the load of 30 as is (assuming simulation doesn't get more complex, but then optimizations are probably also being done along the way). It actually doesn't seem that bad...
Title: Re: OOS simulation
Post by: VerifiedN on October 19, 2013, 11:08:11 PM
I don't know, it might scale well enough.

The current system does help CPU load a great deal, but the amount of memory the game needs (and the amount of processing overhead on that data - increasing simulation step size/rate will do nothing to reduce encounters) will continue growing as more systems are added; something will definitely need to be done about that eventually, especially if it gets anywhere near the 32-bit memory limit.
Title: Re: OOS simulation
Post by: Thaago on October 19, 2013, 11:30:57 PM
It seems strange to me that lots of systems should add much to the memory... how big are fleets in memory anyways? All my internal rules of thumb from this sort of thing are from low level languages where the object memory cost overhead is low to non-existent, so I don't even know how to estimate.
Title: Re: OOS simulation
Post by: PCCL on October 20, 2013, 01:25:13 AM
judging by how much of the save file they take up, fleets are a huge part of the memories (assuming that translates to the RAM use in game at all)

So it's really not much about more systems, but the fact that fleets populate these systems
Title: Re: OOS simulation
Post by: Zaphide on October 20, 2013, 01:34:16 AM
judging by how much of the save file they take up, fleets are a huge part of the memories (assuming that translates to the RAM use in game at all)

So it's really not much about more systems, but the fact that fleets populate these systems

Yeah this is my experience with Exerelin. Sheer number of fleets (and stuff that is in those fleets such as CR for every member, buffs, repair trackers etc) seem to constitute a massive amount of the save file. I suspect this translates pretty much directly into RAM usage.
Title: Re: OOS simulation
Post by: Alex on October 20, 2013, 01:55:52 PM
Yeah, I think it's safe to say that the amount of detail actually saved for non-player fleets is excessive. It currently saves the state of every single armor plate, for crying out loud - just for damaged ships, but still. (Why? It works fine for vanilla; and optimizing without knowing exactly how you'll be using something is not a good way to go about it.)

The good news is there'll be plenty of relatively easy things to change to improve the situation once vanilla gets more systems.
Title: Re: OOS simulation
Post by: LarvaLounge on October 21, 2013, 05:19:02 AM
This is an issue I've thought about as well.

I'm no programmer, but...
reading "Explore hundreds of star systems" on the front page...
and playing a 24 system Exerelin campaign...

Yeah, something will have to change.
Title: Re: OOS simulation
Post by: miljan on October 21, 2013, 07:49:28 AM
I dont understand why is Out Of System done almost same as the in system?
Why not make it something simple like in SPAZ or something where you just get a list of planets where you can travel.
Title: Re: OOS simulation
Post by: Alex on October 21, 2013, 08:08:29 AM
Because there are *two* systems right now in vanilla, and premature optimization is the root of all evil.

Yeah, something will have to change.

Duh? :) What I mean is, if this is a concern, it probably needn't be.
Title: Re: OOS simulation
Post by: DatonKallandor on October 21, 2013, 08:51:22 AM
I think games like I-War that have theoretically lots of ships and lots of real estate to cover "cheat" by only tracking precise locations and status when stuff is actually within the players sensor range - and continue to track within a certain amount of leaving sensor range should the player happen to follow a specific fleet.

That seems like something you can adapt quite easily to Starsector - after all there's no point in tracking the exact hull status of an enemy fleet if you've been out of sensor range contact for 2 days. You can assume they've repaired and reorganized, since "sensor range" in this case means they've been in a different system than you for a long period of time.
Title: Re: OOS simulation
Post by: Giangiotto on October 21, 2013, 02:51:00 PM
How I would do it:

-Sector player is in is fully simulated similar to now
-Other sectors keep one generic 'strength' record for type of fleet (eg. Defense, supply, scout), this number changes to simulate combat based on the 'strength' on the enemy fleet types
-When the player moves into one such sector the game generates fleets based on the numbers
-A sector the player has been to but has left keeps some degree of information (eg. Capital ships) for some time before becoming a simulated sector again after X time

I realize my suggestion is rather drastic but I fear for the RAM usage of this game.
Title: Re: OOS simulation
Post by: Zaphide on October 21, 2013, 03:12:12 PM
I really don't think it has to be that drastic though. Easiest just to have full fleet details for fleets in the players system, and then all other systems have a 'fleet token' that just stores the hull variants in the fleet and the commander stats. AI fleets will have pre-defined variants (no customs) so you don't need to really store much.

Then when player moves into a different system, all those fleet tokens just get converted into real fleets, and the previous systems fleets get converted into fleet tokens.

And there is no reason the frequency of updates in systems the player isn't in can't be lowered to like 1/60th rather than 1/10th (or even once per StarSector day). Anyway, it's all fairly non-trivial I imagine so not something you want to embark on without a real need (and currently there is no real need). If you start optimizing too early it usually makes refactoring/changes excruciatingly difficult later.

re. SPAZ - although I thought SPAZ was a great game, it felt a little too much like a sequence of arenas in my mind. There was too much 'disconnect' between leaving a system and coming back.

re. Exerelin - I wouldn't really view Exerelin performance as indicative of StarSector performance, as it is an unoptimized mod on top of an unoptimized StarSector :)
Title: Re: OOS simulation
Post by: frag971 on October 22, 2013, 06:31:38 AM
What about asyncronous simulation? You don't have to simulate everything in real time, maybe delay simulations while in space and "catch up" when a player is in station/battle?

Also, completely unrelated: I wish t he distance between system was larger, to make fuel matter more. if i want a long travel i better damn bring a hauler.
Title: Re: OOS simulation
Post by: Magician on October 22, 2013, 09:31:48 AM
It will be a good idea in case few changes are made:
1) Traveling itself is a difficult choice which can lead to uncertain outcomes, and requires chains of smaller choices which affect how successfull your traveling is. For now its "bring fuel and click on map - wait" and player almost unaffected by the fact that he is in another part of the starsector. If you will take for example such game as EvE online, you can literaly wander into wrong neighbourhood and lose everything you have, just because you didn't know some corps were planning something near destination of your travel.
2) Traveling itself should be divided into smaller bits, where you have to make different choices and this will affect your traveling/life. Space has to be more random, more uncertain, more unpredictable.
In case such or similiar changes are done to game, increase in fuel consumption will be only a reasonable tweaking to ensure excitement and challange of traveling in space.

Probably something like this will be implemented anyway in future releases if other mechanics are implemented.