Author Topic: Pulsar 4X  (Read 33496 times)

0 Members and 1 Guest are viewing this topic.

Offline Antagonist (OP)

  • Pulsar 4x Dev
  • Sub-Lieutenant
  • *
  • A
  • Posts: 124
Re: Pulsar 4X
« Reply #45 on: August 13, 2012, 08:11:03 AM »
Since I'm distracted today, new conversation point... units of measurement.

First of all, metric.  I will veto anyone who suggests anything different.

Then for other stuff...
Stars in Solar Masses, where our Sun is 1.0
Planets in Earth Masses, where Earth is 1.0
Orbits or inter-planetary distances in AU, where earth is 1.0 AU from the Sun
Luminosity in solar luminosity units, where the sun is 1.0 L
Masses not planetary-sized usually displayed in tonnes. Not tons... the 1000kg tonne or metric ton.
Time? Seconds, Minutes, hours, days and years, even on planets where 1 day != 1 earth day, we will gnerally use Earth days. Not entirely sure about months due to its variable nature, but I'm sure we can work out something.

Pattern? Intentional. This is to give players proper perspective compared to the known, aka Earth. Since the default game will anyway play as humans from Earth (I assume this and see no reason not?) this will also be accurate ingame.  For other races... since we are doing the MVVM thing it might be possible to have each player allowed custom units of measurements, an alien race's umbarg might be distance from their planet to their sun, but has little use beyond RP so a later added feature if anything I think.
« Last Edit: August 13, 2012, 08:24:26 AM by Antagonist »
 

Offline clement

  • Pulsar 4x Dev
  • Sub-Lieutenant
  • *
  • c
  • Posts: 137
  • Thanked: 13 times
Re: Pulsar 4X
« Reply #46 on: August 13, 2012, 08:33:05 AM »
For me, as far as roles go, I can fill in on pretty much any position but would probably be of most use in the game engine. I have worked in every part of the stack from database access up to the UI and most of my time right now at work is spent on architecture/design and performance tuning of different tiers.

I agree with Antagonist that getting some design documents together would be a good idea. Even if they are basic and just define the sections that are going to be consistent with Aurora. If there are parts of the Aurora that we want to tweak or change we should definitely hash those out early on so we know what effects they will have on other systems.

@Antagonist I have my code conversion of Accrete broken out in a separate repository, I will try to clean it up and get it posted on Github in the next day or two and then we can talk about it and the functionality you were working on.

If anyone wants to discuss any of this via chat, just message me and I will send you my chat info. I can generally chat at anytime of the day unless I am in a meeting I could not avoid. I live in Atlanta, GA which is Eastern Time Zone (UTC-5).
 

Offline MrBear

  • Pulsar 4x Dev
  • Leading Rate
  • *
  • M
  • Posts: 8
Re: Pulsar 4X
« Reply #47 on: August 13, 2012, 08:36:00 AM »
I'd be tempted to either skip months altogether as a time unit (especially since they require a moon to make sense on a planet) or to call a month 30 earth days as a defacto standard.
 

Offline clement

  • Pulsar 4x Dev
  • Sub-Lieutenant
  • *
  • c
  • Posts: 137
  • Thanked: 13 times
Re: Pulsar 4X
« Reply #48 on: August 13, 2012, 08:37:59 AM »
Since I'm distracted today, new conversation point... units of measurement.

First of all, metric.  I will veto anyone who suggests anything different.

Then for other stuff...
Stars in Solar Masses, where our Sun is 1.0
Planets in Earth Masses, where Earth is 1.0
Orbits or inter-planetary distances in AU, where earth is 1.0 AU from the Sun
Luminosity in solar luminosity units, where the sun is 1.0 L
Masses not planetary-sized usually displayed in tonnes. Not tons... the 1000kg tonne or metric ton.
Time? Seconds, Minutes, hours, days and years, even on planets where 1 day != 1 earth day, we will gnerally use Earth days. Not entirely sure about months due to its variable nature, but I'm sure we can work out something.

Pattern? Intentional. This is to give players proper perspective compared to the known, aka Earth. Since the default game will anyway play as humans from Earth (I assume this and see no reason not?) this will also be accurate ingame.  For other races... since we are doing the MVVM thing it might be possible to have each player allowed custom units of measurements, an alien race's umbarg might be distance from their planet to their sun, but has little use beyond RP so a later added feature if anything I think.


