Question on randomness
Moderator: Forum Moderators
As i understand, bat_stats.chance_to_hit_defender is also integer (50 for 50% chance). So there is no rounding error.ott wrote:Yes and no. From src/statistics.cpp:drachefly wrote:Does EV take into account the death of units partway through?and this is applied for each swing actually attempted. If a skirmish is cut short because one of the combatants dies, no additional amounts are added to the EV.Code: Select all
attacker_stats().expected_damage_inflicted += bat_stats.damage_defender_takes * bat_stats.chance_to_hit_defender; defender_stats().expected_damage_taken += bat_stats.damage_defender_takes * bat_stats.chance_to_hit_defender;
***
However, there is an important inaccuracy in the current code. All the stored values are integers, so if an elf doing 5-4 damage at 50% chance to hit attacks and kills an opponent with 10hp after 3 swings, the current code will say it did 10hp while EV was 7.5, but the code will calculate EV as 6. So EV will always be underestimated. I can't think of a quick fix for this right now while we are in feature freeze, so this will likely have to wait for 1.0.
Knowledge is Power.
Ellestar is correct. The expected values are stored as the real expected values multiplied by 100. They are divided by 100 immediately before display. There is no floating point math going on at all (except the division by 100.0 immediately before display).
David
David
“At Gambling, the deadly sin is to mistake bad play for bad luck.” -- Ian Fleming
I get somewhat confused.
To be honest, I do not know what you are all talking about.
I expected, that for each attack a random number between 0 and 1 is calculated (evenly distributed) and if the number is higher than the percentage to hit its a miss, if its lower its a hit.
But if I understand your discussions about expectation values correctly, the calculation is not done in this easy way.
Can anyone explain to me, how it is done, and why?
regards Michael
To be honest, I do not know what you are all talking about.
I expected, that for each attack a random number between 0 and 1 is calculated (evenly distributed) and if the number is higher than the percentage to hit its a miss, if its lower its a hit.
But if I understand your discussions about expectation values correctly, the calculation is not done in this easy way.
Can anyone explain to me, how it is done, and why?
regards Michael
Re: Question on randomness
I discovered Murphy's Law pretty much applies together with the probabilities. Something like "probabilities always work one miss against you", i have also founs this is a somewhat reliable proposition to make decisions out of.Olm wrote:I really like Wesnoth, but there is one thing that really annoys me, and i am not even sure if rightly so.
I cannot get rid of the impression, that the odds in fights are not what they are shown to be.
Don't get me wrong, I understand how chance works, and that it is perfectly possible to get 4 hits from one unit with only 40 % chance to hit. But I have the impression, this happens far to often for my enemy, and far to seldom for me. I know, that its easy to get such an impression, and I did not do a statistically significant study on this, but I tried it once with a mage, reloading again and again to see how often he would hit and I really did not get the impression that he hits more than two out of three times.
Thus my question: Are the chances tweaked, e.g. for increasing difficulty for the harder difficulty levels?
If you assure me, that this is not done, I will perform an analysis to either ease my mind, or find a bug.
Cuyo Quiz,where madness meets me 
Turn on, tune in, fall out.
"I know that, but every single person nags about how negative turin is; it should be in the FPI thread "Turin should give positive comments" =)"-Neorice,23 Sep 2004

Turn on, tune in, fall out.
"I know that, but every single person nags about how negative turin is; it should be in the FPI thread "Turin should give positive comments" =)"-Neorice,23 Sep 2004