Hello,
I was reading the online documentation when I found this page: "Maths of Freeciv". As a physics student I couldn't resist and I began reading.
I found that the win_chance function does not handle the following case correctly (looking at the source code confirmed that) :
Suppose we have a combat between an ultra-weak defender and an ultra-strong attacker. I mean att_P_lose1 = 0 (the attacker will win every single round). It is obvious such an attacker will win.
But, because each term is multiplied by att_P_lose1 = 0, the function concludes the attacker has no chance at all of winning (because 0 + 0 + ... + 0 = 0 ).
Am I wrong ?
Thank you for making such a good piece of software, and for using it ! (and also for reading me)
Louis
Edit : win_chance is at common/combat.c: 230
Is win_chance correct ?
Re: Is win_chance correct ?
Given that I remember always seeing 99% win chance for attacker against defense 0 units, I doubted your theory.
Note that the very first term (before the loop) is not multiplied by att_P_lose1:
double binom_save = pow(def_P_lose1, (double)(def_N_lose - 1));
double accum_prob = binom_save; /* lr = 0 */
// def_P_lose1 would be 1.00 here so no matter def_N_lose, accum_prob = binom_save = 1 (100%)
Note that the very first term (before the loop) is not multiplied by att_P_lose1:
double binom_save = pow(def_P_lose1, (double)(def_N_lose - 1));
double accum_prob = binom_save; /* lr = 0 */
// def_P_lose1 would be 1.00 here so no matter def_N_lose, accum_prob = binom_save = 1 (100%)
Re: Is win_chance correct ?
Thanks for your reply,
As you said, I didn't see accum_prob was 1 at the beginning. (As written in the doc, that is unclear because 0^0 is undefined...)
I experimented and got results that showed the function was correct. I'm sorry for the noise
Louis
As you said, I didn't see accum_prob was 1 at the beginning. (As written in the doc, that is unclear because 0^0 is undefined...)
I experimented and got results that showed the function was correct. I'm sorry for the noise
Louis