For time I think just go with Seconds, Minutes, Hours, Days, Months, and Years based on Earth. That will match with the players' internal references. That also makes it very easy to track in game how much time has passed. Also, if there is a new settlement on a planet with a 16 hour day or a 20 day month, that will not change the amount of time it takes run the production cycle or any of the other things in game that are based on time.
 

Offline Antagonist (OP)

  • Pulsar 4x Dev
  • Sub-Lieutenant
  • *
  • A
  • Posts: 124
Re: Pulsar 4X
« Reply #49 on: August 13, 2012, 08:46:22 AM »
If you wanna get added to the Skype chat room we have made, message me or sublight your Skype info, or add me to skype directly (l.skyfire).  Well, sublight is primary communications but he's working till... 10:30PM GMT if I worked that out right in my head.  This is tentatively also the time when we can start with 'official' discussion if most ppl can make it then, though you can join the room and chat beforehand too.
 

Offline Nathan_

  • Pulsar 4x Dev
  • Commodore
  • *
  • N
  • Posts: 701
Re: Pulsar 4X
« Reply #50 on: August 13, 2012, 01:20:51 PM »
As I'm finding in my skirmish simulation, changing the time intervals "breaks" a lot of stuff, so that is something to bear in mind if you want to change the time interval model around.
 

Offline SnopyDogy

  • Pulsar 4x Dev
  • Chief Petty Officer
  • *
  • Posts: 41
  • Pulsar4x Dev
    • Pulsar4x
Re: Pulsar 4X
« Reply #51 on: August 13, 2012, 10:38:03 PM »
Quote from: Nathan_ link=topic=5176. msg53185#msg53185 date=1344882051
As I'm finding in my skirmish simulation, changing the time intervals "breaks" a lot of stuff, so that is something to bear in mind if you want to change the time interval model around.

I’m curious, what exactly broke when you changed the time interval?
It’s possible to code things like that to handle a variety of intervals without breaking.
 

Offline Nathan_

  • Pulsar 4x Dev
  • Commodore
  • *
  • N
  • Posts: 701
Re: Pulsar 4X
« Reply #52 on: August 13, 2012, 11:29:27 PM »
Yes, all that is required is reworking the appropriate game mechanics, or just accepting a new situation. capacitor recharge rates work differently with a smaller time resolution, which makes larger guns somewhat quicker to recharge. movement is altered by a shorter time interval as another example. aurora does not resolve distances smaller than 10km I think, and any ship moving faster than 2 km/s can clear that. with a 20th of a second interval all of the sudden any ship not moving atleast 200 km/s won't be able to move without some specialized handling. My solution thus far is to resolve distances down to 1km, and again do said specialized handling.

Another issue is lightspeed. lasers will travel the appropriate distance for a 5 second interval under all situation(except max tech pdc lasers, who get to travel a little faster), but with a smaller time interval how should that be handled? just FTL lasers? laser "packets"?

its not a show stopping issue, but it brings some things up.
 

Offline SnopyDogy

  • Pulsar 4x Dev
  • Chief Petty Officer
  • *
  • Posts: 41
  • Pulsar4x Dev
    • Pulsar4x
Re: Pulsar 4X
« Reply #53 on: August 14, 2012, 01:19:29 AM »
Quote from: Nathan_ link=topic=5176. msg53210#msg53210 date=1344918567
Yes, all that is required is reworking the appropriate game mechanics, or just accepting a new situation.  capacitor recharge rates work differently with a smaller time resolution, which makes larger guns somewhat quicker to recharge.  movement is altered by a shorter time interval as another example. 

In a real time game we get around issues like this using Frame-Independent-Movement.  Basically we use the time taken to render the last frame (Commonly called delta time) to adjust thing like movement, recharge times etc.
As an example for a take a player who moves at 10m/s and a delta time of 0. 01667, we would calculate his movement using:
PlayerSpeed = PlayerSpeedPerSecond * DeltaTime
PlayerSpeed = 10 * 0. 01667;
PlayerSpeed = 0. 1667m/s - We only move 16. 67cm that frame.
This scale up for any size delta time.

Applying this to an Aurora Like game, for a ship that moves 1000km/s and an interval of 5 seconds:
ShipSpeed = ShipSpeedPerSecond * Interval
ShipSpeed = 1000 * 5
ShipSpeed = 5000km/s.
Or for Power Recharge rate of 5 Power per Second, and an interval of 5 Seconds:
PowerRecharged = RechageRate * Interval
PowerRecharged = 5 * 5
PowerRecharged = 25.
The thing is to pick one single time unit as the standard unit (in this case a second) and them measure everything in that, m/s, Km/s, Power Recharge per Second, etc.  This allows us to use a scalar (delta time) to adjust it. 
The one problem with the Interval method is that with larger interval you won’t get compounding affects you get with smaller intervals around acceleration and the like.  This could be solved by either always processing in the smallest possible increment (impractical?) or by using formulas like those used when calculating compound interest in finance when using anything larger than the minimum interval.


