Terra Invicta Dev Diary #17: Rocket Science

For updates and discussion of Terra Invicta, a grand-strategy alien invasion simulator
Post Reply
User avatar
johnnylump
Site Admin
Posts: 1133
Joined: Wed Nov 11, 2015 4:12 am

Terra Invicta Dev Diary #17: Rocket Science

Post by johnnylump »

ships1.png
ships1.png (946.03 KiB) Viewed 11930 times
One of the things we’ve promised with Terra Invicta is an accurate-as-we-can-make-it model of space travel in our Solar System.

This dev diary will get into the meat of the overall design, but I want to say at the outset that what players will face is a straightforward set of questions. All the nasty math will take place under the hood, and you can focus on strategic decisionmaking, and let the game take care of the rest. The questions are:

1) Where do you want to go?
2) How fast do you want to get there?
3) How much of your Delta-V are you willing to burn?

Questions 2) and 3) contain, as you might expect, a tradeoff.

Your fleet’s ability to accelerate, the distance between your origin and destination, and the force of gravity at the origin, destination, and points in between are all primary determinants of how long a trip can take. A space ship’s acceleration is a product of the drive it is using and its mass.
Delta-V measures how much a space ship can change its velocity. In space, with almost no organic way to slow down, a ship will keep going unless you apply some acceleration in the opposite of its direction of travel. It’s also a normalized value that can represent all kinds of propulsion systems and propellant – a way of comparing today’s conventional rockets to nuclear drives and far-off notional stuff based on fusion or antimatter.

So: You want to send your brand-new corvette from your shipyard in High Lunar Orbit to your propellant depot orbiting 433 Eros. Here’s what it presents you:
trajectory1.png
trajectory1.png (131.12 KiB) Viewed 11930 times

The slider lets you trade Delta-V expenditure for travel time.

To figure all that out, the game has to calculate the ship’s interaction with gravity around the moon, then Earth (when it leaves lunar’s sphere of influence for Earth’s), then around the Sun, and finally around Eros. It’s also calculating hitting a moving target from a moving origin – and determining whether it would be wiser to wait a bit at the origin until the destination is in a more favorable location.

The relationship between thrust, thrust duration, and gravity determine the primary “shape” of a trajectory. Terra Invicta models three types of trajectory, each governed by their own math:

• Impulse conics: These are for high-thrust, low-efficiency drives, and are probably most familiar to players of Kerbal Space Program and fans of modern space travel. Chemical and many fission drives will use these.

Fleets launch by very quickly burning a great deal of their Delta-V to put themselves on a conic-section-shaped trajectory – basically building an elliptical or hyperbolic orbit they can coast on until they reach their destination, at which point they burn again to match velocities with their destination and enter a stable orbit there.

Fleets with more Delta-V can get to their destination faster by building tighter conics that spend less time coasting, all the way up to highly eccentric hyperbolas that look almost like a straight line. We use a beautiful piece of math called a “Lambert Solver” to help calculate these.

While the ever-changing relative positions of the planets impact the duration and propellant consumption of all trajectories, impulse conics are particularly sensitive to launch windows – times when the positions are favorable or unfavorable for fast or efficient movement. But we’ve got that handled, too -- the game will test and offer you trajectories in which you loiter at your origin until a good launch window comes up, if those are faster or more efficient with propellant than immediate launches.

• Microthrust spirals: These are for low-thrust and typically high-efficiency drives that have lots of Delta-V but very little muscle to use it. Electrical drives will use these, and, surprisingly, sometimes more powerful drives – even fusion -- will need to operate on these trajectories to escape from powerful gravity wells.

Essentially, if a thruster can’t overcome the local acceleration due to gravity (whether from a moon, asteroid, planet or the Sun), it has to engage in a long, slow spiral from its origin, burning constantly to build toward having enough velocity to escape the local gravity.

We can’t promise every ship you build with electrical and other low-thrust drives will be militarily useful, but we wanted to model the entire range of notional propulsion systems and let you sort out what works best for you.

• Torches: For powerful, advanced drives with scads of Delta-V that can maintain near-constant high thrust throughout the Solar System and not care much about measly gravity. Ships move on a straight line toward their destination, accelerating most or all of the way (with maybe some coasting in the middle to save juice), and then flip and decelerate tail-first to match velocities with wherever they are trying to go.
This is the type of drive behavior portrayed in the Expanse television series.

In some cases, the same ship may use different propulsion models based on specific conditions. A drive may behave like a torch in a low-gravity environment, such as hopping between asteroids in the Belt, but will operate in a microthrust regime near Earth or Jupiter. Or, if you are far from a favorable launch window, the game will check to see if the ship has the Delta-V to perform a torch trajectory instead. And drives may operate under different models in different parts of the same trajectory as conditions change.

As you can imagine, drive techs play a major role in your expansion in the Solar System and flexibility to meet alien and human threats. And a support network of propellant depots at various locations make sure your fleets can keep moving and be ready for combat.

An aside: Our dev in charge of implementing all this mathematical wizardry is TauCeti Deichmann, a talented game designer in his own right. Check out his trading game Sidereal Confluence on the Geek!

