Generation of Empires

Now that we can generate a Species and a Star Map, we need to populate the galaxy. This means giving each of the Species an Empire to call their own.

This is the first time that I’ve not yet already written the code to cover this, so the end result might be very different, but this is my plan.

The goal is to populate ~10% of the galaxy, but for each Empire to be a contiguous block. It is possible that empires are going to be generated close to each other, or there might be a significant gap between them. That is entirely down to the whims of the RNG. All of the examples in this article are based on the Galaxy being 100×100 ly in size, having 1,000,000 stars in it and having 10 Species populating it.

Size of the Empire

For each Species, determine how many Stars they will have in their Empire. We want this to be roughly equal. This means that we need to have a starting value – 10% of the number of stars in the galaxy, divided by the number of species.

This gives us a current starting value of 10,000 stars in each Empire.

We are then going to modify this in two ways.

Firstly, we are going to add 1,000 for each ranking the species has in the “Expansive” trait.

This means that a Species that has Expansive: +2 will now have a value of 12,000 stars in their Empire, whilst one that has Expansive: -1 will only have 9,000 stars

Finally, we are going to add some randomness into this. We will generate a random number from a Normal Distribution with this value as the mean. This makes it possible for the species to have a final number of stars that is significantly different to this, but it’s much more likely to be very close.

Actual Stars in the Empire

Next, we need to determine what stars are in what empire. This is going to be done in a two-pass process.

The first pass is to randomly pick a sector that the empire starts in. In every case, this is going to be an unpopulated sector, and this counts as the first star that each species has.

The second pass is to determine the rest of the stars. This will be done one-star-per-species and not an entire species at a time, just to give them more chance of overlapping if they happen to be close enough.

For each star placed, we will:

  • Randomly pick a sector that has any presence from the species at all
  • Generate the list of sectors that we could pick next
  • Randomly pick one of these sectors to use for the next star.

So, the power is all behind how we generate the list of sectors.

My current plan is as follows:

  • Add the same sector that we are expanding from once for each unallocated star in it
    • If the species has a negative value for the “Expansive” trait then repeat this step again, so that the starting sector is added twice for each possible star
  • Add each of the 8 sectors around this starting sector once for each unallocated star in it
    • If the species has a negative value for the “Aggressive” trait then do not add any sectors that have a different species already present in it.
    • If the species has a positive value for the “Aggressive” trait then repeat this if the sector already has any stars allocated to a different species.
    • If the species has a positive value for the “Expansive” trait then repeat this for every sector.

Any time that we are unable to select a new sector to expand into, we simply lose that turn. This means that it’s technically possible for the species to get surrounded by other species and squashed, which is a nice side effect.

Worked Example

That sounds complicated, so let’s have a real example. Say that the selected sector was at (5, 5), and the stats for this and the surrounding sectors are:

  • (5, 5) – 5 stars, 1 allocated to current species, 4 unallocated
  • (4, 4) – 3 stars, all unallocated
  • (4, 5) – 2 stars, all unallocated
  • (4, 6) – 3 stars, 1 allocated to current species, 1 allocated to a different species, 1 unallocated
  • (5, 4) – 2 stars, all unallocated
  • (5, 6) – 0 stars
  • (6, 4) – 2 stars, all unallocated
  • (6, 5) – 1 star, allocated to a different species
  • (6, 6) – 3 stars, 1 allocated to a different species, 2 unallocated

In that case, if our species has Positive Expansive and Negative Aggressive then we will:

  • Add (5, 5) 4 times – once for each unallocated star
  • Add (4, 4) 6 times – twice for each unallocated star.
    • +1 time for being a close sector
    • +1 time for being Positive Expansive
  • Add (4, 5) 4 times – twice for each unallocated star
  • Add (4, 6) 1 time – once for each unallocated star
    • +1 time for being a close sector
    • +1 time for being Positive Expansive
    • -1 time for being Negative Aggressive and there being another species present there already
  • Add (5, 4) 4 times – twice for each unallocated star
  • Not add (5, 6) at all – no unallocated stars
  • Add (6, 4) 4 times – twice for each unallocated star
  • Not add (6, 5) at all – no unallocated stars
  • Add (6, 6) 2 times – once for each unallocated star

This means that our list to pick from has a total of 25 entries in it, from which we will randomly pick one. As such, the chance of us picking a sector that has another species already present – either (4, 6) or (6, 6) – is 3/25 = 12%, which fits with us being a Negative Aggressive species. If we were instead a Positive Aggressive species this would have actually been 9/31 = 29%, which is a big boost. Equally, if we were a Negative Aggressive AND a Negative Expansive species we would never expand into a sector that was already occupied by another species – preferring to expand away from them instead.

 

Advertisements