Explaining Battle Calculations

Discuss anything related to warbarons.

Explaining Battle Calculations

Postby Enigmatic » Tue Oct 11, 2011 7:53 am

I just received this battle log and i still wonder how this translates?

Battle roll:72
Attacker chance:(30.77%)
Defender chance:(69.23%)
Defenders: HeroDreadKnight is injured

Battle roll:63
Attacker chance:(30.77%)
Defender chance:(69.23%)
Attackers: Dwarf is injured

Battle roll:90
Attacker chance:(30.77%)
Defender chance:(69.23%)
Defenders: HeroDreadKnight is slayed

Specially how the roll is playing in here. Warpedia stats that there are 2 rolls for a single combat round (at least!) and there might be redone rounds when hit/hit and of course miss/miss.
Enigmatic
 
Posts: 25
Joined: Sat Oct 01, 2011 12:38 am

Re: Explaining Battle Calculations

Postby piranha » Tue Oct 11, 2011 9:42 am

If the dice roll is lower than the defender chance he hits

We had the system described in the warpedia but to make the battles compute faster we changed it to a more efficient calculation that gives the same result.

Code: Select all
function dice2($attstr, $defstr)
    {
        $atohit = $attstr / $this->dice;
        $dtohit = $defstr / $this->dice;


        $apropability = 1 - $atohit;
        $dpropability = 1 - $dtohit;

        $ahitchance = $atohit*$dpropability;
        $dhitchance = $dtohit*$apropability;

        $attackertohit = ($ahitchance / ($dhitchance+$ahitchance))*100;
        $defendertohit = ($dhitchance / ($dhitchance+$ahitchance))*100;


        $roll = mt_rand(1,100);

        if($roll <= $defendertohit)
        {
            return array("defhit", $attackertohit, $defendertohit, $roll);
        }

        elseif($roll > $defendertohit)
        {
            return array("atthit", $attackertohit, $defendertohit, $roll);
        }

    }
User avatar
piranha
Site Admin
 
Posts: 1188
Joined: Fri Feb 12, 2010 9:44 pm

Re: Explaining Battle Calculations

Postby Enigmatic » Thu Oct 13, 2011 12:52 am

Thanks for clearing up. :D

That means in translation: probabilities for hitting (of both sides) are calculated and and then a dice of 1d100 is thrown. Dice-value represents (in a percentual scale) the battle favor. Higher is better for the attacker, lower better for the defender. Threshold is the defender chance. Is the roll higher than the defender chance then the defender is hit and vice versa.

I'd still prefer a 2 dice roll to negate effect of extreme rolls. (I had a battle with 2 consecutive dice roll of just 5 thereforce trashing a quite good unit) however this should be fine.
Enigmatic
 
Posts: 25
Joined: Sat Oct 01, 2011 12:38 am

Re: Explaining Battle Calculations

Postby KGB » Thu Oct 13, 2011 3:39 am

Enigmatic,

This is the 2 dice roll system.

The odds calculator (not shown) just works out what the odds for each unit to hit are using the 2 dice roll system. Then it translates that into percentages (Unit1/(Unit1+Unit2) and Unit2/(Unit1+Unit2) which are used in the formula Piranha showed below.

The reason the 2 Dice aren't used is because the game now simulates 1000 battles to compute the % chance to win (so that the 90% rule can be used to discard extreme results that you mentioned) and all those no-hit rolls (when neither side hits with 2 dice) were making battles take 30 seconds to finish. This speeds things up dramatically although a large battle can still take 4-5 seconds before you see a result.

KGB
KGB
 
Posts: 3030
Joined: Tue Feb 16, 2010 12:06 am

Re: Explaining Battle Calculations

Postby ams16 » Thu Oct 13, 2011 6:00 pm

What's the 90% rule?
ams16
 
Posts: 94
Joined: Sat Jan 22, 2011 4:06 am

Re: Explaining Battle Calculations

Postby KGB » Fri Oct 14, 2011 2:46 am

Ams16,

The 90% rule is used to smooth out the dice rolls and prevent crazy outcomes like 1 Lt Infantry beating 5 Lt Infantry or a Hero + Dragon losing to a scout.

By that I mean that once your win% > 90%, you are guaranteed to win the battle (if you lose, the result is thrown out and the battle re-done until you win). At the same time, if your win% <10% you can't win the battle (and again if you do, it's re-done until you lose).

So basically the game calculates the odds for every possible outcome in a battle and then chops off 10% at either end so that the middle 80% (the most likely outcomes) are used.

KGB
KGB
 
Posts: 3030
Joined: Tue Feb 16, 2010 12:06 am

Re: Explaining Battle Calculations

Postby ams16 » Fri Oct 14, 2011 11:17 pm

Ugh. I don't like that rule. Random is as random does. You should be able to lose 90% battle, 10% of the time. Otherwise, it's not 90%.
ams16
 
Posts: 94
Joined: Sat Jan 22, 2011 4:06 am

Re: Explaining Battle Calculations

Postby piranha » Sat Oct 15, 2011 6:08 am

At first that it might seem bad to remove 10% like that because its possible to be sure of winning. But what happened before that rule was armies of seven 1 - 2 turn units including a hero suddenly lost to a single 1 turn unit.

You can lose games because of a bad roll. You still can but its much better than it was in beta2.

In a beta3 game on Illuria I started as horse lords. Took the two cities to the sides and then went for the one north of me. A wolf rider guarded it. I attacked with a minotaur and 2 light cav (something like that). 3 times in a row having 88 - 89% chance to win and lost all three times including my start hero and minotaurs on all three attacks. Its still possible to lose due to bad luck :-).

But no more of those completely game breaking results.
User avatar
piranha
Site Admin
 
Posts: 1188
Joined: Fri Feb 12, 2010 9:44 pm

Re: Explaining Battle Calculations

Postby ams16 » Mon Oct 17, 2011 3:57 am

I still disagree strongly.

90% should mean that you lose 10% of the time. It happens. Luck happens.

I don't know what happened in your B3 game, but in general, losing a 90% battle three times in a row will happen 1/1000 times. Oh well.

Since you are actually rerolling with battles where the 90% loses, on average, you end up getting BETTER results when you have a 90% battle than you would with just random results.

Say you have a 90% battle with 8 units vs. 2 units. It rolls such that all 8 units die, but on only 1 of the 2 units die. You have the computer reroll the results. This time, 2 units of the 8 survive, and the 2 die. That's the one that gets used. That happens in every 90% battle. It is MUCH better to go in with 90% than it is to go in with 89%, and that's just wrong.

This is really just wrong.
ams16
 
Posts: 94
Joined: Sat Jan 22, 2011 4:06 am

Re: Explaining Battle Calculations

Postby Yahtzee » Mon Oct 17, 2011 4:40 am

Yeah ... why not just say 100% then? I don't get it.
Yahtzee
 
Posts: 25
Joined: Tue Oct 11, 2011 12:29 am

Next

Return to Game discussion

Who is online

Users browsing this forum: No registered users and 27 guests

cron
Not able to open ./cache/data_global.php