Quote from: Nathan_ link=topic=5176. msg53210#msg53210 date=1344918567
aurora does not resolve distances smaller than 10km I think, and any ship moving faster than 2 km/s can clear that.  with a 20th of a second interval all of the sudden any ship not moving atleast 200 km/s won't be able to move without some specialized handling.  My solution thus far is to resolve distances down to 1km, and again do said specialized handling.

As you say these resolution/collision issues need to be resolved using special cases, however if you code the game right this shouldn’t be too had either.  A couple of ideas I’ve used include:
Ray Casting: Extend a ray (line) out in front of the ship in the direction of travel and see if this ray intersects any other objects (or any 10km square containing an object).  If it does, see if the distance to that object is less then how far you will be moving for this interval, if the distance is smaller than process a collision, else just move.  This can all be done using vector maths, a good physics library will have most of this already implemented.
Spatial Partitioning: This can allow us to resolve down to much smaller distances, but only when actually required.  First we divide a system up into a grid of squares, say 100,000km to start, if 2 (or more) objects for which we need to process a collision are in the same grid square (say a ship and a missile) then we divide up the the square into even smaller squares, say 1000km and check again.  We can keep doing this until we get down to a scale where we can say for certain what is going on.  In your case you could use a similar concept to this, resolve down to 10km normally, if things are happening inside a 10km square area then resolve down further, keep going down until things make sense.

Quote from: Nathan_ link=topic=5176. msg53210#msg53210 date=1344918567
Another issue is lightspeed.  lasers will travel the appropriate distance for a 5 second interval under all situation(except max tech pdc lasers, who get to travel a little faster), but with a smaller time interval how should that be handled? just FTL lasers? laser "packets"?

Light is probably the hardest thing to work with because it moves so dam fast! One way to handle it is to treat a beam weapon as a ray (as describe above), if that ray collides with ANY object in a minimum increment then a collision is assumed to occur.  If it could have collided with multiple objects then whichever is closer is the one that gets hit.

It’s all possible it’s just a matter of deciding at what point it feels “real” enough that we can stop processing to smaller resolutions, that’s what play testing is for, and if we can achieve “real” given the limits of the processing power available.
/endrant

Regarding Pulsar4x, are we going to change the way the increment work, maybe go real time + pausing?
Also RE months and Imperial Verses Metric, I say use Metric and Seconds/Minutes/Hours/Days/Years in the simulation and then add options for displaying Months and units in imperial into the UI later.  The important thing is to keep what the engine/simulation uses internally consistent.
 

Offline Antagonist (OP)

  • Pulsar 4x Dev
  • Sub-Lieutenant
  • *
  • A
  • Posts: 124
Re: Pulsar 4X
« Reply #54 on: August 14, 2012, 03:02:09 AM »
Myself and clement had a little chat on Skype about what 'realtime' Aurora implies.  First of all, one thread a system seems a pretty safe bet.  Systems don't really interact with each other all that much so it minimizes race conditions.  Usually between player and AI there should be at least around 4 systems eventually, so enough for multithreading to be useful even if the work per thread isn't exactly balanced, but it helps.

The comparison with XCOM worldscape is reasonably apt.  You either click > which is around 1 hour per real second, >> which is around 1 day per real second, >>> which is around a week per real second, etc. Or you can pause and review your blueprints and design new ships and assign orders. This will work much like 'autoturn' on current Aurora, just with smaller subintervals and consistent real:ingame time. However, in order to do this properly so that the speed is same for fast PCs and for slow ones you are gonna have to work off some delta, such as timesincelastupdate. Basically frame independant approach used for rendering and physics in most modern game. Faster PCs will naturally have smaller deltas and more accurate simulations while slow PCs will have coarser.  Ideally both coarse and fine subintervals should both result in same end, but will have to work on that.

The biggest bottleneck of base Aurora is basically its tendency to read and write from the Access database every update. Just by using an ORM and keeping data structures in memory we gain an incredible performance benefit and should be able to do much more than base Aurora can.

Combat though... combat. 1 day subintervals might be alright for economy, where little is different compared to hourly subintervals, but combat might require 1000s of updates in the span of an ingame hour.  Whether in a visible system or not.

