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.


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).


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.

  • 1
    \$\begingroup\$ This is not a "small' game project \$\endgroup\$
    – Casanova
    Jun 15, 2018 at 23:05
  • 1
    \$\begingroup\$ So what is your actual question here? Dividing the battle into "turns" would be pretty simple -- just assign orders, click an end turn button, and have the AI do its thing. Or are you asking about AI? If so, what specific part of the AI? Or are you looking for rendering help? It's not entirely clear in your question. \$\endgroup\$
    – Jax
    Jun 17, 2018 at 3:29
  • \$\begingroup\$ My question is a finding a way to resolve the battle accounting all those variable. I'm not looking for a code, more of a logic (kind of a flowchart) \$\endgroup\$ Jun 17, 2018 at 18:10
  • 1
    \$\begingroup\$ In the current phrasing, it's a bit ambiguous what design goals an answer should try to achieve, since "an interesting way" is very subjective. I'd recommend reviewing the tag guidance for game-design questions, and editing the question to clearly specify a set of design criteria we can use to focus & evaluate possible solutions. \$\endgroup\$
    – DMGregory
    Jun 18, 2018 at 16:55
  • 1
    \$\begingroup\$ By what criteria should we judge "best"? If someone says health should decrease by (damage - armor) and someone else says health should decrease by (damage / armor), how do we determine which one is "best" for your game? You'll need to consider what specific outcomes you want, and which bad outcomes you don't want, and use those to develop clear criteria for proposed designs. \$\endgroup\$
    – DMGregory
    Jun 18, 2018 at 20:55

2 Answers 2


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.

  • \$\begingroup\$ I love your answer. I think you're right and creating attributes only confused me more and made it harder to think a way of calculating. Thanks for the answer, you gave me some ideas ! \$\endgroup\$ Jun 19, 2018 at 22:43

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.

  • \$\begingroup\$ I'm not aware of any of those board games but will soon look into it and give comments ! \$\endgroup\$ Jun 17, 2018 at 18:24
  • \$\begingroup\$ It would be easier if you could explain in detail how the method you mentioned works. I'm not familiar with the board games you mentioned and probably a lot others aren't either. You don't have to include code at all, as long as you give everyone a basic idea of how it should work. \$\endgroup\$ Jun 17, 2018 at 21:45
  • \$\begingroup\$ I've read some descriptions of the game you listed, but they seem to be too complex for what I'm looking for. Fights should be calculated with some player interaction, but the game does not resolve about controlling units and fighting but more on sending them at the right moment and countering the units of the other player \$\endgroup\$ Jun 18, 2018 at 0:30

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .