Some music and nicer camera

I refined the combat camera to be smoother and also added a feature to follow units with the camera. It helps a lot that you don’t have to manually follow the flying ships while trying to do something. However, in follow mode the camera is not locked to the unit(s) followed: instead the reference point for the camera moves with the unit(s) and the camera can still be moved around normally. Camera can also be snapped to move to selected units by pressing a button or by double pressing the unit group.
    Also, I’m glad to say that Jarkko Rotstén was interested enough to join the project to provide music. Currently we are trying to find the right style for the music and I feel we are on the right track.

I made a video for the music and to show the new camera features. The video starts from fleet creation before the combat and also has some explanations on what’s going on. The music starts at 1:30.

Point defence

I have done so much panels and UI stuff recently so I wanted to add something different next. I decided to add target finding logics for turrets at this point. Until now the turrets have targeted only the one target set for the ship but now they find their targets autonomously, prioritizing missiles. So if there are missiles present they work as point defence.

First tech tree

Moving on to implement the first version of the technology system and tech trees. I like the idea of randomness in technologies: you should not know for certain what scientific discovery you are going to make next or in the whole future. Still the randomness should be balanced to avoid the situation that one civilization gets all of the good techs and some other civilization gets bad ones. The solution I made is that the technology tree is random but same for all civilizations. The tree represents the scientific laws of that universe: It dictates what kind of technologies can be found and in which order and those laws are the same for everyone.

At the start of the game some of the technologies will be omitted from that game altogether, those things do not exist in this universe. The rest forms a tech tree which is common for all civs. Civilizations will see only the techs they can research next and also how many new technology choices those techs will open up. How far in the tech tree civs can see beforehand might become variable depending on acquired techs and racial bonuses (or penalties). In addition, not all of the tech opportunities will be visible for all civilizations. This means that different parts of the common tech tree will be hidden for each civilizations and techs in those parts have to be gained via espionage or capturing bases or enemy ships. There also might be racial factors which affect how freely the common tech tree can be progressed. For example, creative races might see all options and non-creative have to follow a very predetermined path. In any case, it should be guaranteed that there are enough techs available for every civilization and that there is a path to at least some of the best techs.

In the video you can see a first version of a randomized tech tree. I ran it three times with different amounts of techs. It is designed in a way that it only reveals the parts which are known to the player’s civ. This info (and only this same info) should be available for the civs controlled by the AI also.

Expanding AI and colony ships

I started with the strategy map AI and decided to make a basic game AI which just produces colony ships and sends them to new planets. That sounds quite simple: just take a colony ship and order it to the closest free planet. But what if there happens to be multiple colony ships available, some of which would go to the same closest planet? What if a new colony ship is produced and is closer to some habitable planet than an existing colony ship en route to that planet? What if some of the colony ships can colonize only certain types of planets? What if some of the colony ships have a huge jump range and would be better to be spent on planets farther away?

I decided to solve this optimization problem by implementing Hungarian algorithm. Now the ships are assigned to free planets optimally in a way that the overall time spent on flying is minimized. It also takes different jump ranges and colonizing restrictions into account. It is also run every turn so if the situation changes, the ships will adapt accordingly.

In the first video there are four civilizations expanding to the stars. In the second video there is one civilization which starts with a huge amount of colony ships. Turn counter can be seen at the top right corner of the screen.

Ship production

Testing the ship pipeline from design to production and to flying to fight some enemies. Currently there are not many restrictions on what can be put on the ship, but soon I have to start improving the ship designing system by adding things like power sources, power consumption, mass and cost of weapons and other modules. Note the nice ship blueprint card in the planet panel in the lower left corner of the screen which shows the actual design of the ship with the weapons it currently has.


I started to design the planet mechanics I have had in mind in a bit more detail. Mainly working with population growth and food mechanics and how to control the population on planets. People have to eat food to stay alive, but they will require more food to reproduce. Also, the growth rate is affected by the remaining free space on the planet. I feel this is quite realistic and simple. So the growth rate of the population on a planet is affected by the surplus of food and the size of the planet. As players can affect the growth rate by allocating work for farming, I find it convenient that the population’s work allocations can be set to meet desired goals. The goals are: sustain population size, max population growth and max food output (surplus can later be stored or sent to other planets). The allocation of workers then changes automatically once the requirements to meet these goals change. In addition, there is also a weight parameter assigned with the farming plan, which interpolates between these goals. With these tools the player can easily set the desired goals for the planets, hopefully reducing the amount of needed micromanagement.

After some (or all) of the workers have been allocated for farming (thematically all kinds of agricultural tasks, not just farming, whatever is required to get food on that planet) the rest of the workers are allocated to industry and research. There is another slider to set the ratio for this allocation.

All planets have base multipliers for food, industry and research output as well as a starting size. Now they are just randomized, but in the future there will be some kind of correlation between these numbers. Probably by having different types of planets and then using that base type as a starting point for some randomization.

Saving system

I have been thinking about and preparing how to make the saving system for the game right from the start. Now the individual pieces can finally be connected and tested. This system allows me to do the scene transitions seen in the previous post and the saving of the game seen in this video. In the video I set courses for the ships and make new blueprints and save to see that things are loaded correctly. For debugging purposes I save the state of the game into binary and JSON. JSON so that human can inspect it easily and binary because that’s what I’m going to really use in the end. Every time the game loads it loads both files and checks that everything matches.

I like to make only a few prefabs for the UI objects and then use them in different places and customize them via code instead of the inspector. This way only a small number of UI objects have to be maintained, it is not always fun to fiddle with those. For example the saving and loading panels are actually the same panel, but opening it up from different places assigns different functions for the save/load-panel and shows and hides different buttons.

Scene transitions

Fixed some issues with transitioning to combat and back and added transition to ship designing scene. Also added some UI things like a main menu panel and a fleet panel to show which ships the selected fleet contains. Next I will add some basic mechanism to colonize star systems and produce ships there. I still have to make some kind of basic enemy AI for the strategic part of the game and then a very simple version of the game can be “played”.


It was finally time to add some more efficient ways of finding ships based on their location. Things like finding closest ships to some location or all ships inside some radius around that location is needed in many places. For example when a ship wants to find the closest enemy or when some phenomenon affects all ships within some distance. So I implemented an octree to be used in the battle for this purpose. The benefits of the octree is that when looking for ships near some location, the algorithm can first iterate the bigger cubes and check if anything inside that can be close enough to the location. If not, every ship under that cube and its subcubes can be ignored, otherwise each subcube is again considered. Managing the octree of course takes some work, but with lots of ships the benefits greatly outweigh the costs.

In the video you can see visualization of the octrees and an example of its use. There are 200 ships per side, and for each frame and for each ship the closest ship from the enemy army is found. The closest ship is visualized with a blue line for the first army and with a red line for the second army. In a real case, the nearest ship search is done much more rarely, maybe closer to once per frame than 400 times per frame like here. Also, usually there should be some max distance in the search which also makes it a bit cheaper. This is not a real performance test since it is only run in the Unity editor, which makes this a bit slow for other reasons.

Unit groups

Giving commands one by one to huge numbers of ships is not very handy, not to mention all other problems like small ships getting lost in some corners of space. So I added some group controls to the combat UI. Now ships can form groups, like in many RTS-games, and there is also a button to choose all remaining ships. Groups can be selected by pushing the corresponding numeric button or by clicking near the midpoint of the group. I still keep the option of choosing ships freely, but I might change it later so that the groups are fixed like in Total War -games. That might be a much easier way to command the armies and probably wouldn’t restrict the combat too much. But will have to test and see if that is needed.

Also added a button which shows the command queue of all ship groups.