Logo

A space themed grand strategy with emphasis on economy, society, and politics

24 August 2022

Connecting the economy

by EhWhoAmI

The economy, being a core part of our game, needs to be constantly iterated so that we come up with an appropriate system that fits our needs. So, this round of economic updates bring more changes to the structure of the economy.

Rough Idea

The economy should

So far organization on making the economy has been disorganized at best. Hopefully it gets better over time as I get more organized and have a more concrete view of what the game will look like.

The current economy

The current economy works like this. Goods will be brought and sold to the market on the current price.

The market will take into account the number of goods put into the market (goods sold), and goods taken out of the market (goods purchased). These two values will form a ratio, calculated as goods sold/goods purchased, or the Supply Demand ratio (S/D ratio).

If the S/D ratio is above 1, then the price will be decreased, and if the S/D ratio is below 1, the price will be increased. The agents that purchase a good in the market will try to maintain the price by decreasing how much they sell if the price goes down (decreasing supply), and increase how much they sell if the price goes up (increasing supply). Similarly, the agents that sell a good will decrease how much they purchase if the price goes up (decreasing demand), and increase how much they purchase if the price goes down (increasing demand).

Agents are tagged to a market based on the body that they are on. The market will loop through each of the cities in a market, and subsequently the various agents in the market, and process the demands and supplies of the agents.

Transport times will not be handled, and goods will be teleported across a planet.

With the newest pull request #182, transport costs have been added.

Transport costs are not too complicated in the pull request, and will be expanded on a later pull request. #182 was starting to get a bit complicated because I was trying to fix the province user interface, so it’s probably a good idea to put it all into a separate pull request.

For now, transport costs are multiplied between the number goods traded and the infrastructure costs.

For this system, each city will have a base transport cost, representing the basic cost of transporting the goods to a city without any infrastructure. This base transport cost is completely arbitrary and defined in the city definition file. The base transport cost will be subtracted by the infrastructure cost. Infrastructure costs are calculated by the number of infrastructure attached to the city, such as railroads and highways. Each infrastructure piece will have a value that is summed up to the final infrastructure cost.

This pull request, though does work on the economy, doesn’t go at all to working on the full set of features planned out for the economy.

However, I will go into some detail as to which direction the economy will go in the future.

Supply and demand on transport

To simulate goods being clogged when there is a high volume of goods being transported, there will have a limit in terms of tonnage or volume when the goods are transport. There will have a linear relationship between the number of goods being transported and the transport costs, so as to simulate the shipping companies getting clogged up with their goods.

Inter-body transport of goods

Transporting goods between bodies (e.g. Earth to moon, Moon to Mars), will be an important part of the game. However this will need path-finding between 2 or more orbital bodies, and so far the game doesn’t even support the changing of orbits of spaceships. When we start work on solving lambert’s problem, then we can probably actually implement the transfer of goods between bodies.

For now this is roughly how I’d imagine the system will be implemented.

If the default price of a good is higher than the cost to orbit on a planet, or there is no goods available on the current market, then the agent will try to look for the good on other bodies. The agent will rank the good costs found on other markets based on the price, and add the approximate transport costs to the ranking. The agent will then take the lowest cost and purchase the good from there. The game will then calculate the transport cost to a space port on the origin body, and then add the transport cost of the spaceship, and the transport costs of the space port on the destination body.

There are some concerns as to performance when calculating the costs to transport from body to body, because the solution to orbital mechanics equations are not analytically solvable. However I did think of some possible options to reduce calculations.

One option is to calculate the costs of transporting goods from each planet on a economic tick, and cache them. Another is to draw a porkchop plot for the destination to each body before the game even starts and recalculate it on a separate thread every now and then.

Tariffs, sanctions and international trade

Tariffs will be a key part of the game, along with sanctions. These two will be key tools in affecting the global economy and the player’s local economy.

Implementing this will first need countries and governments to be properly implemented, so it will be implemented then.

One way to implement tariffs is to keep a counter of the gross national production of each good. If a country decides to implement tariffs on the good that they produce to another country, then the good’s transport costs will go up.

If a country decides to completely sanction off their selling of a certain good, then the supply of how much the country produces will not be taken into account with the market, however, it will decrease the cost of goods for local consumers. How that would be done is to be decided.

Resource limits

One key part about managing off-world colonies is having to manage limited resources.

One concern of not implementing resource limits right out the bat is the fact that it will benefit producers and harm consumers of a good.

The naive implementation had a map of the current resources on the market, and every time an agent bought a good onto the market, they will get their resources if the requested resource are less than what there was on the market. The amount of resource will be subtracted from the market. If there are not enough resources on the market, then the agent’s order will be cancelled. When an agent sells a good, then they will get their cash from the current cost of the good, and add the resources to the market.

Then in that case, the consumers will not be able to purchase goods, however the producers will be able to sell as many goods onto the market as they wanted. So in theory, a producer would be able to sell as much as they wanted, while a consumer would not be able to. The other case is when iterating through the market, there would always have an agent who was created first in the market, and thus iterated through first. Then, that agent would always be getting their resources, while an agent later down would not be getting their resources. Granted, we could randomly sort the list and iterate through them, thus mitigating this, however I don’t really like leaving these to chance.

I have a rough idea as to what the implementation can look like.

If the last economic tick had no supply, then all purchasers will not be able to buy the good, thus simulating shortages

If the last economic tick has no demand, then the good will not be sold at all, and the supply will be added to the next production, but with a penalty as a storage cost.

Other ideas

These ideas are ideas that I’d like to implement, however they since they cover more complicated topics, I’ll not go too in depth on them until we have the above implemented.


tags: dev-diary - economy