Difference between revisions of "Medieval Battle Simulation"

From Simulace.info
Jump to: navigation, search
 
(5 intermediate revisions by the same user not shown)
Line 1: Line 1:
 
=Introduction=
 
=Introduction=
This model simulates a medieval battle between two armies (blue vs red).
+
This model simulates a medieval battle between two armies (blue vs red).<br/>
 +
The main goal is to find which formations and compositions of units work against which.<br/>
 +
Uploading files to this wiki was unsuccessful, so I've provided external links as well (with the hope that file upload might be fixed in the future).
  
 
=Problem definition=
 
=Problem definition=
The main goal is to find which formations and compositions of units work against which.<br/>
 
 
Two armies fight each other on a battlefield. An army is composed of several units in a certain formation.<br/>
 
Two armies fight each other on a battlefield. An army is composed of several units in a certain formation.<br/>
 
When simulation is started the armies move against each other, killing the units of the opposing army.<br/>
 
When simulation is started the armies move against each other, killing the units of the opposing army.<br/>
Line 18: Line 19:
 
'''Scenario A'''<br/>
 
'''Scenario A'''<br/>
 
Same composition of units and formations.<br/>
 
Same composition of units and formations.<br/>
A1: line vs line
 
A2: square vs square
 
A3: wedge vs wedge
 
  
 
'''Scenario B'''<br/>
 
'''Scenario B'''<br/>
 
Same composition of units, different formations.<br/>
 
Same composition of units, different formations.<br/>
B1: line vs square
 
B2: line vs wedge
 
B3: square vs wedge
 
  
 
'''Scenario C'''<br/>
 
'''Scenario C'''<br/>
 
Knights centric Blue vs Spearmen centric Red<br/>
 
Knights centric Blue vs Spearmen centric Red<br/>
C1: line vs line
 
C2: square vs square
 
C3: wedge vs wedge
 
C4: line vs square
 
C5: line vs wedge
 
C6: square vs wedge
 
  
 
'''Scenario D'''<br/>
 
'''Scenario D'''<br/>
 
Swordsmen centric Blue vs Spearmen centric Red<br/>
 
Swordsmen centric Blue vs Spearmen centric Red<br/>
D1: line vs line
 
D2: square vs square
 
D3: wedge vs wedge
 
D4: line vs square
 
D5: line vs wedge
 
D6: square vs wedge
 
  
 
'''Scenario E'''<br/>
 
'''Scenario E'''<br/>
Generic Blue vs Max number of units Red<br/>
+
Generic Blue vs Swordsmen and Knights Red<br/>
D1: line vs line
 
D2: square vs square
 
D3: wedge vs wedge
 
D4: line vs square
 
D5: line vs wedge
 
D6: square vs wedge
 
  
 
=Model=
 
=Model=
Line 82: Line 59:
  
 
=Results=
 
=Results=
 +
Table of results with every battles outcome:<br/>
 +
[[File:xlazl00_Results_Table.PNG]]
 +
