Forums » Suggestions
dynamic economy
I have read a number of post on dynamic economy and decided to give information on what I know about this type of models, because it is very interesting task. Hope it will help.
A dynamical model of economy based on supply/demand considerations is a very simple computational task. It involves solving of the linear system of ODEs (ordinary differential equations) of the first order numerically. This model is very similar to what they use to solve in chemistry. Currently it is not possible to implement such model in the game for the following reasons.
Each station buys/sells about 30 items. This means that for each station you need to solve 30 linear ODEs with 30x30 matrix of parameters, 900 parameters total. Since you are inventing the model, you are going to tweak 900 parameters for each station to get reasonable tendensies. This is impossible amount of work! Next, if you have about 1000 stations in the game, you need to solve a system of 30000 equations with band-diagonal matrix, bandwith=30. The inversion of such matrix is a very CPU consuming task, and you have no choise but to use the explicit finite difference scheme. Explicit scheme imposes a hard restriction on the time step (so called CFL condition), so this is another pain.
But nevertheless, it is possible to invent a beautifull economy model in virtual world. I will split the message to discribe how I would do it if I would be asked.
A dynamical model of economy based on supply/demand considerations is a very simple computational task. It involves solving of the linear system of ODEs (ordinary differential equations) of the first order numerically. This model is very similar to what they use to solve in chemistry. Currently it is not possible to implement such model in the game for the following reasons.
Each station buys/sells about 30 items. This means that for each station you need to solve 30 linear ODEs with 30x30 matrix of parameters, 900 parameters total. Since you are inventing the model, you are going to tweak 900 parameters for each station to get reasonable tendensies. This is impossible amount of work! Next, if you have about 1000 stations in the game, you need to solve a system of 30000 equations with band-diagonal matrix, bandwith=30. The inversion of such matrix is a very CPU consuming task, and you have no choise but to use the explicit finite difference scheme. Explicit scheme imposes a hard restriction on the time step (so called CFL condition), so this is another pain.
But nevertheless, it is possible to invent a beautifull economy model in virtual world. I will split the message to discribe how I would do it if I would be asked.
If I would be asked to make virtual dynamical model of economy, I would make it much more simple than it is now for the sake of fun.
First, I would limit the number of items bought/sold at a station to 5 or maximum 10. The total number of items in the game can be dozens, but each station should not have more than 10.
Second, I would invent the model with 3-diagonal matrix, i.e. the tendency of each item depends on two others. This way you need to tweak only 28 parameters for each station to make sure that you have 1 missile produced in a minute, one bot in 5 minutes, one ship in an hour, and so on. Then if you have 1000 stations you will need to solve a system of 10000 ODEs with 3-diagonal matrix, invertable in NO time. This means that you can used implicit finite difference scheme with any time step you want. You can update economy state once in a minute, once in an hour, or once a day, depending on how busy are your CPU resources.
Next, it will be necessary to make the universe economy and/or nations economy conservative, i.e. the amount of bots shot by players during some time should be equal to the amount of bots produced, and so on. For this purpose I would make several types of stations (5 types for example): stations producing ships, stations producing weapons, station producing basic resourses ... anything you want. The ballance can be kept by introducing/removing stations of certain type. Stations need to have some capacity. If the amount of produced item is grater than capacity or the amount of demanded item is less than zero, production should stop. Technically you need to solve the same 3-diagonal system of ODEs with less variables in this case, and this is where the trade missions should come into the game. This is about it.
Huh, tired to write, if somebody tired to read, just don't read :).
First, I would limit the number of items bought/sold at a station to 5 or maximum 10. The total number of items in the game can be dozens, but each station should not have more than 10.
Second, I would invent the model with 3-diagonal matrix, i.e. the tendency of each item depends on two others. This way you need to tweak only 28 parameters for each station to make sure that you have 1 missile produced in a minute, one bot in 5 minutes, one ship in an hour, and so on. Then if you have 1000 stations you will need to solve a system of 10000 ODEs with 3-diagonal matrix, invertable in NO time. This means that you can used implicit finite difference scheme with any time step you want. You can update economy state once in a minute, once in an hour, or once a day, depending on how busy are your CPU resources.
Next, it will be necessary to make the universe economy and/or nations economy conservative, i.e. the amount of bots shot by players during some time should be equal to the amount of bots produced, and so on. For this purpose I would make several types of stations (5 types for example): stations producing ships, stations producing weapons, station producing basic resourses ... anything you want. The ballance can be kept by introducing/removing stations of certain type. Stations need to have some capacity. If the amount of produced item is grater than capacity or the amount of demanded item is less than zero, production should stop. Technically you need to solve the same 3-diagonal system of ODEs with less variables in this case, and this is where the trade missions should come into the game. This is about it.
Huh, tired to write, if somebody tired to read, just don't read :).