Results 1 to 4 of 4

Thread: Combat System: Formulas

  1. #1
    Consul Wren's Avatar
    Join Date
    Aug 2008
    Location
    So Chi you thought I was bashful
    Posts
    7,076

    Default Combat System: Formulas

    This article is entirely the work of Kirilloid. It is a translation of his combat tutorial in Russian, which is in turn based on Combat Tutorial from the Spanish wiki about Travian. The tutorial translation into Russian, made by a moderator on the Ukrainian forum, was also used.

    The original English version of the thread is posted on the .com forum, I have reposted and cleaned the English slightly.

    Special thanks to two Travian players: [CWL] JacekW and Antoshka, who helped with huge armies and rams formulae, respectively.

    Table of contents
    1. Combat basics:
      1. Offense and defense points
      2. Raid/Normal attack
      3. Mixed infantry/cavalry
    2. Bonuses:
      1. Wall
      2. Basic village's defense
      3. Residence/Palace
      4. Morale bonus
      5. Upgrades
    3. Miscellaneous:
      1. Catapults
      2. Rams
      3. Scouts
    Last edited by Wren; 07-07-2010 at 10:13 PM.
    Retired.
    s3r2: Deakon - Nemesis/WFTW (winnarz!!) ...... s6r2: Anon - CD (lulz, failtrain)...... s1r4: Trogdor - 7RU


  2. #2
    Consul Wren's Avatar
    Join Date
    Aug 2008
    Location
    So Chi you thought I was bashful
    Posts
    7,076

    Default 1. Combat Basics

    1. Offense and defense points: unit strength
    2. Raid/Normal attack: standard combat
    3. Mixed infantry/cavalry: combat with complicated defense


    a. Offense and defense points

    In Travian, every unit has some strength in attack and defense. Its offense points are its attack skill. The more offense points () a unit has, the more enemies it will kill, when used in attack. The same is true for defense, except there are two types: defense against infantry () and defense against cavalry ().

    E.g. praetorians (65/35 def) are better against infantry, just as spearmen (35/60 def) are better against cavalry.

    In combat, only the offense points of attacker and defense points of defenders are taken into account. Attacking with praetorians isn't effective despite their high defense value. Similarly, macemen are worse on defense. So use your troops wisely, only for purposes they're well-suited. Otherwise you'll lose easily!

    Even with knowledge about units' stats, you cannot easily predict combat result, because the combat system is neither simple nor trivial.

    Players with Travian Plus turned on can find a rather good warsim in their rally point. This extended version allows them taking into account almost all values affecting battle result. Players w/o plus have limited version of combat simulator, which cannot take into account some factors like wall level or moralebonus, leading to inaccurate results. However, since the debut of Тravian version 3.6, all players have the same full functionality.

    There are several free combat simulators online. One of the most famous free warsims is mine. It has an almost equal set of features as the full in-game warsim plus a few: convenient hero use, traps in Gallic village, battles with Natars, some artifacts and two targets for catapults.

    Also, my warsim has another useful feature: it tracks which units you have input in the URL. If you copy the URL from the address bar and send it to somebody, after opening this URL, he or she will go to the simulator's page, where all troops are already set to the same values as you just done. All examples in this article will be accompanied by a "try it" link, so you'll be able to check the examples by yourself.


    b. Raid / normal attack

    Here, I describe common combat without any bonuses like walls, upgrades, etc. As mentioned, we only take offense points from attacking army and defense points from the defending army.

    First, count total offense and defense points. Total points are just amount of troops multiplied by corresponding unit stat.

    For instance, we attack with 100 imperians and 50 legionnaires. Their attack values are 70 and 40 respectively, so total offense points will be:

    100 · 70 + 50 · 40 = 9000 (1)

    Let the defender have 150 phalanx. As all the attacking troops in our example are infantry, we will use only defense against infantry, 40. In this case total defense points are:

    150 · 40 = 6000 (2)

    Consider first a normal attack, combat will continue until one side is completely destroyed. We determine the loser by comparing total offense and defense points. In our example, 9000 (1) is more than 6000 (2), so the defender will lose.

    Winner's casualties are determined by next formula:

    100% · (loser_points / winner_points)^1.5 (3)

    since the defender loses this battle, loser_points = 6000 and winner_points = 9000.

    100% · (6000 / 9000)^1.5 ≈ 100% · 0.5443 = 54.43%

    So 54.43% of attackers will die. This fraction is the same for all different types of troops. Since the attacker had 100 imperians and 50 legionnaires, he/she lost 100 · 0.5443 = 54.43 (54 rounded) imperians and 0.5443 · 50 = 27.21 (27 rounded) legionnaires.
    Amounts are rounded for each type of troops separately, not all up or all down.

    For raids, the formula changes a bit, losses will be:

    100% · x / (100% + x)

    where x is determined by formula mentioned above (3).

    This calculates the losses of the winner. The loser's casulaties will be (100% – winner's losses).

    Consider another example: 100 imperians raiding 100 praetorians. Offense points (7000) are greater than defense points (6500), so the attacker wins again.

    x = 100% · (6500 / 7000)^1.5 ≈ 89.479%

    100% · 89.479% / 189.479% ≈ 47.22%

    So 47.22% from 100 or just 47 imperians will die. Defender will lose 100% – 47.22% = 52.78% of his/her army, i.e. 53 praetorians.
    try it and don't forget to choose "raid"

    The winner's casualties formula is actually more complicated, but only applies when large armies take part in combat. The formula is a bit different and the winner takes more casualties. Instead of the standard formula (3), another one is used:

    100% · (loser_points / winner_points)^K (4)

    where K depends on how much soldiers were involved in combat. Really, large, immense battles should differ from small battles between hundreds of soldiers.
    К is determined by next formula:

    2 · (1.8592 – N^0.015) (5)

    where N is total amount of units taking part in battle (unit count, not their wheat upkeep).
    1.2578 ≤ К ≤ 1.5: When the total number of units is one thousand or less K = 1.5, and if the total number is larger than one billion (not exact) K = 1.2578.

    E.g., 2000 haeduans attacks 1400 phalanx. N = 2000 + 1400 = 3400

    К = 2 · (1.8592 – 3400^0.015) = 2 · (1.8592 – 1.1297) = 2 · 0.7295 = 1.459

    So the formula for losses (attacker wins obviously) will look like: 100% · (def_points / off_points)^1.459
    2000 haeduans have 2000·140 = 280,000 offense points
    1400 phalanx have 1400·50 = 70,000 offense points, since the attackers are cavalry troops, we will use phalanx's defense against cavalry.
    100% · (70,000 / 280,000)^1.459 = 100% · 0.25^1.459 ≈ 13.23%
    2000 · 13.23% ≈ 265, i.e. 265 haeduans die.


    c. Simple combat with mixed infantry/cavalry

    How do we calculate defense points if the attacker has both infantry and cavalry troops? Offense points are calculated the same way, but determining of defense points become non-trivial. In such a case, the defense points are calculated proportional to infantry/cavalry offense ratio.

    For instance, 100 theutates thunders and 50 swordsmen are attacking 100 praetorians.

    Offense points are equal: 100 · 90 + 50 · 65 = 9000 + 3250 = 12,250

    From more then twelve thousand offense points, cavalry part is 9000, and remainder is infantry part. We need to get proportion, so we divide:

    9000 / 12,250 ≈ 0.7346

    and do the same for infantry:

    3250 / 12250 ≈ 0.2654

    Therefore, 73.46% of offense points are cavalry offense points, and 26.54% infantry points (sum should be equal to 100%, if we are not mistaken).

    Then we "apply" this infantry/cavalry proportion to defender's troops. Praetorian has 65 def.points against infantry and 35 def against cavalry, i.e. total army's defense is:

    100 · 65 = 6500 (infantry)
    100 · 35 = 3500 (cavalry)

    To get real defense points we need to combine these points by proportion:

    0.7346 · 3500 + 0.2654 · 6500 = 2571.1 + 1725.1 ≈ 4296

    Therefore, praetorians will have 4296 defense points against such attacking army.

    Now we got offense and defense points so could apply formulas we already know: 12250 > 4296, meaning attacker will win and defender will lose all his/her troops:

    100% · (4296 / 12250)^1.5 ≈ 20.77%

    Attacker will lose 20.77% of all of his/her own troops, which works out 100 · 0.2077 = 21 theutates thunders and 50 · 0.2077 = 10 swordsmen.
    Retired.
    s3r2: Deakon - Nemesis/WFTW (winnarz!!) ...... s6r2: Anon - CD (lulz, failtrain)...... s1r4: Trogdor - 7RU


  3. #3
    Consul Wren's Avatar
    Join Date
    Aug 2008
    Location
    So Chi you thought I was bashful
    Posts
    7,076

    Default 2. Bonuses

    1. wall: gives extra bonus percent to defense, up to +80%
    2. basic defense: adds an absolute value to defense, +10
    3. residence/palace: adds some absolute value to defense, up to +800
    4. moralebonus: defender could have up to +50% bonus, if his account's total population is less than attacker's total population
    5. upgrades: depends on the stats of units, +20–30% for offense/defense average, but may be higher in some cases


    a. Wall

    The wall gives the defender an extra percentage bonus, which depends on the tribe of wall and its level:
    1.020^L for the Teutonic Earth wall;
    1.025^L for the Gallic Palisade;
    1.030^L for the Roman City wall.
    where L is level of corresponding building.

    E.g. a level 15 Roman city wall gives this bonus: 1.03^15 = 1.558 or 55.8%. At level 20 the bonus is a bit more than 80%. Therefore, the wall is a cornerstone in a village's defense.

    Consider 150 swordsmen attacking 100 praetorians and 25 legionnaires behind a level 15 city wall.
    Since swordsmen are infantry we will use only defense against infantry values.
    offense points will be: 150 · 65 = 9750
    defense points will be: 25 · 35 + 100 · 65 = 7375
    But we have a wall, which could greatly increase defense points: 7375 · 1.558 ≈ 11490

    11490 is greater than 9750, so in this example the defender will win.
    casualties = 100% · (9750 / 11490) ^ 1.5 = 78.17% which result in 78 praetorians and 20 legionnaires lost.
    If there's no wall, the attacker would win. You may check it with the combat simulator.


    b. Basic village defense

    Even an empty village with no fortification has a small defense value (10). Moreover, this value is also affected by other bonuses, like the wall. I was not completely honest with you, omitting this value in previous calculations. This was done for the sake of simplicity and because such small value rarely can affect result of average combat.
    E.g. 2 phalanx attacks empty village.
    offense is 15·2 = 30
    defense is 10
    2 · (10/30)^1.5 ≈ 0.385 which leads to no casualties.
    But if we build in an empty (I mean no troops) roman village a 5th level wall, the combat result will change.
    defense become 10·1.03^5 or 12 points
    2 · (12/30)^1.5 ≈ 0.506 which will be rounded to 1 and will mean 1 dead phalanx.

    Also there's one extra tricky aspect. There's a known phenomenon that one unit will always die against even an empty village, unless it was a strong cavalry unit. It could be described by basic defense. However, why does one imperian with 70 offense points die and 2 phalanx with total 30 offense points don't?
    That's because there's an extra check for every combat with a lone attacker.
    If unit's offense points are less than 83, unit will die disregarding of defender's losses. This check is applied for both attack types: normal attack/raid. Also, this value (83) is affected by moralebonus. The unit's attack strength is counted considering upgrades.
    You may read below in this section about exact formulas for upgrades and moralebonus.


    c. Residence/Palace

    Residence/Palace (we will use just "Palace" hereinafter, since both buildings are equal in their defending abilities) also help in combat, but its contribution isn't much. The Palace doesn't add percent-based bonus, but just adds some absolute defense value: e.g., on 20th level Palace will give only 800 defense points (both against infantry and cavalry). This addition is expressed by the following formula:

    2 · n^2 (6)

    where n is the level of the palace.

    As we could see, first levels give you nearly nothing. E.g., 1st level Palace adds only 2 points, 2nd level — 8pts, 3rd level — 18pts, etc.

    Against large armies, even 800 points is a tiny value, but against small squadrons it may be useful. If 10 imperians attack a village with a 20th level palace, they all die! (700 < 800+10). Of course, it is not easy to obtain the benefits from these buildings, since even a level 5 residence isn't very cheap. And when you have enough resources, armies are far stronger than 10 imperians.

    [Nevertheless, at the beginning of one Russian server I made top 50 in defense, using no troops! Of course, it was done due to residence's defense. Residence is especially effective against noobs attacking with phalanx or spearmen. =)]

    Hint: Defense given by palace and basic village defense is affected by the wall bonus just like troops.
    15 phalanx attacks village with 6th level residence and 6th level roman wall.
    offense is 15 · 15 = 225
    defense is (Residence + base defense) · Wall bonus = (2·6^2 + 10) · (1.03^6) ≈ 82 · 1.194 ≈ 98

    Attacker wins, but since the residence can't be destroyed by regular troops, the attacker loses something while the defender loses nothing.
    100% · (98/225) ^ 1.5 ≈ 28.7% or 4 phalanx


    d. Moralebonus

    This bonus is applied only to the defender when his/her population is less than population of attacker. For example, if attacker's population is 500, and defender's is 600, there will be no bonus. If the attacker's and defender's populations are 700 and 150 correspondingly, defender will receive a bonus.

    The account's population is used! Though some sources say it's the village's population, they are wrong.

    The formula for moralebonus is simple:
    M^0.2, where M is attacker's population / defender's population.

    E.g. 500 swordsmen from account with 2500 pop attacks 500 praetorians from account with 1000 pop.
    (2500/1000)^0.2 ≈ 1.2 or 20% bonus
    losses are 100% · (65·500 / 65·500·1.2) ^ 1.5 = 76.0% or 380 praetorians

    Moralebonus never goes higher than +50%, even if the defender has zero population.
    Note: Nature, the 'account' for unoccupied oases, has its own population (500). The moralebonus works for nature as usual. For occupied oases, owner account's population is used.

    Note: This formula is also applied to loyalty descending.

    Furthermore, if the attacker has fewer points than defender (including all bonuses, except moralebonus itself), and has more population, formula become a bit more complicated:

    moralebonus = M^{0.2·(offense points/defense points)}

    Such a case could occur, for example, with WW village on small account, although WW villages are completely unaffected by moralebonus.

    E.g. 1500 swordsmen from account with 2500 pop attacks 2500 praetorians on account with 1000 pop.
    offense points = 1500 · 65
    defense points = 2500 · 65
    As offense points are less then defense points and attacker's population is bigger, complicated formula is used:
    moralebonus = M^{0.2·(offense points/defense points)} = (2500/1000) ^ {0.2 · 1500/2500)} = 2.5 ^ 0.12 ≈ 1.116

    Also total amount of troops (4000) taking part in battle is more than 1000, so it is an immense battle, use (5).
    K = 2 · (1.8592 – 4000^0.015) = 2 · (1.8592 – 1.1325) = 2 · 0.7267 = 1.4534

    The defender wins and his/her losses are: 100% · (offense points / defense points·moralebonus) ^ K
    losses = 100% · (1500·65 / (2500·65 + 10)·1.116) ^ 1.4534 = 40.57% or 1014 praetorians


    e. Upgrades

    This part of Travian combat mechanics has a huge slew of formulas spread over the Internet.

    BASE_VALUE · 1.015^LEVEL
    BASE_VALUE · (1 + 0.015 · LEVEL)
    (А · UPKEEP + 0.015 · BASE_VALUE) · LEVEL / 2, where А is a constant ≈ 0.641627,

    But the full correct formula is a bit more complicated:

    improved_value = BASE_VALUE + (BASE_VALUE + 300 · UPKEEP / 7) · (1.007^LEVEL – 1) (7)

    It is correct for every stat (offense, def. against infantry, def. against cavalry) and for any unit.
    [I've obtained this formula in summer 2007 and published it on ru-forum.]

    Note: Base upkeep is always used. Neither artifacts, the WW village, nor the Horse Drinking Pool affects upgrades.

    As always, consider an example:
    20,000 macemen, fully upgraded in blacksmith (lvl20) attacks 12,000 non-improved praetorians.
    According to formula (7)
    improved_value = 40 + (40 + 300 · 1 / 7) · (1.007^20 – 1) ≈ 40 + (40 + 42.8571) · 0.149713 = 52.4048

    offense points will be: 20,000 · 52.4048 = 1,048,096
    defense points will be: 12,000 · 65 = 780,000

    total amount of troops is 32,000, so according to (5) immensity of battle will be
    K = 2 · (1.8592 – 32,000^0.015) = 2 · (1.8592 – 1.1684) = 2 · 0.6908 = 1.3816
    losses will be 100% · (780,000 / 1,048,096) ^ 1.3816 = 66.486% or 13297 macemen.
    Retired.
    s3r2: Deakon - Nemesis/WFTW (winnarz!!) ...... s6r2: Anon - CD (lulz, failtrain)...... s1r4: Trogdor - 7RU


  4. #4
    Consul Wren's Avatar
    Join Date
    Aug 2008
    Location
    So Chi you thought I was bashful
    Posts
    7,076

    Default 3. Miscellaneous

    1. Catapults: damage buildings, but only some act
    2. Rams: damage the wall, but only some act
    3. Espionage: how scouts work


    Here are the two most complicated parts of combat mechanics: catapults and rams.

    a. Catapults

    There's a formula that determines the amount of catapults that are enough to completely destroy any building of certain level:

    X = round{(morale · (lvl^2 + lvl + 1) / (8 · U / D)) + 0.5} (8)

    U – catapult's upgrade, U = round(200 · 1.0205^{upgrade_level})/200;
    Yes, it is the standard upgrade level in the blacksmith. Both the offense points and destruction capability of catapult are affected by this upgrade level.
    D – durability multiplier, combined effect of stonemason and artifacts. If none of them are present, then D = 1
    lvl – level of building.
    morale – different from 2d. (attacker's population / defender's population)^0.3, also 100% ≤ morale ≤ 300%. The maximum is reached when the attacker's populations is 40 times larger than defender's population.
    Х is the number of catapults that act.

    In the heat of battle, while slow catapults go to their firing position, part of them could be damaged and negated before discharge. Of course, attacker's troops are protecting their siege machines, but the more advantage defending troops have, the fewer catapults reach their firing position and will fire. Percent of catapults that act is determined by the next formulae:

    X = (offense points / defense points)^1.5 (9)
    if X > 1, then this part will be = 1 – 0.5 / X
    if X < 1, then this part will be = 0.5 · X
    Amount of catapults isn't rounded.

    In simple terms, this formula could be described as follows:
    If there's no defense, catapults will work at almost 100% of their potential.
    In case of almost balanced forces only half of catapults will work.
    If the defense has an overwhelming majority, only half the number of catapults that would survive if it was raid would work.

    If the amount of working catapults is less than sufficient (8), then the building will be partially demolished at most. Due to quadratic dependence, higher levels are harder to destroy.
    E.g., to destroy building from level 99 to level 98, 25 (working) catapults are required.
    To destroy building from level 19 to 18, 5 (working) catapults are required, or 5 times less.
    However, if village is affected by unique durability artifact, making buildings 5x more durable, it will be wiser to attack WW with catapults because the WW building itself isn't affected by the durability artifact.

    When you set 2 targets for catapults, their force is divided between two targets equally.

    When you target some kind of building and there're several such buildings in destination village (e.g.: cropland, warehouse, etc.), catapults will always hit building of certain type with highest level.
    Should the catapults fire on random, it will be truly random and the above rule will be ignored.


    b. Rams

    When there's no defense, rams destroy walls almost as well as catapults destroy buildings; but when there's some defense things become much more complicated since the wall gives bonus in combat. The rams' destruction capability is unaffected by morale, and durability multiplier has one additional part, which depends on wall's tribe. Durability, by tribe, is listed below:
    Roman city wall: 1
    Gallic palisade: 2
    Teutonic earth wall: 5

    First, rams virtually "demolish" wall to some intermediate level, which is used in later calculations. This value is always an integer between the initial and final wall level (inclusive). The formula is very complicated and consists of two parabolas so I will provide only total "virtual durability":

    DDR = DC · { L·(L+1)/8 + 5 + (24.875 + 0.625·L2)·L2/2 } (10)
    L2 = round{ (L – 1) / 2 }

    L — starting level of wall.
    DDR — Demolition Damage of Rams, equals percent of worked rams (9).
    DC — Durability coefficient, depends on tribe, stonemason, rams' upgrades and durability artifact.

    Again, this is not the value you can see in combat report. However, you could find out this value by log. I'll show how to obtain this intermediate value later.

    There's a chart with 3 series below. Each series uses a corresponding start wall level (see legend) and depicts the dependency between amount of working rams and the intermediate wall level.
    We will use a Roman city wall with no stonemason and artifacts.



    After calculating this intermediate level, defense points are recalculated (another wall level => another wall bonus) and the final result of battle is determined. All losses are calculated using this new value.
    Consider next battle:
    20,000 clubswingers, 5000 Teutonic knight and 100 rams attacks
    15,000 praetorians behind 20th level roman wall.
    No upgrades and other boni are assumed for the sake of simplicity. Try it.
    Wall was demolished completely, what else do we need?

    Let's replace rams with some other infantry troops and find out, which wall level should be set to get the same losses. Who said "zero"? Try it yourself!
    100 rams = 108 axemen + 2 spearmen in offense points.
    A-ha! A level 9 wall. That's how we could determine this intermediate value.

    Destruction capability of rams is affected by upgrade level, the same as catapults (8).


    c. Espionage

    Finally, I will describe simulation for scouts (I mean recon. troops for all tribes). Formula for "combat" between scouts is the same as for common attack (3), except for the defender's losses. It is always 0%. Also, there are no immense battles, i.e. 1.5 is used for K in any battle.

    Instead of offense and defense points, scouting and counter-scouting points are used. Base values are 35 and 20 respectively for any tribe. These attributes are also affected by common formula for upgrades in blacksmith and armory (7). As could be seen from the upgrade formula, Romans and Gallic spies receive greater bonus from upgrades. Combine it with horse drinking trough and Roman's Equites Legatti are the best. For classic servers, Teutonic scouts are considered the best, since speed isn't a great deal for recon. operations.

    Possible results of recon. operations:
    All "attackers" die. They would know nothing, and "defender" would know who visited.
    None of "attackers" die. "Defender" won't know he/she was scouted.
    Note: This could happen even if "defender" have some small amount of scouts.
    In all other cases both sides will receive reports with corresponding info.
    Retired.
    s3r2: Deakon - Nemesis/WFTW (winnarz!!) ...... s6r2: Anon - CD (lulz, failtrain)...... s1r4: Trogdor - 7RU


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •