[guide] Building Formulas

DeletedUser

Guest
You can use the interface php to get info about units and buildings for each server. If you wanted the info for world 1:

building info: "http://us1.tribalwars.net/interface.php?func=get_building_info"
unit info: "http://us1.tribalwars.net/interface.php?func=get_unit_info"

You can also find it on the twstats website.
buildings: "http://us.twstats.com/us1/index.php?page=buildings"

timber cost of a building[wood]*[wood_factor]^([level of the building] - 1)
clay cost of a building[stone]*[stone_factor]^([level of the building] - 1)
iron cost of a building[iron]*[iron_factor]^([level of the building] - 1)
amount of villagers a building uses[pop]*[pop_factor]^(level of the building] - 1)
duration of creation, for lvl 1 and 2[build_time]*1.18*[build_time_factor]^(-13)
duration of creation, for lvl 3+[build_time]*1.18*[build_time_factor]^(level - 1 - 14/(level-1))


In the help page, if you look at the total points, you will see a pattern. Each successive level is worth about 1.2 times the points of the previous level. Knowing this, you can calculate how many points a building is worth.
Code:
points of a building = [points of the building at level 1]*1.2^([level of the building] - 1), rounded to the nearest integer

The amount of population a farm supports follows a similar pattern. Each successive level supports about 1.172103 times the population of the previous level (I'm not sure what the exact value the game uses is, but it's pretty darn close)
Code:
population the farm supports = 240*1.172103^([level of the farm] - 1), rounded to the nearest integer
similar thing for the warehouse
Code:
Capacity = 1000*1.2294934^([level of the warehouse] - 1), rounded to the nearest integer
and the timber camp, clay pit, and iron mine (except at level 0, they make 5 resources an hour):
Code:
production per hour = [30]*1.163118^([level of the building] - 1)
and the hiding place:
Code:
hidden resources = 150*(4/3)^([level of the hiding place] - 1)
and the wall:
Code:
factor for defending troops = 1.037^[level of the wall]

If the market is less than level 10, the number of merchants is equal to the market level.
If the market is level 10 or higher:
Code:
number of merchants = (market level - 10)^2 + 10


The time it takes for something to be built depends on the level of the building it's made in. All times are in seconds.

Buildings are constructed and expanded in the village headquarters. Multiply the duration of creation by the time factor of your village headquarters to get the actual amount of time it takes to make a building. The exact time factor is equal to 1.05^(-[level of the village headquarters])
Code:
actual build time = [duration of creation]*1.05^(-[level of the village headquarters])

Units are recruited in the barracks, stables, workshop, and academy. Multiply the build_time by the time factor of the building the unit's made in to get the actual amount of time it takes to recruit that unit. The exact time factor is equal to 2/3*1.06^(-[level of the building]).
Code:
actual build time of a unit = 2/3*[build_time]*1.06^(-[level of the building the unit is created in])

spear fighter - made in barracks
swordsman - made in barracks
axeman - made in barracks
archer - made in barracks
scout - made in stable
light cavalry - made in stable
mounted archer - made in stable
heavy cavalry - made in stable
ram - made in workshop
catapult - made in workshop
nobleman - made in academy

Research is done in the smithy. Multiply the duration of a research by the time factor of the smithy. The exact time factor is equal to 1.1^(-[level of the smithy]).

On a ten tech world, each successive research level takes 1.75 times the duration of the previous level. On a 3 tech world, each successive research level takes 3 times the duration of the previous level.

As far as I can tell, these are the research times for level 1 techs, without the smithy time modifier:
spear - 3960 seconds
sword - 5940 seconds
axe - 6930 seconds
archer - 3960 seconds
scout - 3960 seconds
lcav - 8910 seconds
m.archer - 9900 seconds
hcav - 9900 seconds
ram - 7910 seconds
catapult - 9900 seconds

The game speed is a setting that changes the durations (you can see what it's set to on the World Settings section of the statistics page. Multiply all research times by 1/[game speed].
 
Last edited by a moderator:

DeletedUser

Guest
Version 8 changed the way construction times are determined. I just hadn't gotten around to updating this thread.

Every upgrade of the village headquarters causes buildings to be constructed 5% faster than before. That formula is still correct.

The change is this:

Code:
----Pre-Version 8----
duration of creation= [build_time]*[build_time_factor]^(level of the building] - 1)

----Post-Version 8----
duration of creation, for lvl 1 and 2 = [build_time]*1.18*[build_time_factor]^(-13)
duration of creation, for lvl 3+ = [build_time]*1.18*[build_time_factor]^(level - 1 - 14/(level-1))

