Medieval Battle Simulation

From Simulace.info
Revision as of 11:35, 20 January 2019 by Xlazl00 (talk | contribs)
Jump to: navigation, search

Introduction

This model simulates a medieval battle between two armies (blue vs red).

Problem definition

The main goal is to find which formations and compositions of units work against which.
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 5 times. More runs would ensure higher certainty of results.

Scenario A
Same composition of units and formations.
A1: line vs line A2: square vs square A3: wedge vs wedge

Scenario B
Same composition of units, different formations.
B1: line vs square B2: line vs wedge B3: square vs wedge

Scenario C
Knights centric Blue vs Spearmen centric Red
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
Swordsmen centric Blue vs Spearmen centric Red
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
Generic Blue vs Max number of units Red
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

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

Conclusion

Code