Myriarch for Java

Myriarch Combat Simulator is now available in an enhanced Java version, with a JavaFX user interface. I removed the download of the original .NET version as it was fairly rudimentary; I had already planned moving to Java at the time and so didn’t bother properly finishing that version.

Overview

Myriarch attempts a precise real-time simulation of pre-gunpowder tactical warfare. Specifically, tens of thousands of soldiers are simulated as independent physical objects, advancing in 100 msec increments. The simulation comprises the following subsystems and features:

  • Physics — Movement with acceleration and turning, distinction of facing and direction, semi-elastic collisions that can cause damage, and accumulation of “push mass” throughout the ranks when two phalanges clash.
  • Combat — Weapon cooldown for repeated attacks, hit chance based on target size, partial body armor, shields that respect facing, and combat bonuses against colliding or routed units.
  • Morale — Gained or lost from successful attacks, then averaged among nearby friendly units, reduced by nearby hostile units that aren’t routed. May generate mass panics or rally fleeing troops.

Now I’m not Electronic Arts (nor even an artist) so the graphics are quite rudimentary and abstract. The screenshot below shows the overstrength Theban left crashing into the Spartan right at the battle of Leuctra 371 BC, the included demo scenario.

Leuctra Clash

Implementation

Myriarch ships as three Java SE 8 JAR files.

  • My Tektosyne library for computational geometry provides geometric primitives and the QuadTree that facilitates locating units on the battlefield.
  • A core library provides all simulation algorithms, as well as a console runner for testing and benchmarking. This library requires only the Compact 2 profile of Java 8 (and Tektosyne requires only Compact 1), so you could use the simulation algorithms on restricted platforms.
  • Finally, the GUI application you see above is written in JavaFX. The JavaFX Canvas turned out to be fast enough for ten thousand simple SVG paths rendered in real time, at least on my system.

See my longer Implementation Notes for more details. That post dates from the original .NET release but was updated for the current Java version.

Motivation

There are plenty of games covering ancient warfare on a per-soldier basis, most famously the Total War series. However, none of them (to my knowledge) attempt an accurate simulation. Not only is the total number of soldiers typically far too low due to technical restrictions, but they are organized into totally independent units widely separated from each other. This may look and play more interesting than reality, but in reality ancient troops were almost always organized into long unbroken battle lines. Hans Delbrück’s Geschichte der Kriegskunst covers this subject in some detail.

Essentially, it would have been foolish to isolate blocks of soldiers. They would have been threatened by easy flanking; reliably commanding them was nearly impossible; and your typical Greek citizen-soldier had to be tightly packed into a formation to be useful. There might be reserves that could be committed, or small elite troops such as Alexander’s hypaspists that could operate independently, but that was all. As for Roman legions, Delbrück argues convincingly that they were simply organizational units. For combat even the Romans would still form up as a single battle line.

So Myriarch was built in an attempt to capture the likely physical reality of ancient battles, complete with the enormous weight that deep files of soldiers transfer to the front ranks. At Leuctra the elites of Thebes and Sparta, clashing head on, were probably roughly equal in numbers and quality. The Thebans won easily anyway because they were pushed by an extra 38 ranks of soldiers. Myriarch simulates that, as well as flanking, although that is barely used in Leuctra. (Historically the Spartan allies fled immediately; in our simulation, they turn to fight head-on until dispersed.)

Non-Goals

Myriarch was designed as a simulation, not a game. At present the user cannot enter any simulation commands at all, only meta-commands to rewind or save the simulation etc. Initial and conditional division commands are fixed as part of the scenario. It is an interesting question of realism which commands should even be available.

Battlefield communication was quite unreliable before radio. Battles would mostly play out according to previously fixed commands, combined with autonomous decisions by individual soldiers or their nearby officers. Committing reserves is one realistic top-level command that should be made available to the user. Otherwise, my principle goal for Myriarch is improving the presently quite limited unit AI, rather than adding game-like interactivity.

4 thoughts on “Myriarch for Java”

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.