View Full Version : Featured: Combat system: formulas from Kirilloid

10 Feb 2013, 08:23 PM
Posted with Kirilloid's permission; the first english version (http://archive.forum.travian.com/showthread.php?132039-Combat-system-formulas) of this was posted on the .com forum. This is a copy from there (and I (Sam) will try to add a couple of links that complement it below).

This guide is entirely correct for T3.6. It has not been updated for T4.

This article is a translation of Kirilloid's combat tutorial in Russian (http://archive.forum.travian.ru/showthread.php?t=113586), which is in turn based on Combat Tutorial from Spanish wiki (http://travianwiki.com/wiki/Tutoriales:Combate) about Travian. Except that tutorial translation to Russian (http://archive.forum.travian.com.ua/showthread.php?t=12657), made by moderator on Ukrainian forum was also used.
Kirilloid would like to thanks two Travian players: [CWL] JacekW (http://archive.forum.travian.com/member.php?u=372556) and Antoshka (http://archive.forum.travian.ru/member.php?u=40227), who helped with huge armies formula and rams formula respectively.

Table of contents

1. Combat basics:

a) Offense and defense points
b) Raid / normal attack
c) Mixed infantry/cavalry

2. Boni:

a) Wall
b) Basic village's defense
c) Residence/Palace
d) Moralebonus
e) Upgrades

3. Misc:

a) Catapults
b) Rams
c) Espionage

10 Feb 2013, 08:25 PM
1.a. Offense and defense points

In Travian every unit has some levels of attack and defense. His offense points are his attack skill. The more offense points () unit has, there more enemies he will kill, when used in attack. The same is true for defense, except there're two types of it: 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 offense points of attacker, and defense points of defenders are taken into account. Attack with praetorians isn't effective despite their high defense value. Similarly clubswingers are worse units in defense. So use your troops wisely, only for purposes, they're well-suited. Otherwise you'll loose easily!

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

Players with Travian plus turned on could find 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 doesn't allow to take into account some factors like wall level, moralebnonus, leading to inaccurate results.

Since new Т3.6 version all players have the same full functionality, though.

There're several free combat simulators online. One of the most famous free warsim is mine. It has almost equal set of features as full in-game warsim and even more: convenient hero using, traps in Gallic village, battles with Natars, some artifacts and two targets for catapults.

Also my warsim have one useful feature: it "remembers in URL" which units you have input. If you copy URL from 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 "try it" link, so you'll be able to check example by yourself.

1.b. Raid / normal attack

Here I describe common combat w/o any boni like walls, upgrades, etc. As mentioned, we only take offense points from attacking army and defense points from defender's army.

First of all, 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 defender has 150 phalanx. As all 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 firstly normal attack, combat is going on till one side will be completely destroyed. We determine looser by comparing total offense and defense points. In our example 9000 (1) is more than 6000 (2), so defender will loose.

Winner's casualties are determined by next formula:

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

since defender looses this battle, looser_points = 6000 and winner_points = 9000.

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

54.43% of attackers will die. This fraction is the same for all different types of troops. Since 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.