There is always going to be some interval in combat that if it becomes larger then things will mess up... Missiles will miss targets, ships will go the wrong way (towards the unupdated target), damage control and damage might happen differently... The capacitor recharge thing sounds weird and could be a bug. The compound formula mentioned by SnopyDogy might be the solution, though not sure if that's what is actually happening.

Ideally we might have some sort of event driven system for updates on combat out of system... if a ship is coasting into 100mil km range before it can release its missile payload it won't need updates till either it reaches that range or it gets hit.  If it isn't getting targetted then only thing to worry about is range.  Say it needs 10 mins to reach its target we can delay updates for 5mins, then update position and recalculate when next update is (since target may have moved closer).  If it is targetted or something is intercepting it you'd need updates more often.  Or if player is actually watching then we need everything updating smoothly every interval, positions and all, just so player doesn't see jumping ships.  Largely I'm looking for optimizations we can apply to out of system combat between AI opponents, but keep the results of the combat the same.


As said above, Pulsar4X has a natural massive performance advantage over Aurora just because of the ORM, aka keep stuff in memory rather than writing to db every interval. We should take advantage of that. Steve I believe in one of his posts mentioned wanting to go down to 1s minimum interval and I propose to do the same. We're not working off Aurora source code here, which is a disadvantage, but it allows us to redesign some of the basic systems in a better way than they are currently done.  This includes the timing systems.

Making minimum interval 1 second naturally increases the issues with lightspeed weapons. Steve is currently using some packet system for his rail weapons in Newtownian. We can do the same... or we can break physics and have beam weapons instantly hit even if the target is several light seconds away.  I don't think this breaks much to be honest, so long as we work in velocity and acceleration into hit chance. Would simplify a lot, and often firing rate matters more in combat than whether the damage is done now or in 5s.

Biggest thing we need to decide is whether to go Newtownian or to go transNewtownian.  The former is MUCH harder to program, the latter simpler. Perhaps we can go the latter, then switch to former in a later iteration.  Largely I think it is up to those willing to actually code it, aka what do they feel they can accomplish?  Intercepting an object with another object, plotting courses and so using Newtownian physics is HARD.  Moreso when that other object also has its own ideas.
 

Offline SnopyDogy

  • Pulsar 4x Dev
  • Chief Petty Officer
  • *
  • Posts: 41
  • Pulsar4x Dev
    • Pulsar4x
Re: Pulsar 4X
« Reply #55 on: August 14, 2012, 04:42:03 AM »
I was thinking along the lines of the XCOM style system myself.  I like the idea of playing Aurora (especially the battles) in real time or faster.  I think the game would flow better that way.  If you can pause any time you like then this isn’t a huge break from how the game is played now anyway.

I know other games have systems where you can increase the rate time moves in the game world and have it drop back (or even pause) automatically when required.  I understand most of them are artificially increasing Delta time.  For example:
Speed *deltatime * TimeIncrement
100m/s * 0. 1 seconds * 1 (real-time) = 10m/s this frame
100m/s * 0. 1 seconds * 10 (10x real-time) = 100m/s this frame.
At faster speeds there will be a lot of “looking ahead” in an attempt to predict what is going to happen and when to move to smaller increment (slow down).  This is where thing like Ray casting come in useful (see above post).

It might be a good idea to use a 3rd part physics library to take the pain out of setting up the Physics for combat and the like.  A quick Google search for c# physics engines showed up:
hxxp: code. google. com/p/physics2d/
hxxp: jitter-physics. com/wordpress/
hxxp: henge3d. codeplex. com/
hxxp: farseerphysics. codeplex. com/
hxxp: code. google. com/p/bulletsharp/
The Last one looks like a good bet, it’s a c# wrapper for the Bullet Physics library (one of the best).

Regarding light speed weapons, I have heard that many AAA title games start out with a physics model MUCH closer to the real world than what ends up shipping, the pull out or simplify anything that gets in the road of gameplay.  I don’t have any problem with doing the same for light speed weapons, as long as it make sense to the player and is fun.
A similar thing can be done for AI battles; if the player can’t see them then do we really need to simulate it exactly? We could cheat and not process exactly what happens, e. g.  Missile fired, wait until enough time has passed, then just assume it hits and process detonation, no movement, no collision checks, just an estimate of flight time and POW it there (think Quick Battle in Total War where the computer works out the result of a battle in a few seconds).  We can do the same for path finding, if the player can’t ever see the ship do we need to track exactly where it’s going, we could just get an estimate of time and then have it appear at its destination after this amount of time has passed.

