wishing fix
rnd_otyp_by_namedesc() had an off by one error when choosing which matching item to return, making it impossible to successfully wish for the Amulet of Yendor, always yielding the plastic imitation. n == 2, maxprob == 2 prob = rn2(maxprob); => 0 or 1 i = 0; while (i < n - 1 && (prob -= ... + 1) > 0) i++; always exited the loop on the first test of the condition because subtracting 1 from 0 or 1 never yielded a result greater than 0. It's still suboptimal: "amulet of yendor" should find an exact match and should never return "cheap plastic imitation of amulet of yendor" from the partial match. I think biasing the choice among multiple candidates based on their generation probabilities only makes sense when all the candidates are within the same class. If scroll of light occurred in 5% of scrolls and spellbook of light occurred in 10% of spellbooks (both percentages pulled out of thin air), having "light" get a 2 out 3 chance to be a spellbook doesn't seem right because scrolls are four times more likely than spellbooks (in most of the dungeon; books aren't randomly generated at all on the rogue level or in Gehennom).
This commit is contained in:
@@ -2488,7 +2488,8 @@ char oclass;
|
||||
long prob = rn2(maxprob);
|
||||
|
||||
i = 0;
|
||||
while (i < n - 1 && (prob -= (objects[validobjs[i]].oc_prob + 1)) > 0)
|
||||
while (i < n - 1
|
||||
&& (prob -= (objects[validobjs[i]].oc_prob + 1)) >= 0)
|
||||
i++;
|
||||
return validobjs[i];
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user