I need to simulate a battle between two players. It can last from one to six rounds. The attacker can have 13 different types of spaceships, the defender - an additional 9 types of defensive structures. The fact is that I will limit the simulation to 1 kk units on each side, so it will be quite large.
Each unit will be an instance of the following class.
class Unit() { UInt16 id;
Arrays for immutable values.
player1technolgies
- armor
- technology protection
- weapon technology
player2technolgies
- armor
- technology protection
- weapon technology
player1BaseStructuralIntegrity
equall default * armor tech
And so on...
Then I will distribute two lists with each gaming device.
One round is as follows:
- Choose a random unit // actually I donโt think it matters if it is random or not
- Choose a random target
- If the strength of the weapon is below 1% of the targetโs shield, it does no damage.
- Target shields absorb damage, the rest goes to the goal of structural integrity.
- If the target structural integrity is below 30% of its initial value, it is likely that 1-structureIntegrity / baseStructuralIntegrity will explode
- Check the likelihood of a quick fire if it falls into step 2
- Go to step 1 until all blocks attack | THE NOTE! Wrecked ships - with structural integrity below 1, can still be attacked. EDIT: They can also attack this round.
- Repeat steps 1-7 for the opponent.
- Delete destroyed ships
- Restore screens
The battle lasts six rounds or until one side is defeated.
Let's consider an attacking fleet of 100 bombers against 200 missile launchers. Bombers have a 95% chance of shooting again after attacking a rocket. Thus, each bomber will attack 96 times on average, giving us 9600 attacks. Assume the defender was lucky and one rocket launcher survived. He also destroyed 10 bombers. We now have 90 bombers attacking one missile launcher, giving us another 8,640 rounds. Think of 100kg bombers and 200k launchers.
Do you have any suggestions for improving this model (performance)? How many times should I run it to get plausible average results?
Update
I think that I will probably stick to my modeling, because even if you found a mathematical solution for this, I would not understand it because of my current level of education.
Someone asked for more details.
Each level of correspondent technology increases the initial cost by 10%, but this is not important for modeling, so suppose that both players have 0 technologies. Let's look at the attacking fleet 1 "Cruiser vs. 2 missile launchers + 1 heavy laser." The cruiser has 2700 structural integrity, 50 shields and 400 weapons. I will write it as 2700: 50: 400
- Cruiser 2700: 50: 400 x1
vs - 200: 20: 80 x2 missile launcher
- Heavy Laser 800: 100: 250 x1
The booster rocket and heavy laser do not have fast fire. The cruiser has 0 quick fire against a heavy laser and 10 against a missile launch, giving it a (10-1) / 10 = 0.90 probability of firing again after attacking a missile launcher.
One possible outcome could be the following:
round 1
the attacker attacks the defender
A cruiser from 2700: 50: 400 fires a Laucher rocket from 200: 20: 80; the result is Missile Laucher with -180: 0: 80
Quick fire:
- The cruiser has fast fire against the Booster.
- the bones were 0.62, compared with 0.90: Cruiser gets another shot.
A cruiser from 2700: 50: 400 fires a Laucher rocket from 200: 20: 80; the result is a missile launcher with -180: 0: 80
Quick fire:
- The cruiser has fast fire against the Booster.
- the bones were 0.09, compared to 0.90: Cruiser gets another shot.
A cruiser from 2700: 50: 400 fires at a rocket launcher from -180: 0: 80; the result is a rocket launcher with -580: 0: 80
Quick fire:
- The cruiser has fast fire against the Booster.
- the game was 0.83, compared with 0.90: Cruiser gets another shot.
Cruiser with 2700: 50: 400 lights on a heavy laser with 800: 100: 250; The result is Heavy Laser with 500: 0: 250
Quick fire:
- The cruiser does not have fast fire against a heavy laser.
defender shoots the attacker
Missile Laucher with -580: 0: 80 fires on the cruiser from 2700: 50: 400; result is Cruiser from 2670: 0: 400
Missile launcher with fire -180: 0: 80 on a cruiser from 2670: 0: 400; result is Cruiser with 2590: 0: 400
A heavy laser with 500: 0: 250 lights on a cruiser with 2590: 0: 400; The result is a Cruiser with 2340: 0: 400
remove ships and restore shields
The cruiser still has integrity, restores its screen.
Rocket Laucher lost all its integrity, removed it from the battle.
Rocket Laucher lost all its integrity, removed it from the battle.
The heavy laser still has integrity, restores its screen.
round 2
the attacker attacks the defender
The cruiser from 2340: 50: 400 shoots with a heavy laser from 500: 100: 250; The result is Heavy Laser with 200: 0: 250
- probability of explosion 75.00% (1-200 / 800): value in the bone 0.30 compared with 0.75: the unit exploded.
Result
is Heavy Laser with 9: 0: 250
Quick fire:
- The cruiser does not have fast fire against a heavy laser.
defender shoots the attacker
A heavy laser with a fire of 9: 0: 250 on a cruiser from 2340: 50: 400; result is Cruiser from 2140: 0: 400
remove ships and restore shields.
The cruiser still has integrity, restores its screen.
The heavy laser lost all its integrity, removed it from the battle.
The battle ended after 2 rounds with the attacker's victory.