Iustus
King
Ok, this time I think I did find a bug, I am not sure how significant it is, but it is a true bug.
(I added the comment). Well, the fact is that some times these two add to 999, not 1000. This means that in some cases the wrong percentage is being used (but it is only slightly off).
Looking at the code for combat, which uses the defender odds only (it rolls 0-999, if the number is in the iDefenderOdds range, then the defender wins, otherwise the attacker wins), this means the attacker gets the round off, so it should be:
or in the case of the actual code:
This would fix this (minor) round off error. It is possible that this has a large accumilation effect, since it can be added in quite a few times if there are a lot of possible first strikes involved. I would have to see the numbers to be convinced though.
Whether it is a very minor bug, or a big one, it does seem to me to be a real bug in getCombatOdds
-Iustus
Code:
iDefenderOdds = ((1000 * iDefenderStrength) / (iAttackerStrength + iDefenderStrength));
iAttackerOdds = ((1000 * iAttackerStrength) / (iAttackerStrength + iDefenderStrength));
[COLOR="SeaGreen"]// note: iDefenderOdds + iAttackerOdds = 1000[/COLOR]
(I added the comment). Well, the fact is that some times these two add to 999, not 1000. This means that in some cases the wrong percentage is being used (but it is only slightly off).
Looking at the code for combat, which uses the defender odds only (it rolls 0-999, if the number is in the iDefenderOdds range, then the defender wins, otherwise the attacker wins), this means the attacker gets the round off, so it should be:
Code:
iDefenderOdds = ((1000 * iDefenderStrength) / (iAttackerStrength + iDefenderStrength));
iAttackerOdds = 1000 - iDefenderOdds ;
[COLOR="SeaGreen"]// note: iDefenderOdds + iAttackerOdds = 1000[/COLOR]
or in the case of the actual code:
Code:
iDefenderOdds = (((GC.getDefineINT("COMBAT_DIE_SIDES") * iDefenderStrength) / (iAttackerStrength + iDefenderStrength));
iAttackerOdds = (GC.getDefineINT("COMBAT_DIE_SIDES") - iDefenderOdds;
[COLOR="SeaGreen"]// note: iDefenderOdds + iAttackerOdds = (GC.getDefineINT("COMBAT_DIE_SIDES")[/COLOR]
This would fix this (minor) round off error. It is possible that this has a large accumilation effect, since it can be added in quite a few times if there are a lot of possible first strikes involved. I would have to see the numbers to be convinced though.
Whether it is a very minor bug, or a big one, it does seem to me to be a real bug in getCombatOdds
-Iustus