At collage a few months back we had a talk from a senior (20+ Years’ experience) producer from Sony Portable Games division.  He said the best advice he could give for developing a game is to get it playable ASAP.  Once you can play it you can get idea of what works and what doesn’t, then you can iterate and improve things.  The faster you get to something that can be played, no matter how bad, the better the end product.
I think this is good advice for us.  I don’t mean that we should rush, but the sooner we have something that we can play the sooner we can find out what does and doesn’t work.  I think it would also help keep everyone engaged with the project over the long term, especially those who can’t contribute to the code.
 

Offline Antagonist (OP)

  • Pulsar 4x Dev
  • Sub-Lieutenant
  • *
  • A
  • Posts: 124
Re: Pulsar 4X
« Reply #56 on: August 14, 2012, 07:26:32 AM »
Threw up a basic solution and project structure on github.

Created in VS 2010 Pro.
2 projects, Pulsar4X.WinForms and Pulsar4X.Lib
Default namespace for both is just Pulsar4X to keep down needed using statements

Lib seems to load fine in mono-dev, WinForms one sublight had some issues with. Anyone who knows mono compatibility who can take a look at it?

Next step might be adding log4Net as an external reference and try get that working crossplatform, as well as start with the utility and constants classes, and working on the stargen, something I discussed with clement.

Can throw up some basic entities like Planet and Star as well, but these may change with requirements of ORM, which we still havn't picked.  Right now between LINQtoSQL and Dapper.

Simulation devwork is likely dependant on basic entities, game design and all, but I suppose we can lay down some basic multithreaded support solong.

UI I'm not touching, but can do with some love.

Err... what else... plenty that can be done, but a lot we need the design and other decisions for first.

If you have opinions, hop on Skype with us.
« Last Edit: August 14, 2012, 07:30:42 AM by Antagonist »
 

Offline Antagonist (OP)

  • Pulsar 4x Dev
  • Sub-Lieutenant
  • *
  • A
  • Posts: 124
Re: Pulsar 4X
« Reply #57 on: August 14, 2012, 08:14:52 AM »
Okay, so I see log4net has a gazillion dlls and you need to pick the correct one (mono, .net 4.0, 3.5, etc) to link to. Between this and the whole mono and alternative IDEs thing I am now rethinking the approach to solution and project files.

I would like to hear thoughts on using premake. For those not in the know, this is basically something that generates .sln and .csproj files. We can have it do stuff like 'If linux, use lib x, if windows, use y' or 'mono reference these libraries, .net these', all without the mess of a mono project and .net project and attempting to keep it all synced.
 

Offline Antagonist (OP)

  • Pulsar 4x Dev
  • Sub-Lieutenant
  • *
  • A
  • Posts: 124
Re: Pulsar 4X
« Reply #58 on: August 14, 2012, 10:29:57 AM »
And done.

premake now generated .sln and .csproj files that compile and work okay on my PC.  They may need some extra references added as we add code however.

Just grab source from repo and run premake4.exe in the base directory to set it up.  Try not to sync the generated solution and project files back to the repo tho till we have confirmed this works.
 

Offline Nathan_

  • Pulsar 4x Dev
  • Commodore
  • *
  • N
  • Posts: 701
Re: Pulsar 4X
« Reply #59 on: August 14, 2012, 01:49:32 PM »
"As you say these resolution/collision issues" - Aurora doesn't really do collision detection, and pulsar probably shouldn't worry about it either, other than for hyperlimits and sensors, I experimented with a quad tree, but with just 1 object its a waste, and sensors are basically going to be dynamic(and wierd due to having multiple detection radii) so no reason to do anything there. We'll see how that plays out. The biggest gain item that I think I can do is to have lookup tables instead of calculating various things. thus far sensors and FCs have lookup tables in my code for detection/accuracy at distance functions.

XCOM is little different from aurora as is so that won't be an issue. at first when I heard XCOM I thought you meant the turn based battle, not the geoscape.

"The biggest bottleneck of base Aurora is basically its tendency to read and write from the Access database every update. Just by using an ORM and keeping data structures in memory we gain an incredible performance benefit and should be able to do much more than base Aurora can." - Yea, my skirmish sim is basically going to not have a database. Its being done in c just to be contrary but I can port over relevant code when needed, such as the component stuff I've worked out. The other reason for what I'm doing is to derive the appropriate formulas for how things work, and I have most it it done right now, currently grappling with armor.