Low-leveled buildings had their construction times drastically reduced, allowing the game to pick up speed earlier on and keep players engaged.

With this change, some low-leveled buildings like the rally point, academy, and church, which already had balanced construction times, would have been able to be constructed too quickly. So their base [build_time]s were increased, meaning there's little change in their actual construction times from version 7.
 

DeletedUser3313

Guest
Hi,

I've been doing a bit of excel on these formulas, but am not getting the same results as the running game for W64. I'm having trouble with the build times above level 3.

Any advice? I have applied the modifiers for the HQ levels.

Thanks in advance.
 

DeletedUser3313

Guest
Hold on, I may have made an error.

Note to self - don't operate heavy spreadsheets while drinking.
 

DeletedUser

Guest
Thanks, guys. This is extremely helpful to a newb like myself.
 

DeletedUser7447

Guest
Even though tribal wars is still on version 8, it seems the formulas has changed. Does anybody know what current formulas for build times are?
 

DeletedUser7902

Guest
Yes in config now is buildtime_formula = 2. Formula has been changed. I am waiting for a new formula
 

fiszupl123

New Member
Reaction score
1
I did a little research, maybe it will help someone. It's not an exact way, but very close. 60% of results are world accurate at 1x speed. If we assume an acceptable error of 1 second, the accuracy is 80%. For 4 seconds it's already 95%. For 8 seconds, that's 99%. For a 2x world, the error (99%) is 3 seconds. So the results are very good.

The formula was determined by calculating coefficients based on in-game construction times. I collected over 5000 samples for different worlds.
As my formula is not exact, you can use it to calculate two values that may differ.
Minimum and maximum value.
You are 100% sure that the real time must be within this range. In 60% of cases (world speed 1x), the minimum and maximum times will be the same.


It doesn't work for the snob academy

public static double[] minFactors = new double[]{0.007552, 0.007554, 0.161452, 0.500304, 0.956705, 1.50814, 2.158727, 2.923994, 3.826395, 4.89346, 6.158127, 7.6594, 9.443313, 11.565152, 14.088409, 17.089235, 20.657818, 24.900529, 29.944887, 35.938469, 43.057794, 51.514313, 61.552976, 73.471276, 87.607613, 104.384149, 124.274164, 147.857654, 175.814335, 208.947195, 248.202977}; public static double[] maxFactors = new double[]{0.007563, 0.007554, 0.161464, 0.500341, 0.956724, 1.50822, 2.158737, 2.924042, 3.826454, 4.89347, 6.158187, 7.659612, 9.443947, 11.566535, 14.088492, 17.09006, 20.658207, 24.90262, 29.945052, 35.938917, 43.063512, 51.518197, 61.556709, 73.47302, 87.61126, 104.384391, 124.279226, 147.860972, 175.819992, 208.951312, 248.219817}; public double factorMin(int level) { return minFactors[level]; } public double factorMax(int level) { return maxFactors[level]; } public long calcTimeMin(Building building, int mainLevel) { double durationOfCreation = (building.build_time / World.speed) * factorMin(building.level) * Math.pow(1.05, -mainLevel); double time = Math.round(durationOfCreation); if(time < building.min_build_time / World.speed) time = building.min_build_time / World.speed; return (long) time; } public long calcTimeMax(Building building, int mainLevel) { double durationOfCreation = (building.build_time / World.speed) * factorMax(building.level) * Math.pow(1.05, -mainLevel); double time = Math.round(durationOfCreation); if(time < building.min_build_time / World.speed) time = building.min_build_time / World.speed; return (long) time; }

Parameters:

World.speed - Current world speed. For example 1x (1.0), 2x(2.0), 1.75x(1.75)

building.build_time - Build time for world 1x
If you take the value from http://us1.tribalwars.us/interface.php?func=get_building_info
It is already calculated.
For example:
World 63 (speed 1.65)
form link: <build_time>3636.3636363636</build_time>
(building.build_time / World.speed) = 6000 / 1.65 = 3636.3636363636

building.level - If we upgrade the building from 15 to 16 level then building.level=15.

mainLevel - The current level of headquarters.

building.min_build_time - While in the game on the headquarters website. By typing the script into the console: "BuildingMain.buildings" The values of the minimum build time will be shown.

