This agent is responsible for creating an economic system to
support and achieve the strategy with help from the other agents. This agent has a strong communication with the Unit Agent and also Building Agent.
It starts by calculating the total resource requirements of the strategy. For
example, if the strategy agent asks for five knights and five clerics, it will
calculate the cost of these ten units and also the additional cost of their dependences (in this case Barracks and Monastery). If the initial amount of resources is not enough to
satisfy this strategy, it also adds the cost of the resource buildings and
workers needed to fulfill the missing resources.
Once it knows
the total resources needed , it makes a calculation of how many
workers are needed. After that,
it distributes them among the different resources by calculating percentages. The percentage of needed wood over the total
needed resources is the percentage of workers assigned to get wood over the total needed
workers. With this we ensure that if we need three times more wood than any
other resource, it is going to spend three times more workers to gather it
compared to other resources.
All the mentioned parts above relay on mathematical formulas that unfortunately I can't show because this blog doesn't allow Mathematical Symbols and showing them picture by picture would be really tedious. Nevertheless, I mention and show them in my thesis paper.
Although the developed formulas can be used in pretty much every RTS, some parameters should be modified and adapted depending on the gathering speed for each resource and so on, as every RTS game is different in that aspect.
As for the
order of the resources assignation when training new workers, it is done with
certain randomness by assigning weight at the resources. For instance, food has
the biggest weight because it is the main resource needed to produce more
workers and avoid stalling. Therefore, the first workers will mostly get assigned to gather food and wood.
Percentages
for resources assignment are:
-
Food 34%
-
Wood 28%
-
Stone 22%
-
Gold 16%
Gold is a
resource needed for advanced combat units, therefore it has the lowest weight
at the beginning to have a better boost on the other resources.
If one
resource has all its workers already assigned and a worker rolls for that
resource, it rolls again.
This system is probably less accurate than if we scripted the resource order by code depending on the required strategy, but would be less adaptive and we also gain a bit of randomness, which is good to avoid the exact game over and over again.
After some tests giving the AI the same amount of resources and the same amount of units to train, I realised that changing the order of a single worker in the first minute of the game, can lead into "major" differences in minutes 7-10, which is great because although the overall strategy and the final result is pretty much the same, the paths it follows to achieve it are slightly different, giving always new experiences to the player.
The firsts test results of this agent were really positive.
No hay comentarios:
Publicar un comentario