Devlog: Territorial expansion

Snap1418Hey there,

Sorry for the delay. As this week has been mostly about testing and balancing, it’s going to be a fairly unusual devlog format (I also apologize in advance for the mostly unrelated screenshots alongside the article). The seemingly small change of assigning sector ownership to whoever hold the most factories in the area, or to the first one to drop a military base, had extremely large repercussions in many, many parts of the game. As there’s really no accurate way to “speed up” the game to test said feature, I basically had to let the game run itself days and nights while occasionally monitoring and tuning the effects. Let’s see what happened.

Reminder

If you follow the blog regularly you know about the sector ownership thingy and you can skip this section. If not, or if you need your memory freshened up, this is for you:

Basically, in beta 2.1 (and before) each faction periodically chooses the sector it considers the best for its needs bordering its current territory and automatically claims it, for free with no special requirements. It cycles until the map is fully colonized. In beta 3 and onward, sectors will belong to whoever has the more factories there. With one exception, if a shipyard or a military base is built there, then the sector belongs to its owner no matter who has the most factories.

This first change was about 10 lines of code long. You can add 50 more lines or so for the basic “build outside my borders” faction AI logic.

So Many Ships !

Snap1417The first issue was that the number of game objects (ships and docks) kinda exploded while the territory of each faction was comparatively smaller than before. This one was unexpected to say the least, after 4 hours I had 24k ships and docks instead of the usual 10k or so. My CPU wasn’t happy. It was caused by 4 things. Firstly the Pirate AI interpreted the new rules as “place as many pirate outposts as you can everywhere”. Fine, it was an oversight, easily fixed. Next, well, given that the territory of each faction expands more slowly, dock builders have much less travel time, hence they build more factories and as a result more trading vessels, not a real issue in itself. Another reason is that with no common borders for a long time, there’s less ‘accidental’ skirmishes, resulting in less bounties, resulting in less deaths. And finally, I coded the faction AI in a way that it had no reason to declare war on others as long as there’s still space to expand, resulting in them hoarding tons of military ships (and ship parts to build those).

This last point is a bit more tricky to solve. In the current state even if it’s a trivial task to allow factions to declare war on each other with no common borders, they don’t have access to military actions that would make sense in that context (yet). So that’s my next order of business, adding punishing raids on infrastructures and the like to keep the military busy.

I also increased the manpower cost of warships to downsize military fleets a bit and get some breathing room. Previous settings were over the top anyway, endgame 50 vs 50 battleship + 200 various escort ships were a mess.

Passive factions frenzy

Snap1419Another unexpected one. Once I told the faction AI how to build docks outside their natural borders (colonize) the two passive factions which are not supposed to expand, and can’t declare war on others, started to do the same. The ISA especially, which start with several small but strategically placed solar systems in short-range of many larger systems, expanded to all the unclaimed planets in range by placing military bases (and shipyards / gates if possible) way before the other factions could.

That’s a behavior I hesitated to eradicate for a while, but the ISA starts very strong comparatively to other factions (more solar systems → more supply → more manpower → more military) because I use it as a safe haven for new players in the early game. If it’s allowed to peacefully expand outside its initial frontiers, it grows too strong and other factions are too afraid of its perceived strength to attack it.

I may however keep a tuned down expansion in place for passive factions, by forbidding them from doing ‘long range’ colonization but still allowing them to build factories in their direct neighborhood.

Peaceful takeover

Snap1413This one is nearly fixed, but in one of those games, the Drath Collective took over half the territory, including most of the home sector, of the Asterian faction without firing a shot by simply having a better economy and building more stuff than the Asterians. While this is to some extend what I want, the Asterians had the military means to deal with the issue, except they don’t recognize it as an issue. I had to change the diplomatic logic so the AI recognizes this behavior as an act of aggression. It’s not yet perfect, but we’re getting there.

Bugs under the hood

Snap1415The good thing is that it also made me notice fairly important bugs (from a simulation perspective). Just after I added the ‘long range’ colonization orders, which allows factions to colonize sectors in a 5 sector radius around their current territory, I noticed that factions absolutely didn’t care about said limit and began colonizing all over the place. While it made for an entertaining game, it was also all over the place.

In fact there was a bug in the pathfinder. I can tell him to use gates or not, and it does exactly that, however, the bug is that no matter the setting I use, when asked for the distance between 2 locations, it always returns the length of the path using gates. So, basically, factions were sending dock builders all across the map believing that all these sectors were in range. I didn’t pick on it before because all ships can use gates. Only careful monitoring of space life-forms (and they tend to stick around the same place for extended periods of time) which can’t usually use gates could have given that away otherwise.

Another bug I found (introduced in beta 2 due to a typo in the code) is that patrolling ships (but not police ships) were not attacking hostile ships anymore most of the time because apparently I set their scanning range to 2 pixels instead of 2000.

Grand Total

So, this small (but important from a gameplay standpoint) change cost a whole week of development and intensive testing and several hundreds of lines of code, not counting the changes to tons of existing lines. The more complex a game (or program for that matter) become the harder it gets to guess what’s the seemingly small changes you make are really going to do.

Of course, most of that could have been avoided if it has been written that way from the get go. Initially, the expansion was supposed to be done through a cultural system (like civ) through dedicated stations, however it would have been yet another system on an already fairly large pile of systems for the player to learn and for me to complete and all things considered it don’t think it would have benefited the game.


Other Changes !

Hey, that’s not because i nearly spent a week staring at the galactic map that i did not improved other things. Well, first, I improved the galactic map (of course ^^). In beta 2 the map was pretty laggy when filters are enabled, this is fixed now. And while at it, I added a sector population filter, and made the map a bit better looking by adding a backdrop and resizing filters.

Docks in occupied territory will give away 25% of their profits to the occupying force.

I also did some graphical improvements with new animated sprites for some stations, loot drops from space-faring creatures aren’t in a metal box anymore either. Things like that. I am also in the process on making the Asset List a bit more responsive (it was kinda clunky) and redesigning some of the menus.

I finished the work on the event system, so far there’s five different events with variations, but more will be added along the way as it’s trivial to do so. I won’t go into details of course as it’s one of the things best experienced by yourself (the swarm article was already a big spoiler in itself).

There’s a bunch of smaller things, most of them in the changelog on the forum.

And hopefully, something directly related to trading should be done next week 🙂

Leave a Reply