We’re hoping to have Tau write up a future dev diary where he can dig in on the details of his efforts.
ABQGhostDog
Posts: 1
Joined: Tue Feb 01, 2022 11:08 pm

Re: Terra Invicta Dev Diary #17: Rocket Science

Post by ABQGhostDog »

Super excited to see how this changes strategic maneuvering compared to the more gamey things you see in other games :D Quick Question, will players be able to force a ship to leave port if needed? I'm imaging a situation where you want ships to leave the station to avoid combat even if waiting results in a better launch window
User avatar
johnnylump
Site Admin
Posts: 1133
Joined: Wed Nov 11, 2015 4:12 am

Re: Terra Invicta Dev Diary #17: Rocket Science

Post by johnnylump »

Yep.
weregamer
Posts: 1
Joined: Thu Feb 03, 2022 7:21 pm

Re: Terra Invicta Dev Diary #17: Rocket Science

Post by weregamer »

I may have missed this earlier; I will now reveal my geekiness.

I see the implication above that in the conic regime, you're still using patched physics. That was fine in Kerbal, which at its core is not trying for accuracy and is in a fictional starsystem. But it definitely caused some issues when trying to make realistic efficient courses in Kerbal - especially when the Mun sphere happened to intersect a course that was not going to or from Mun.

I guess that even with vector processing from a GPU a full n-body problem might be too much, but I was hoping for at least a 3 or 4 body solution.

Is this more a matter of not wanting to add non-graphical GPU code, or more about schedule, or did you come up with a slicker way to do this because you don't have to simulate the entire trajectory in real-time the way Kerbal does?
User avatar
johnnylump
Site Admin
Posts: 1133
Joined: Wed Nov 11, 2015 4:12 am

Re: Terra Invicta Dev Diary #17: Rocket Science

Post by johnnylump »

We made the call early on -- like, years ago -- to use trajectory planner-type tools rather than "live" 3/4/n-body simulations. It comes down to performance and the focus of the game.

Terra Invicta isn't about trajectory design, piloting or engineering -- the assumption is all that's going to be done properly unless you don't maintain your mission control stat or other key resources. It's ultimately about strategic decisionmaking within a set of constraints, from your resources to ship designs and the distances between the planets. So n-body simulation type precision doesn't have much added value in there for the work and potential performance hit. Instead, we're building planners that calculate the critical values -- launch date, time of travel and Delta-V -- and provide a position-at-time function for mapping out where the ship is going to go. The impulse-conic planner is rooted in the Lambert Solver I mentioned in the main post; the spiral and torch stuff is much more from scratch.

I'd note that we've got up to 7 AIs playing the same game you are, potentially with dozens of fleets each. They also need to ping the trajectory planner on any given frame to see a suite of options and then filter down to what they want to do within the space of milliseconds. So we weren't eager to ask them to draw precisely optimized ellipses or time burns on-the-fly, and we're not asking the player to do those things either.

As an aside, we played around with a compute shader for conic calculations but ultimately decided not to keep going with it.

This might not answer exactly what you were asking, but it's a summary of where the gameplay and technical design meet on this point.
LordHivemindOfCeres
Posts: 2
Joined: Tue Nov 09, 2021 10:01 am

Re: Terra Invicta Dev Diary #17: Rocket Science

Post by LordHivemindOfCeres »

Does this mean that langrange points will not be usable?
User avatar
johnnylump
Site Admin
Posts: 1133
Joined: Wed Nov 11, 2015 4:12 am

Re: Terra Invicta Dev Diary #17: Rocket Science

Post by johnnylump »

Lagrange points are modeled, with some cheating. I'd refer you to the earlier dev diary about how the Solar System is modeled:
https://www.pavonisinteractive.com/phpB ... =7&t=28979
DukeDankins
Posts: 1
Joined: Wed Feb 16, 2022 8:03 pm

Re: Terra Invicta Dev Diary #17: Rocket Science

Post by DukeDankins »

It's so amazing to see deep understanding of real orbital mechanics becoming more mainstream!
A question about the ship you used to demo the deltaV slider: 250kps is an insane amount of deltaV, what's your mass ratio and specific impulse?
Last edited by DukeDankins on Wed Feb 16, 2022 8:09 pm, edited 1 time in total.
User avatar
johnnylump
Site Admin
Posts: 1133
Joined: Wed Nov 11, 2015 4:12 am

Re: Terra Invicta Dev Diary #17: Rocket Science

Post by johnnylump »

I don't recall which ship and drive was used for that pic.

We've got all manner of drives modeled, including nuclear pulse, fusion and antimatter, so it's probably one of those.
PTTG
Posts: 5
Joined: Sun Nov 29, 2020 9:59 pm

Re: Terra Invicta Dev Diary #17: Rocket Science

Post by PTTG »

I am tremendously looking forward to using this flight system. The first dozen or so nodes you correctly plan in ksp are awesome, but after that they're a chore.
keaSar
Posts: 1
Joined: Mon Apr 04, 2022 5:33 pm

Re: Terra Invicta Dev Diary #17: Rocket Science

Post by keaSar »

What about missiles and projectiles? Will they have deltaV instead of range as well?
Post Reply