try it (http://travian.kirilloid.ru/warsim.php#a:r1u50,,100#d:r3;r3u150#)

For raid formula changes a bit, losses will be:

100% · x / (100% + x)

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

This is losses of winner. Losses of another side will be (100% – winner's losses).

Consider another example: 100 imperians raiding 100 praetorians. Offense points (7000) are greater than defense ones (6500), so 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 loose 100% – 47.22% = 52.78% of his/her army, i.e. 53 praetorians.

try it (http://travian.kirilloid.ru/warsim.php#a:r1u,,100#d:r1;r1u,100#) and don't forget to choose "raid"

When greater armies taking part in combat, disposition changes a bit, bringing winner more casualties. Instead common formula (3), another one is used:

100% · (looser_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 (amount, and not their total upkeep).
1.2578 ≤ К ≤ 1.5: When total amount of units is one thousand or less K = 1.5, and if total amount is larger than 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 formula for losses will look like (attacker wins obviously): 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 attackers are cavalry troops, we use phalanx' 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.

try it (http://travian.kirilloid.ru/warsim.php#a:r3u,,,,,2000#d:r3;r3u1400#)

1.c. Simple combat with mixed infantry/cavalry

How we get defense points if attacker has both infantry and cavalry troops? Offense points are calculated the same way, but determining of defense points become non-trivial. In such case they 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 ones (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 loose all his/her troops:

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

Attacker will loose 20.77% of all of his/her own troops, which works out 100 · 0.2077 = 21 theutates thunders and 50 · 0.2077 = 10 swordsmen.

try it (http://travian.kirilloid.ru/warsim.php#a:r3u,50,,100#d:r1;r1u,100#)

10 Feb 2013, 08:26 PM
wall: gives extra bonus percent to defense, up to +80%
basic defense: adds some absolute value to defense, +10
palace: adds some absolute value to defense, up to +800
moralebonus: defender could have up to +50% bonus, if his account's total population is less than attacker's total population
upgrades: depends on stats of units, +20–30% for offense/defense average, but may be higher in some rare cases

2.a. Wall

Wall gives to defender extra percent-based bonus, which depends on race of wall:

1.020^L for Teutonic Earth wall;
1.025^L for Gallic Palisade;
1.030^L for Romans City wall.

where L is level of corresponding building.

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

Consider 150 swordsmen attacking 100 praetorians and 25 legionnaires behind 15th level 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 defender will win.
casualties = 100% · (9750 / 11490) ^ 1.5 = 78.17% which result in 78 praetorians and 20 legionnaires loss.
If there's no wall attacker would win. You may check it with combat simulator.

try it (http://travian.kirilloid.ru/warsim.php#a:r3u,150#d:r1w15;r1u25,100#)

2.b. Basic village defense

Even empty village with no fortification, has some small defense value, equals 10. Moreover, this value is also affected by other boni like 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 hardly 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 empty (I mean no troops) roman village a 5th level wall, 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 died phalanx.

try it (http://travian.kirilloid.ru/warsim.php#a:r3u2#d:r1w5;r1#)

Also there's one extra tricky moment. There's known phenomena, that one unit will always die against even empty village if he was not a strong cavalry. It could be described by basic defense, but if it's so, why one imperian with 70 offense points die and 2 phalanx with total 30 offense points don't die?
There's an extra check for every combat with 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) could be affected by moralebonus and unit's offense is counted considering upgrades.
You may read below in this section about exact formulas for upgrades and moralebonus.

2.c. Residence/Palace

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

2 · n^2 (6)

where n is level of 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.

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

Nevertheless, in 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 wall bonus as well as 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 residence couldn't be destroyed by regular troops, so attacker despite of his/her win, looses something and defender looses nothing.
100% · (98/225) ^ 1.5 ≈ 28.7% or 4 phalanx

try it (http://travian.kirilloid.ru/warsim.php#a:r3u15#d:r1w6R6;r1uU#)

2.d. Moralebonus

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

Accounts population is used! Though, on travianwiki.com is said, that population of "village" (aldea) is taken, it is wrong.

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

try it (http://travian.kirilloid.ru/warsim.php#a:r3u,500p2500#d:r1p1000;r1u,500#)

Moralebonus never goes higher than +50%, even if defender have zero population.

Note: Unoccupied oasis has its own population, which is 500. And moralebonus works for nature as usual. For occupied oases owner account's population is used.

//This formula is also applied to loyalty descending.

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

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

Such case could occur for example with WW village on small account, but 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 immense battle, use (5).
K = 2 · (1.8592 – 4000^0.015) = 2 · (1.8592 – 1.1325) = 2 · 0.7267 = 1.4534

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

try it (http://travian.kirilloid.ru/warsim.php#a:r3u,1500p2500#d:r1p1000;r1u,2500#)

2.e. Upgrades

This part of Travian combat mechanics have most various zoo of formulas spread over the Internet.

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

But 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 (http://archive.forum.travian.ru/showpost.php?p=118422&postcount=2).

As said on travianwiki.com, Nicolas Cirigliano ElCiri also obtained this formula, but it doen't said, when he did it. Nevertheless, since two persons obtained the same formula independently, so it counts in favor of last formula.

Note: Base upkeep is always used. Neither artifacts (http://help.travian.com/index.php?type=faq&mod=508), nor WW village (http://help.travian.com/index.php?type=faq&gid=40), nor Horse drinking trough (http://help.travian.com/index.php?type=faq&gid=41) could affect upgrades.

As always, consider some example.
20,000 clubswingers, 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 clubswingers.

try it (http://travian.kirilloid.ru/warsim.php#a:r2u20000U20#d:r1;r1u,12000#)

10 Feb 2013, 08:27 PM
Here gathered two most complicated parts of combat mechanics: catapults and rams.

3.a. Catapults

There's a formula, which determines amount of catapults, 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 common upgrade level made in blacksmith, except offense points, destruction capability of catapult is also affected by this upgrade level.
D – durability multiplier, combined effect of stonemason and artifacts. If none of them present, then D = 1
lvl – level of building;
morale – (attacker's population / defender's population)^0.3, also 100% ≤ morale ≤ 300%. And maximum is reached, when attacker's populations is 40 times larger than defender's population or more.
Х is amount of catapults came into action (sic!).

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 less catapults reach their firing position and will fire. Percent of catapults came into action is determined by next formulaes:

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 defense has overwhelming majority, only half of catapults alive as if it was raid, would work.

If amount of worked catapults is less than sufficient (8), then building will be demolished only partially or will not destroyed at all. Due to quadratic dependence higher levels are harder to destroy.
E.g., to destroy building from 99th to 98th level 25 (worked) catapults are required.
To destroy building from 19th to 18th level 5 (worked) 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 as long as WW buildings itself isn't affected by 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.

3.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 wall gives bonus in combat. Rams' destruction capability is unaffected by morale, and durability multiplier has one additional part, which depends on wall's tribe. Racial durability is listed below:

Roman city wall: 1
Gallic palisade: 2
Teutonic earth wall: 5

Firstly, rams virtually "demolish" wall to some intermediate level, which is used in later calculations.
This value is always and integer between initial and final wall level inclusive. Formula is very complicated and consists of two parabolas (http://en.wikipedia.org/wiki/Parabola) 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 explicit 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 have corresponding start wall level (see legend) and depict dependency between amount of worked rams and our intermediate level of wall.
Roman city wall with no stonemason and artifacts assumed.


After calculating this intermediate level, defense points are recalculated (another wall level => another wall bonus) and final result of battle, all losses are calculated using this new values.
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. (http://kirilloid.ru/warsim.php#a:r2u20000,,,,,5000,100#d:r1w20;r1u,15000#)
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 (http://travian.kirilloid.ru/warsim.php#a:r2u20000,2,108,,,5000#d:r1w9;r1u,15000#) yourself firstly!
100 rams = 108 axemen + 2 spearmen in offense points.
A-ha! 9th level of wall. That's how we could find this implicit value.

Destruction capability of rams is affected by upgrade level as well as for catapults (8).

3.c. Espionage

Finally, I 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 defender's losses. It is always 0%, also there're no immense battles, i.e. 1.5 is used in power for 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. This attributes are also affected by common formula for upgrades in blacksmith and armory (7). As could be saw from formula, Romans and Gallic spies receive greater bonus from upgrades. Combine it with horse drinking trough, and Romans 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.operation:
All "attackers" die. They would know nothing, and "defender" would know who came.
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.

10 Feb 2013, 09:07 PM
Additional context for the population / morale bonus: http://archive.forum.travian.co.uk/showthread.php?36992-Information-about-Population-based-Defence-Bonus

[Post for other helpful relevant stuff to be added into :p]

septimus ii
10 Feb 2013, 11:23 PM
I love you, and I will study this in detail in the morning

11 Feb 2013, 12:39 AM
lol, it's been on the .com forums for two and a half years :p (but it is absolutely critical reference)

septimus ii
11 Feb 2013, 06:34 AM
3.b. Rams
No upgrades and other boni are assumed for the sake of simplicity. Try it. (http://http://travian.kirilloid.ru/warsim.php#a:r2u20000,,,,,5000,100#d:r1w20;r1u,15000#)

There's a problem with that link. My browser tries to open http//travian... which doesn't work. Looking at the quote, it tries to open http://http://travian...

Also "This value is always and integer" should be "This value is always an integer" in the 2nd paragraph of 3.b. Rams :P

EDIT: Also, boni! Love it :happy: