# Production Algorithm

### From Conquest Wiki

To keep the turn speed reasonable, production in Conquest is automated. However, the system is relatively complex, and a good commander can use it to his advantage.

## Old Concept

In its first version, the production system was quite simple. Cities had a production of 1, mega cities of 2 and every settlement had three production queues for the three unit types. In every turn the production value of a city was added to all three of its queues. When a queue had accumulated enough points (e.g. 8 for the trooper queue, 16 for the tank queue and 24 for the bomber queue), it got reset and a unit of the corresponding type appeared.

However, this system had a heavy disadvantage. The randomly generated map had too high impact on the outcome of the match. One player might have had several fast producing mega cities in the back of his empire, while the other one had them close to the front. Now the second player had his units a lot faster in the field and just overpowered the other player, who couldn't do much about it (at this point also operations weren't implemented yet).

We experimented a lot with map design back then (like algorithms for symmetrical maps), but didn't get any satisfying solutions - until we figured out the solution was lying in the production.

## New Concept

Without being able to set production points, the best and fairest point to get units, is the center of a player's empire - called the core. With the biggest unit gain there, a player can move his troops in any direction at reasonable speed. Moreover, a commander can indirectly set his production focus by expanding in certain directions.

But how is it decided how fast the core cities produce? Or the outer cities?

Let's start by finding out the total production points of an empire. Every city adds 1 production point, while every mega city adds 2. Now we have to decide on a way to spread this total amount of production points over all settlements. For that we calculate the mass center of the empire.

We add up the position vectors of all cities, add twice the position vectors of all mega cities, and divide the result by the number (amount of cities + 2 * amount of mega cities). The result is a coordinate vector for the center of a player's empire.

Next, we calculate the distances from all cities to this center point, as well as the sum of all those. To get the production request of a city, we simply invert the fraction (distance of city to the center) / (sum of all distances to the center). The closer a city is to the center, the higher its production request value will be. If we now divide this production request of a city by the sum of the production request value of all cities, we get a percentage value which determines its share of production points. Voila.

As in the old algorithm, those production points are now simply added to the unit production queues; unit gain is handled accordingly. It is noteworthy to say, that in the new production system, the tank queue has an offset which is 1/3 of the trooper's production cost, and the bomber queue's offset is 2/3 of the trooper's production cost; which will reduce the chance to gain more than one unit per turn (though it still happens in cities close to the core).

Some people might have figured out, that the system as described here can't work under certain circumstances. What if a city is exactly placed on the center (which is possible)? It would have an infinite production request value, which doesn't compute. The solution is to go 3D. We shift the center by a certain distance upward above the battlefield. The higher our center is on the Z axis, the more even the points are spread between all cities of a player. The lower it is, the more centered the production gets and the faster core cities produce.

## Production Delay

It's good to know that all production points a city would receive are lost if either a battle took place or a nuclear missile landed. That system got implemented so that a player who conquers a city doesn't get any units out of it right after, but instead has to hold the city for at least one turn. It also allows some interesting strategies, as battles or missile hits in a player's core cities can greatly hinder his unit gain.