MasterSplinter
New member
- Joined
- Jul 22, 2015
- Messages
- 9
Hi everyone. I hope I am posting this in the right place. I know this will contain some calculus, but since it looks a bit more complicated I will post it here. If it belongs somewhere else, please move it to the relevant thread. I know this one is a bit long, but I would really appreciate it if you take your time to help me. I am not from an english speaking country, so please excuse me if my english is a bit off.
I am trying to make a formula for a strategy game. To understand the problem better, I will give you a very brief introduction to the relevant parts of the game. In this game each player makes troops for multiple villages, that fight each other. There is a maximum amount of troops a player can make in each village, but I will get back to this in a moment. There are three kind of units that fight seperatly; infantery, cavalery and archers. Both of these kind of units have offensive and defensive units. Each of these units have attack/defence power. What I am trying to make is a formula that can say:
- What is the strongest offensive village you can make agaist a given defensive village?
- What is the strongest defensive village you can make against a given offensive village?
Before we head into the problem, Ill give you an overview of the units.
Infantery units:
Spearman
Attack power: 10
Infantery defence: 15
Cavalery defence: 45
Archer defence: 20
Population: 1
Now, lets get on to the problem:
Swordman
Attack power: 15
Infantery defence: 50
Cavalery defence: 15
Archer defence: 40
Population: 1
Axeman
Attack power: 40
Infantery defence: 10
Cavalery defence: 5
Archer defence: 10
Population: 1
Cavalery units:
Light cavalery
Attack power: 130
Infantery defence: 30
Cavalery defence: 40
Archer defence: 30
Population: 3
Heavy cavalery
Attack power: 150
Infantery defence: 200
Cavalery defence: 80
Archer defence: 180
Population: 6
Archer units:
Archer
Attack power: 15
Infantery defence: 50
Cavalery defence: 40
Archer defence: 5
Population: 1
Mounted Archer
Attack power: 120
Infantery defence: 40
Cavalery defence: 30
Archer defence: 30
Population: 5
Each village can have a population of maximum 18.500
Alright, lets get on to the math. I know that battle results are made out of this formula:
This formula is used three times in a battle (one time for each unit type (infantery/cavalery/archer units). If you feel very confused so far, I will show an example of how a battle works below (I recommend skipping the quoted example until you have read the rest of this post):
This example didnt contain archer units, since that would make it even more complicated, but it is calculated the exact same way.
Now, in this example I was given both the offensive and the defensive strength, but lets say I only knew one of them. What is I knew that the defense was 9250 spearmen and 9250 swordmen (total of 18500 population)? How will I be able to calculate what the best possible offensive army would be?
I have tried to calculate a bit with derivation, but since infantery strength, cavalery strength and archer unit strength all need to take each other into account, it is getting too hard for me.
I would really appreciate some help. Please explain how you are thinking, so that I can understand it too :smile: Thank you in advance!
I am trying to make a formula for a strategy game. To understand the problem better, I will give you a very brief introduction to the relevant parts of the game. In this game each player makes troops for multiple villages, that fight each other. There is a maximum amount of troops a player can make in each village, but I will get back to this in a moment. There are three kind of units that fight seperatly; infantery, cavalery and archers. Both of these kind of units have offensive and defensive units. Each of these units have attack/defence power. What I am trying to make is a formula that can say:
- What is the strongest offensive village you can make agaist a given defensive village?
- What is the strongest defensive village you can make against a given offensive village?
Before we head into the problem, Ill give you an overview of the units.
Infantery units:
Spearman
Attack power: 10
Infantery defence: 15
Cavalery defence: 45
Archer defence: 20
Population: 1
Now, lets get on to the problem:
Swordman
Attack power: 15
Infantery defence: 50
Cavalery defence: 15
Archer defence: 40
Population: 1
Axeman
Attack power: 40
Infantery defence: 10
Cavalery defence: 5
Archer defence: 10
Population: 1
Cavalery units:
Light cavalery
Attack power: 130
Infantery defence: 30
Cavalery defence: 40
Archer defence: 30
Population: 3
Heavy cavalery
Attack power: 150
Infantery defence: 200
Cavalery defence: 80
Archer defence: 180
Population: 6
Archer units:
Archer
Attack power: 15
Infantery defence: 50
Cavalery defence: 40
Archer defence: 5
Population: 1
Mounted Archer
Attack power: 120
Infantery defence: 40
Cavalery defence: 30
Archer defence: 30
Population: 5
Each village can have a population of maximum 18.500
Alright, lets get on to the math. I know that battle results are made out of this formula:
Winners losses = (Loosers strength/Winners strength)^1,5
This formula is used three times in a battle (one time for each unit type (infantery/cavalery/archer units). If you feel very confused so far, I will show an example of how a battle works below (I recommend skipping the quoted example until you have read the rest of this post):
Lets say you use an attacking force of 6000 axemen and 3000 light cavalery against a defending force of 5000 spearmen and 5000 swordmen.
First, lets look at the numbers for the attacking force:
Attack power:
Axemen (infantery strength)= 240000 (6000x40)
Light Cavalery (cavalery strength) = 390000 (3000x130)
Total attack power = 630000;
Since 24/63 of the total attack power is infantery strength 24/63 of the defensive units will defend against infantery. Multiply this number with the units infantery defence. This means that the defence will contain:
1904,762 spearmen (28571,428 infantery defence)
1904,762 swordmen (95238,095 infantery defence)
This means that the total defensive strength against infantery would be 123809,523
This means that the infantery attack strength is 2400000 while the infantery defence is 123809,523. Now, lets put these numbers into the formula above:
(123809,523/240000)^1.5 = 0,37052218207460881201358712215362
0,37052218207460881201358712215362 * 6000 (number of attacking axemen) = 2223,1330924476528720815227329217
The attacker looses 2223 Axemen
Now we will do the exact same thing for the cavalery battle:
Since 39/63 of the total attack power is cavalery attack, 39/63 of the defence will fight cavalery attack.
The attacking cavalery power is 390000.
The defensive power is
3095,238 Speamen (139285,714 cavalery defence)
3095,238 Swordmen (46428,571 cavalery defence)
Total of: 185714,285
Let put these numbers into the formula:
(185714,285/390000)^1,5 = 0,32860264541009845899038191059149
0,32860264541009845899038191059149 * 3000 (number of attacking light cavalery) = 985,80793623029537697114573177448
The attacker looses 986 light cavalery
By using the formla we calculated the result of a battle where 6000 axemen and 3000 light cavalery attacks 5000 spearmen and 5000 swordmen. The defender looses everything, while the attacker looses 2223 axemen and 986 light cavalery.
This example didnt contain archer units, since that would make it even more complicated, but it is calculated the exact same way.
Now, in this example I was given both the offensive and the defensive strength, but lets say I only knew one of them. What is I knew that the defense was 9250 spearmen and 9250 swordmen (total of 18500 population)? How will I be able to calculate what the best possible offensive army would be?
I have tried to calculate a bit with derivation, but since infantery strength, cavalery strength and archer unit strength all need to take each other into account, it is getting too hard for me.
I would really appreciate some help. Please explain how you are thinking, so that I can understand it too :smile: Thank you in advance!