-
Notifications
You must be signed in to change notification settings - Fork 96
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
The battle formula does not work properly #450
Comments
Works in combat simulator. Why you don`t give us a screen for an example : Send 2000 Imperian with 20 level in Armoury to battle with 2000 Spearman with 20 level in Backsmith. Also send same 2000 Imperian level 0 in Armoury to battle with 2000 Spearman with level 10 in Blacksmith. And print us the screens. |
Most likely I was mistaken. But as for me, the formula does not work very well for calculating these bonuses. |
calculations, calculations....... @AL-Kateb would you care to investigate this math as well perhaps? :) |
I'm on it :) |
I tested the bonus from blacksmith and armory, according to the code, and according to my testing it is working fine, I did not check the hero bonus yet, but as for these two, the battle report matched the simulation 100%, even though it was a little bit off compared to the regular T4 legends simulator, but that's a different story. I think I know why your reports are different from the simulation, as I noticed you entered 2677 in the population, there is no village that can go that high in population, clearly you're assuming the population taken into account here is the account population, but this is inaccurate, the population used in calculation is the VILLAGE POPULATION not the account population, hence the real attack does not match the simulation. As a side note, while I was at it, I was transferring troops from one village to another (Same account), and apparently there's something wrong with that code, something is wrong with returning the troops, after a few actions I was able to change the home for my troops from one village to another! Which is a big issue, players can exploit this to produce troops from one village and send them all (change their home) to another, it is not as straight forward as this, some condition needs to be met, I am gonna check how to replicate this and see how to fix it, then I will get back to you. |
The general population is taken into account (the entire account), since there is an additional bonus of protection for weak players (when attacking the strong on the weak), this exists from the very first travian. I'll give an example: I'm top in the houses and the strongest player on the server. I have a village with a small population (in which all my main attacking troops) in order that the bonus in the attack is not taken into account. It will be stupid compared to players who started playing much later and much weaker than me. Perhaps this is the problem of calculating battles. Because of the fact that only the population of the village is attacked. Sorry for the bad english. I write through translator. In English, I could not find descriptions where it was said that the general population was taken into account, I could only find it in Russian. |
I completely understand your logic, and it makes perfect sense, but as far as I remember, I was in an argument with a friend of mine over this a couple of years ago, we tested the original Travian and we concluded that the population used here is the one of the village, not the entire account. Which as you said defeats the purpose of the bonus. But regardless of how original Travian behaves, the code as it stands today calculates the population of the village, not the account. I will do more research to check what population original Travian uses, and if it is the account's population, it is easy to edit the code to reflect that. |
I can give you a link to the Russian-language text, which describes completely how the simulator of strife works. You can read this through an interpreter. There is also an excellent resource where this calculator is available in an expanded form. It is recommended by a lot of people to use. There is an account of everything that is present in the game of travian. Also this calculator is available here. If you are interested in calculating, then I think you can ask Kirilloid himself what and how to count. I will also give a link to the calculation of formulas (also in Russian). If there are difficulties with the translation, I can help. http://travian.kirilloid.ru/warsim2.php - Advanced battles calculator (excellent resource), pay attention to the population (when hovering on the field is written what kind of population)
http://travian.wikia.com/wiki/Combat_simulator - on this site speak about Kirilloid |
I just tested on Travian, even though the result was not exactly as the simulator it was closer to the one where I put the whole population instead of just the village population, so you're right. I will modify the code accordingly |
http://t4.answers.travian.ru/index.php?aid=345 - it's in Russian, I could not find it on the English site (The battle system: formulas) I'll try to find it in English, but it's unlikely. |
A very nice debate guys, I appreciate the time you took to look into this :) |
@AL-Kateb you have not forgotten about this problem? :) |
@iopietro Please pay attention to this problem, it is very serious for the game process. |
Fixed in c3e2bae. @velhbxtyrj Let me know if i can close this issue. |
With the game calculator this perfectly matches. But a little different from that of another calculator :) |
Step 6: rounds to the nearest multiple of 0.0002, the formula should be 2 * round(1.8592 - pow($total_units, 0.015), 4); // 1.3268946071185956 K = 1.3268 |
Ok, I modified the formula from: round(2*(1.8592-pow($involve,0.015)),4); To: 2*round((1.8592-pow($involve,0.015)),4); ($involve = total units) But there's still a very little difference (without bonuses): Infantry attacking points = 1635870 Infantry defensive points = 805660 Total attack points = 2263950 K = 1,3634 Attacker final result = round((Total defensive points/Total attacking points)^K),8) = 0.42728169 Attacker losses: Defender losses: all troops are dead. |
I changed that formula with your formula and it seems to work great: $rdp = round($cap/$rap, 4)*($cdp) + round($ap/$rap, 4)*($dp) + 10;
|
Yes, wanted to say about the mix of infantry and cavalry, should be round to 4 decimal places. |
Ok, thanks, i modified it and now it works great, with all kinds of bonus (walls, residence/palace + base defense, troops upgrades) except for the morale bonus, i don't know how it should be approximated (i tried 3 decimal digits): If Total attacking points < Total defending points $moralbonus = round(min(1.5, pow($attpop / $defpop, 0.2 * ($rap / $rdp))), 3); else $moralbonus = round(min(1.5, pow($attpop / $defpop, 0.2)), 3); But it's slightly different than your simulator. |
Yes. I use a single expression with // here it's still a bonus, you multipy it the same way in all other parts of code.
$moralebonus = 1 / round(max(0.667, pow($defpop / $attpop, 0.2 * min(1, $rap / $rdp))), 3); Also I don't see from the code your shown, whether there's a check that moralebonus cannot be less than 1. |
Nice, it works perfectly :)! Yes, it's a huge handicap in certain cases. if($attpop > $defpop) {
$moralbonus = 1 / round(max(0.667, pow($defpop / $attpop, 0.2 * min(1, $rap / $rdp))), 3);
}else{
$moralbonus = 1.0;
} |
I've another question, what is the formula which determines the new level of a building partially demolished by catapults/rams (I can't find it in your guide)? For example (with no bonuses, no defenses, no losses): 10 catapults will bring a building from level 20 to level 18, how can i know that the new level must be 18? |
https://wbb.forum.travian.com/thread/75248-combat-system-formulas/ Actually I don't know why do you need super-precise calculations. My research is not ideal anyway. There are problems with stonemason or/and artifact. Formula gives big error for lower level buildings. |
Thanks! Yeah, I saw that chapter, but I haven't thought about that formula. |
Can be closed ? |
Not yet, there's still a discrepancy with the battle formula, when you attack a village with a wall and you damage/destroy it, the whole battle is recalculated, but battle results are a lot different than the original travian. |
Ahh ok |
I wanna ask if is counted in battle formula next attributes :
|
Maybe, create a separate issue for rams? Walls durability coefficients are:
|
Also you might be interested in |
@Shadowss, Yes, they're already implemented. @kirilloid, The only wrong formula is the one that recalculates the battle after the destruction/damaging of the walls, while the formulas that calculate how much a building have to be damaged (for rams and catapults) are slightly different than yours. |
@kirilloid Sorry in advance for the distrubance, but I would ask you some questions:
Thanks for the help! |
Technically now I have a solution, but it is incorrect with low wall levels and artefacts. |
Ok, thanks again :). |
In new simulator rams works just incorrectly |
Lol, nice, did you report it to the Travian's devs? |
Yes, I reported and they accepted it. |
Very good :). Thanks! I'll take a look on that commit. |
Combat system is ready to be digested. There are
The quirky logic for rams with two stages is here. BTW if you wonder how |
Thanks a lot :)! |
Please review the code in which the bonuses for the troops are summed up from the hero and from the Blacksmith and Armoury. According to my calculations, these bonuses are not taken into account.
There is a possibility that I made improvements through the admin panel. But it is unlikely that the problem arose because of this.
The text was updated successfully, but these errors were encountered: