So I know this thread is old, but there is a bug in get_smash_yield():
Code:
float [item] get_smash_yield(item it)
{
float [item] resultf;
float sum = 0;
int[item] resulti;
if (!is_smashable(it))
return resultf;
string tier = get_smash_tier(it);
float [string] element_type = get_smash_element(it);
resulti = get_related(it,"pulverize");
foreach thing in resulti
{
sum = sum + resulti[thing];
}
foreach thing in resulti
{
resultf[thing] = resulti[thing] / sum; // BUG HERE
}
return resultf;
}
The bug is noted above. To find the expected yield of each thing, the line marked above should actually be
resultf[thing] = resulti[thing] / 1000000.0; // This is correct
This properly accounts for multiple returns. In addition, the computation of the variable "sum" is unnecessary.
For example, the item "Armgun" yields 4 nuggets 50% of the time, and 1 wad 50% of the time.
Working out the math, that means that the average yields should be:
E(#Twinkly nuggets) = 0.5*4=2
E(#Twinkly wads) = 0.5*1=0.5
This is properly reflected by the get_related ash function:
Code:
> ash get_related($item[armgun],"pulverize");
Returned: aggregate int [item]
twinkly nuggets => 2000000
twinkly wad => 500000
I'm not sure where else this bug occurs, because I only use a few functions.