Two Army Battle Simulator

Two Army Battle Simulator

I'm currently developing a small game project on unity (with purpose of learning C#) where each player controls a base and can build buildings, do research, build units, pretty much the basis.
I arrived where the each player may send their army of different sizes to attack the other player's base. Each army can be composed of three different unit types, being Infantry, Archers and Cavalry. They work as a kind of rock-paper-scissors, meaning infantry beats cavalry given equal resources (horses cost more than warriors, so 1 on 1, cavalry still wins), cavalry beats archers and finally, archers beats infantry given a long distance.
Every unit has different stats, health, damage, armor and range (mouvement speed exists but I do not want to consider it in battle).
I want the battle to be split in rounds and that it is not because you have less soldiers than the other player that you should loose. What would be an interesting way of solving the battle taking account of all those variables ?
Sort of solution I have is to give each player some decisions as to what would he do first (either archers attack first, cavalry waits for flanks, etc.) but nit seems too complicated and I still don't know how each parameter should be calculated. Should luck be included too ?
Thanks,
luisarcher.

EDIT
After comments, here is my question more clearly. What would be the best way to simulate a battle of two armies composed of those units (with their weaknesses and strengths) where both armies would loose troops in X amount of rounds ?
I want the results to evolve with time so the players can react to it (either retreat, or maybe small commands). I'm not looking for a piece of code, but more of a guideline of how should I use every attribute of each unit (health, damage, armor and range).

EDIT2
By best, I mean an interesting resolution where each unit feels unique to be built and where players won't feel forced to build only 1 kind of units since it has the most cost effective hp/damage per amount of resource spent. I'm thinking of something like all those web-based strategy games like Grepolis, Tribal Wars, oGame, etc. 

Solutions/Answers:

Answer 1:

Keep in mind that this is a design question, and you can handle it in many ways. There will be no “best” or “correct” option; there may, however, be bad design decisions.

Your fundamental design error is that you seem to have started from the wrong end in your design process: you already have attributes for your units, but have no concept for how the fights will be handled. Now you’re stuck trying to think of how to use all these attributes in an interesting way, without considering whether or not all of them are really necessary. A better way would be to first come up with an idea of how you want a fight to be handled, and add unit attributes as needed.

Keeping that in mind, let’s completely ditch all your current attributes. Now let’s think about how a fight can be fought between two armies so that:

  1. archers hold advantage over infantry, infantry holds advantage over cavalry, and cavalry holds advantage over archers

  2. the fight has to last a finite amount of turns, in between which the player can make strategic decisions to alter the fight flow

The first question you should ask yourself is how many rounds you expect the fight to last. Two more or less equal sized armies will need to have a victor determined in that specified amount of turns.

In order to fulfill the requirement #1, you need to make sure that certain unit type deals more damage (or receives less damage) to another.

This is how the aforementioned browser strategy games like Tribal Wars handle the “rock-paper-scissors” balancing: each unit type has a universal Attack attribute, and then three different attributes for defense: General Defense against infantry, Cavalry Defense and Archer Defense. During the fight, the system calculates the total offensive strength of each unit type in the attacking army, and then divides the defending troops into groups to fight against said groups.

So for example, let’s say you have 1000 Infantry, 500 Cavalry and 500 Archers. The total offensive strength will look as follows:

  1. 1000 * Infantry Offense = Total Infantry Offensive Strength
  2. 500 * Cavalry Offense = Total Cavalry Offensive Strength
  3. 500 * Archer Offense = Total Archer Offensive Strength

The defense troops are then divided into three groups proportional to each of the three offensive groups, and the system uses their Defense attributes against the specific group they’re fighting against to calculate the losses on each side. For instance, if the offensive strength of the Infantry group is 5000, and the defensive strength of the first defending group is 5000, then each side loses 50% of their units; however, if the values are 10000 to 1000, then the attacking side loses only one unit per ten defenders killed.

Then the only thing you need to do is to repeat the process for each round of the fight. Now you need to come up with the attribute values and balance them out in a way that would allow your fights to last for certain amount of rounds on average. Come up with a few scenarios to test it with, and adjust the values according to how you want your game being played.

Answer 2:

You could try using a “Command and Colours” technique, as used in “Memoir ’44” and “Battlelore” boardgames. It give both players a few orders to play in a turn and changes which orders each turn. This would also have to have a turn-based gameplay game. One order could be “5 Cavalry” or “All Infantry”. This would limit each turns complexity but overall increase strategies. Would orders they get is luck based though.

Unfortunately, I don’t now how to code this though.

Hope this helps.

References