{ "main": { "id": "main", "image": "buildings/main.png", "max_level": 30, "min_level": 1, "image_levels": [ 5, 15 ], "req": [], "require": [], "wood": 113, "stone": 102, "iron": 88, "pop": 1, "wood_factor": 1.26, "stone_factor": 1.275, "iron_factor": 1.26, "pop_factor": 1.17, "build_time": 10, "build_time_factor": 1.2, "build_time_min": 10, "points": 10, "level": "1", "level_next": 2, "link": "/game.php?village=8663&amp;screen=main", "can_build": true, "big_image": "main1", "wood_queue_factor": 113, "stone_queue_factor": 102, "iron_queue_factor": 88, "build_link": "/game.php?village=8663&amp;screen=main&amp;action=upgrade_building&amp;id=main&amp;type=main&amp;h=d753abab", "name": "Ratusz", "text": "W ratuszu można rozbudowywać budynki lub budować nowe. Im wyższy stopień rozbudowania ratusza, tym szybciej są budowane budynki. Przy ratuszu na minimum 15 poziomie możesz burzyć inne budynki w wiosce (jej poparcie musi wynosić 100%)." }, "place": { "id": "place", "image": "buildings/place.png", "max_level": 1, "min_level": 0, "image_levels": [], "req": [], "require": [], "wood": 13, "stone": 51, "iron": 38, "pop": 0, "wood_factor": 1.26, "stone_factor": 1.275, "iron_factor": 1.26, "pop_factor": 1.17, "build_time": 78, "build_time_factor": 1.2, "build_time_min": 10, "points": 0, "level": "1", "level_next": 2, "link": "/game.php?village=8663&amp;screen=place", "can_build": true, "big_image": "place1", "wood_queue_factor": 13, "stone_queue_factor": 51, "iron_queue_factor": 38, "complete": true, "build_link": "/game.php?village=8663&amp;screen=main&amp;action=upgrade_building&amp;id=place&amp;type=main&amp;h=d753abab", "name": "Plac", "text": "Na placu stoją wszystkie wojska. Tutaj możesz wydawać rozkazy i przesuwać wojska." }, "wood": { "id": "wood", "image": "buildings/wood.png", "max_level": 30, "min_level": 0, "image_levels": [ 10, 20 ], "req": [], "require": [], "wood": 50, "stone": 60, "iron": 40, "pop": 5, "wood_factor": 1.25, "stone_factor": 1.275, "iron_factor": 1.245, "pop_factor": 1.155, "build_time": 10, "build_time_factor": 1.2, "build_time_min": 10, "points": 6, "level": "0", "level_next": 1, "link": "/game.php?village=8663&amp;screen=wood", "can_build": true, "big_image": "wood1", "wood_queue_factor": 50, "stone_queue_factor": 60, "iron_queue_factor": 40, "build_link": "/game.php?village=8663&amp;screen=main&amp;action=upgrade_building&amp;id=wood&amp;type=main&amp;h=d753abab", "name": "Tartak", "text": "Tutaj drwale obrabiają drewno ścięte w okolicznych lasach, które jest potrzebne zarówno do budowy wioski, jak i do uzbrojenia wojsk. Im wyższy stopień rozbudowania tartaku, tym większa produkcja drewna." }, "stone": { "id": "stone", "image": "buildings/stone.png", "max_level": 30, "min_level": 0, "image_levels": [ 10, 20 ], "req": [], "require": [], "wood": 65, "stone": 50, "iron": 40, "pop": 10, "wood_factor": 1.27, "stone_factor": 1.265, "iron_factor": 1.24, "pop_factor": 1.14, "build_time": 10, "build_time_factor": 1.2, "build_time_min": 10, "points": 6, "level": "0", "level_next": 1, "link": "/game.php?village=8663&amp;screen=stone", "can_build": true, "big_image": "stone1", "wood_queue_factor": 65, "stone_queue_factor": 50, "iron_queue_factor": 40, "build_link": "/game.php?village=8663&amp;screen=main&amp;action=upgrade_building&amp;id=stone&amp;type=main&amp;h=d753abab", "name": "Cegielnia", "text": "W cegielni pracownicy wydobywają glinę na rozbudowę wioski. Im wyższy stopień rozbudowania cegielni, tym więcej wydobywa się gliny." }, "iron": { "id": "iron", "image": "buildings/iron.png", "max_level": 30, "min_level": 0, "image_levels": [ 10, 20 ], "req": [], "require": [], "wood": 75, "stone": 65, "iron": 70, "pop": 10, "wood_factor": 1.252, "stone_factor": 1.275, "iron_factor": 1.24, "pop_factor": 1.17, "build_time": 10, "build_time_factor": 1.2, "build_time_min": 10, "points": 6, "level": "0", "level_next": 1, "link": "/game.php?village=8663&amp;screen=iron", "can_build": true, "big_image": "iron1", "wood_queue_factor": 75, "stone_queue_factor": 65, "iron_queue_factor": 70, "build_link": "/game.php?village=8663&amp;screen=main&amp;action=upgrade_building&amp;id=iron&amp;type=main&amp;h=d753abab", "name": "Huta żelaza", "text": "W hucie żelaza Twoi pracownicy wytapiają żelazo. Im wyższy stopień rozbudowania huty, tym więcej żelaza można przy jej pomocy pozyskiwać." }, "farm": { "id": "farm", "image": "buildings/farm.png", "max_level": 30, "min_level": 1, "image_levels": [ 10, 20 ], "req": [], "require": [], "wood": 59, "stone": 53, "iron": 39, "pop": 0, "wood_factor": 1.3, "stone_factor": 1.32, "iron_factor": 1.29, "pop_factor": 1, "build_time": 10, "build_time_factor": 1.2, "build_time_min": 10, "points": 5, "level": "1", "level_next": 2, "link": "/game.php?village=8663&amp;screen=farm", "can_build": true, "big_image": "farm1", "wood_queue_factor": 59, "stone_queue_factor": 53, "iron_queue_factor": 39, "build_link": "/game.php?village=8663&amp;screen=main&amp;action=upgrade_building&amp;id=farm&amp;type=main&amp;h=d753abab", "name": "Zagroda", "text": "Zagroda wyżywia Twoich pracowników i wojska. Bez rozbudowania zagrody Twoja wioska nie może się rozrastać. Im wyższy stopień rozbudowania, tym więcej mieszkańców może być wyżywionych." }, "storage": { "id": "storage", "image": "buildings/storage.png", "max_level": 30, "min_level": 1, "image_levels": [ 10, 20 ], "req": [], "require": [], "wood": 76, "stone": 64, "iron": 50, "pop": 0, "wood_factor": 1.265, "stone_factor": 1.27, "iron_factor": 1.245, "pop_factor": 1.15, "build_time": 10, "build_time_factor": 1.2, "build_time_min": 10, "points": 6, "level": "1", "level_next": 2, "link": "/game.php?village=8663&amp;screen=storage", "can_build": true, "big_image": "storage1", "wood_queue_factor": 76, "stone_queue_factor": 64, "iron_queue_factor": 50, "build_link": "/game.php?village=8663&amp;screen=main&amp;action=upgrade_building&amp;id=storage&amp;type=main&amp;h=d753abab", "name": "Spichlerz", "text": "W spichlerzu są umieszczane surowce. Im wyższy stopień rozbudowania, tym więcej możesz umieszczać w nim surowców." }, "hide": { "id": "hide", "image": "buildings/hide.png", "max_level": 10, "min_level": 0, "image_levels": [], "req": [], "require": [], "wood": 63, "stone": 75, "iron": 63, "pop": 0, "wood_factor": 1.25, "stone_factor": 1.25, "iron_factor": 1.25, "pop_factor": 1.17, "build_time": 13, "build_time_factor": 1.2, "build_time_min": 10, "points": 5, "level": "1", "level_next": 2, "link": "/game.php?village=8663&amp;screen=hide", "can_build": true, "big_image": "hide1", "wood_queue_factor": 63, "stone_queue_factor": 75, "iron_queue_factor": 63, "build_link": "/game.php?village=8663&amp;screen=main&amp;action=upgrade_building&amp;id=hide&amp;type=main&amp;h=d753abab", "name": "Schowek", "text": "W schowku można chować surowce, tak, żeby przeciwnik nie mógł ich zrabować. Nawet zwiadowcy przeciwnika nie mogą się dowiedzieć, ile surowców ukryto w schowku." } }

Code:
min_build_time:

wall 240
barracks 10
farm 10
hide 10
iron 10
main 10
market 10
place 10
statue 10
stone 10
storage 10
wood 10
watchtower 30
smith 10
snob ??
stable 10
garage 10
Code:
build_time:

wall 3600.0
barracks 1800.0
farm 1200.0
hide 1800.0
iron 1080.0
main 900.0
market 2700.0
place 10860.0
statue 1500.0
stone 900.0
storage 1020.0
wood 900.0
watchtower 13200.0
smith 6000.0
snob 586800.0
stable 6000.0
garage 6000.0
Regards
 
Last edited:
Top