[https://uloz.to/!2gg2D3yYIO2X/xlazl00-results-table-png]
  
 +
Screenshots of every battle before it starts (ZIP):<br/>
 +
[[File:xlazl00_Screenshots.zip]]
 +
[https://uloz.to/!2dsY6o3IJzOx/xlazl00-screenshots-zip]
  
 
'''Scenario A'''<br/>
 
'''Scenario A'''<br/>
 
Same composition of units and formations.<br/>
 
Same composition of units and formations.<br/>
A1: line vs line<br/>
+
A1: line vs line => TIE<br/>
  
A2: square vs square<br/>
+
A2: square vs square => TIE <br/>
  
A3: wedge vs wedge<br/>
+
A3: wedge vs wedge => TIE<br/>
  
 
'''Scenario B'''<br/>
 
'''Scenario B'''<br/>
 
Same composition of units, different formations.<br/>
 
Same composition of units, different formations.<br/>
B1: line vs square<br/>
+
B1: line vs square => BLUE<br/>
  
B2: line vs wedge<br/>
+
B2: line vs wedge => RED<br/>
  
B3: square vs wedge<br/>
+
B3: square vs wedge => RED<br/>
  
 
'''Scenario C'''<br/>
 
'''Scenario C'''<br/>
 
Knights centric Blue vs Spearmen centric Red<br/>
 
Knights centric Blue vs Spearmen centric Red<br/>
C1: line vs line<br/>
+
C1: line vs line => RED<br/>
  
C2: square vs square<br/>
+
C2: square vs square => RED<br/>
  
C3: wedge vs wedge<br/>
+
C3: wedge vs wedge => RED<br/>
  
C4: line vs square<br/>
+
C4: line vs square => RED<br/>
  
C5: line vs wedge<br/>
+
C5: line vs wedge => RED<br/>
  
C6: square vs wedge<br/>
+
C6: square vs wedge => RED<br/>
  
C7: square vs line<br/>
+
C7: square vs line => RED<br/>
  
C8: wedge vs square<br/>
+
C8: wedge vs square => RED<br/>
  
C9: wedge vs line<br/>
+
C9: wedge vs line => RED<br/>
  
 
'''Scenario D'''<br/>
 
'''Scenario D'''<br/>
 
Swordsmen centric Blue vs Spearmen centric Red<br/>
 
Swordsmen centric Blue vs Spearmen centric Red<br/>
D1: line vs line<br/>
+
D1: line vs line => RED<br/>
  
D2: square vs square<br/>
+
D2: square vs square => RED<br/>
  
D3: wedge vs wedge<br/>
+
D3: wedge vs wedge => RED<br/>
  
D4: line vs square<br/>
+
D4: line vs square => BLUE<br/>
  
D5: line vs wedge<br/>
+
D5: line vs wedge => RED<br/>
  
D6: square vs wedge<br/>
+
D6: square vs wedge => RED<br/>
  
D7: square vs line<br/>
+
D7: square vs line => RED<br/>
  
D8: wedge vs square<br/>
+
D8: wedge vs square => TIE<br/>
  
D9: wedge vs line<br/>
+
D9: wedge vs line => RED<br/>
  
 
'''Scenario E'''<br/>
 
'''Scenario E'''<br/>
 
Generic Blue vs Swordsmen and Knights Red<br/>
 
Generic Blue vs Swordsmen and Knights Red<br/>
E1: line vs line<br/>
+
E1: line vs line => BLUE<br/>
  
E2: square vs square<br/>
+
E2: square vs square => BLUE<br/>
  
E3: wedge vs wedge<br/>
+
E3: wedge vs wedge => BLUE<br/>
  
E4: line vs square<br/>
+
E4: line vs square => BLUE<br/>
  
E5: line vs wedge<br/>
+
E5: line vs wedge => BLUE<br/>
  
E6: square vs wedge<br/>
+
E6: square vs wedge => RED<br/>
  
E7: square vs line<br/>
+
E7: square vs line => RED<br/>
  
E8: wedge vs square<br/>
+
E8: wedge vs square => BLUE<br/>
  
E9: wedge vs line<br/>
+
E9: wedge vs line => BLUE<br/>
  
 
=Conclusion=
 
=Conclusion=
  
 +
Through the many battles it became clear that numbers and the ability to flank the enemy are the major deciding factors.<br/>
 +
When even a stronger enemy is flanked, their chances of winning are quite slim.<br/>
  
 +
Changing the cost/budget/health/damage of the units might change the results, but with how I set the model, having a wider (taller) formation and greater numbers is a sure way to victory.<br/>
 +
However one cannot omit the factor of chance. Since the damage given is a random number (between half of damage and full damage), there might be few occasions when luck decides the battle.<br/>
  
 +
=Code=
  
=Code=
+
[[File:xlazl00_battle_sim.nlogo]]
 +
[https://uloz.to/!EdjqgNNUzDdn/xlazl00-battle-sim-nlogo]

Latest revision as of 14:37, 20 January 2019

Introduction

This model simulates a medieval battle between two armies (blue vs red).
The main goal is to find which formations and compositions of units work against which.
Uploading files to this wiki was unsuccessful, so I've provided external links as well (with the hope that file upload might be fixed in the future).

Problem definition

Two armies fight each other on a battlefield. An army is composed of several units in a certain formation.
When simulation is started the armies move against each other, killing the units of the opposing army.
When one army has no units left alive it is considered defeated and simulation is over.
There is a limit to how many units an army can have, each unit type has a cost.
Sum of costs cannot be greater than cost limit (600). Furthermore, an army cannot have more than 32 units of the same type.

Method

I am using NetLogo to simulate movement and combat of the units.
I have selected certain scenarios which bring out differences in military strategies.
Each scenario is run 20 times. More runs would ensure higher certainty of results.
Since there is a bit of randomness in play (seeking enemies, random hits), if an army wins by just a small portion of it surviving (e.g. one soldier) I will consider it a tie.

Scenario A
Same composition of units and formations.

Scenario B
Same composition of units, different formations.

Scenario C
Knights centric Blue vs Spearmen centric Red

Scenario D
Swordsmen centric Blue vs Spearmen centric Red

Scenario E
Generic Blue vs Swordsmen and Knights Red

Model

Following is the description of the model and how the units fight.
Soldiers start moving forward (towards the center) in formation.
When one soldier meets an enemy soldier, they exchange hits of certain damage (DMG).
Hits lower health points (HP). When health reaches zero a soldier dies.
If a soldier survives an engagement he seeks nearest enemies.
If a soldier doesn’t meet an enemy till he reaches the center of battlefield he starts to seek nearest enemies.
Soldiers of the same army do not fight each other but are obstacles to one another.
When such collision occurs, the blocked soldier tries to find a different route, if there is none, he waits.

Units
The difference between armies is given by their color. The damage a unit gives to enemy is a random number between half of its DMG and full DMG.

Spearmen
HP: 5 , DMG: 3, Cost: 10
Swordsmen
HP: 10 , DMG: 2, Cost: 20
Knights
HP: 20 , DMG: 5, Cost: 50

Formations
Line - half of the unit type is north and the other south making a line facing towards the center, each unit type creates a different line
Square - same as line, but there are 2 lines per unit type (6 lines per army)
Wedge - an arrowhead looking formation pointing towards the center, each unit type creates its own wedge

Results

Table of results with every battles outcome:
Xlazl00 Results Table.PNG [1]

Screenshots of every battle before it starts (ZIP):
File:Xlazl00 Screenshots.zip [2]

Scenario A
Same composition of units and formations.
A1: line vs line => TIE

A2: square vs square => TIE

A3: wedge vs wedge => TIE

Scenario B
Same composition of units, different formations.
B1: line vs square => BLUE

B2: line vs wedge => RED

B3: square vs wedge => RED

Scenario C
Knights centric Blue vs Spearmen centric Red
C1: line vs line => RED

C2: square vs square => RED

C3: wedge vs wedge => RED

C4: line vs square => RED

C5: line vs wedge => RED

C6: square vs wedge => RED

C7: square vs line => RED

C8: wedge vs square => RED

C9: wedge vs line => RED

Scenario D
Swordsmen centric Blue vs Spearmen centric Red
D1: line vs line => RED

D2: square vs square => RED

D3: wedge vs wedge => RED

D4: line vs square => BLUE

D5: line vs wedge => RED

D6: square vs wedge => RED

D7: square vs line => RED

D8: wedge vs square => TIE

D9: wedge vs line => RED

Scenario E
Generic Blue vs Swordsmen and Knights Red
E1: line vs line => BLUE

E2: square vs square => BLUE

E3: wedge vs wedge => BLUE

E4: line vs square => BLUE

E5: line vs wedge => BLUE

E6: square vs wedge => RED

E7: square vs line => RED

E8: wedge vs square => BLUE

E9: wedge vs line => BLUE

Conclusion

Through the many battles it became clear that numbers and the ability to flank the enemy are the major deciding factors.
When even a stronger enemy is flanked, their chances of winning are quite slim.

Changing the cost/budget/health/damage of the units might change the results, but with how I set the model, having a wider (taller) formation and greater numbers is a sure way to victory.
However one cannot omit the factor of chance. Since the damage given is a random number (between half of damage and full damage), there might be few occasions when luck decides the battle.

Code

File:Xlazl00 battle sim.nlogo [3]