During the last couple of weeks, I’ve been working more and more on content for the next release, as opposed to features. The next release is going to add four new star systems – Arcadia, Eos, Magec, and Valhalla. David has done a lion’s share of work in mapping these out and creating the backstory – and now, it’s time for these to be populated with fleets.

When adding content, a key question that comes up is how much to procedurally generate vs hand-craft. Both approaches have their pros and cons; on a very basic level, hand-crafted content is going to have higher initial quality, while procedurally generated content is going to have more replay value. It’s not a question of which approach to choose, though. Every approach lies somewhere on a continuum between the two, so the question is exactly how to mix hand-crafted and procedural components, and in what proportion – in this case, specifically as it applies to fleet creation.

Before deciding how to do something, it’s not a bad idea to figure out what it is you want to actually do. With that in mind, let’s take a look at what we actually want out of fleet creation. There are two parts to it: what ships make up a fleet, and what kinds of fleets to spawn (and where, and how often).

Fleet Composition

First, the obvious: what ships go into a fleet depends on what type of fleet it is. A trade fleet is going to need freighters, a patrol is going to need fast attack ships, and so on.

Completely unrelated screenshot of the habitation glows on Sindria, along with some backstory

Ships aren’t directly tied to factions; ultimately the idea is that ship production is based on the availability of blueprints. So, for example, the Hegemony-controlled autofactory at Jangala may have a blueprint that allows it to produce Enforcer-class destroyers, while a different Hegemony world might not. On the other hand, given a choice between the high-tech (and high-cost!) Medusa and the low-tech, reliable Enforcer, a Hegemony commander would prefer the latter; factions should be able to express ship preferences in some way.

“Proper” autofactory-based ship production isn’t part of the next release, but ideally, the new system for creating fleets would be built to easily factor in ship availability.

Finally, with local conditions of the market that’s creating the fleet should factor in as well. A highly stable market is going to produce higher quality, better-equipped fleets.

Up until now, Starsector has been using a system where fleet compositions are explicitly defined for each faction. A Hegemony patrol might have one to three specific Enforcer variants (a “variant” being a particular weapon loadout), zero to two Broadsword fighter wings, etc. Good enough for what it needed to do, but this kind of approach isn’t flexible enough to meet the new requirements – what would it do if Enforcers aren’t available at all, but a different type of destroyer was? What we need is an extra layer of abstraction.

"escortMedium":{ "enforcer_Assault":20, "medusa_PD":10, "fallback":{"combatMedium":1}, },

This is what the definition of a ship role looks like. It says that 1) a Medusa variant and an Enforcer variant are both suited for the “medium escort” role, 2) all things being equal, the Enforcer variant is more desirable (20 to 10, so by a factor of two, and 3) if neither is available, fall back to picking one “medium combat” ship instead.

There’s a default set of ship roles, but each faction can define its own, thus expressing its preferences. For example, the Tri-Tachyon Corporation would prefer the high-tech Medusa instead, and might have a different loadout for it as well – but would still fall back to using an Enforcer if that’s what was available.

The stability of the market creating the fleet further adjust the weights to prefer more expensive ships with higher stability.

When putting together a fleet, then, we just say that it needs two medium escorts, a medium freighter, and a small personnel transport. What we might end up with, depending on ship availability, fallbacks, and how the faction defines its ship roles, could be two small combat ships, a medium escort ship, two small freighters, and a medium personnel transport. There’s enough flexibility to put together a fleet that roughly matches the specifications, but takes into account what’s actually available.

Trade Fleets and Patrols

The economy is a big part of the next release, and having trade fleets ply routes dictated by supply and demand is a big part of making it visible to the player and making the world feel more alive.

The algorithm for generating trade fleets is simple:

Do we have the maximum allowed number of trade fleets in play? If we do, abort and check again later. Pick a market to spawn a trade fleet from. Bigger markets have a higher chance to be picked, but the same market can’t be picked twice within a week or so. Pick another market to send the fleet to. Markets that have a higher trade volume with the initial market have a higher chance to be picked.

At this point, we’ve got the trade route. Now we need to create the trade fleet, and the new approach to fleet composition makes it much easier. We don’t need to worry at all about what faction either of the markets is owned by, what ships are available, etc. We just add enough transport ships to match the types and quantity of cargo being carried, add an appropriate number of escorts, and the fleet composition algorithm takes care of the rest.

Generating patrols is similar. The number of patrols is governed by the size and stability of the market, and the actual ships that the patrol is made up of is determined by the faction and by ship availability.

All in all, this is a heavily procedural approach, and you might be thinking to yourself – “But what if there’s a case where we want something special that the above can’t handle? Procedural content is good as a baseline, but it’s not going to take you all the way there.” Indeed it’s not; a more customized approach is still possible, as is disabling automated trade fleet and patrol generation for specific markets. The procedural approach is meant to fill in the blanks, so to speak; to provide a basic level of meaningful-looking activity that you get for free. Detail can be hand-crafted in as needed.

Other Stuff

Speaking of meaningful-looking activity, but on a somewhat unrelated note: something I found interesting came up while playtesting the behavior of trade fleets. Initially, the fleets would spawn and immediately proceed to their destination. This just felt… strange. Part of it is that fleets fade in after they spawn, and that was very apparent when the fleet immediately headed away from the planet is started from. It also made the fleets seem very mechanical in their behavior – take off, immediately head off, tag the destination, immediately head back and despawn after tagging the original market. The proceedings lacked gravitas, if you will.

Adding an extra step where fleets orbit each world, loading and offloading cargo for several days, made a huge difference in terms of feel. Just seeing non-frantic activity in orbit around a world, large fleets orbiting slowly on a predictable trajectory. I was surprised how much such a minor change helped make things feel more alive.

This also reminds me of when I tried reducing fleet speeds by a factor of 10 or so, just to see what would happen. Sounds drastic, right? It is, and it wouldn’t work out well without some changes to gameplay. Purely on a feel level, though, it was really, really good. Instant majestic feel to everything!

Switching topics once again, but still about trade fleets: you might be wondering what impact those have in-game. If you’ve been keeping track, you know that the economy goes on behind the scenes, and doesn’t depend on trade fleets to actually work. This is good, because relying on trade fleet behavior would make for an incredibly brittle and volatile system. You can’t even count on a trade fleet from market A to market B spawning with any regularity, let alone arriving safely.

On the other hand, what happens to trade fleets can feed back into the economy without running into the same issues. When trade fleets take losses along a route, it affects the economy, and can drive goods to different markets in the long term. There are also smuggling fleets. These are analogous to trade fleets, though smaller, and feed back into the economy in a similar way, with the addition of a “smuggling” market condition that applies a penalty to the market’s stability.

Alright, then… back to the content-ing!

Comment thread here.

Tags: economy, fleets, pretty sure these tags aren't good for anything, procedural, trade