digitrev
Member
So I've noticed that several locations have items without drop rates. I've decided that this just will not do, and hence that I should start doing some item spading. This is the script I'm using to collect data:
I'll be dropping the result JSON strings into the Bayes tester (http://ludonomicon.com/kol/CoffeeBayes.html) and start spading missing data. Now, since I'd like this data to ultimately make its way into KoLmafia proper, I was wondering if folks could tell me if there's any obvious mistakes I've made in the code.
Also, I'll only be satisfied for a given drop rate once it passes 95% belief in the Bayes tester (using the Full Range analysis). I'll gladly submit all my raw data so that folks can verify it.
Code:
// where , fight, drop, drate, ndropped, times it happened
int [location, monster, item, float, int] timesDropped;
string fName = "dropSpading.txt";
string bayesJSON(int[float, int] toJSON){
string buff = '[';
foreach drate in toJSON{
buff += '{counts: [';
int maxDropped = 0;
foreach nDropped in toJSON[drate]{
if (nDropped > maxDropped) maxDropped = nDropped;
}
for n from 0 to maxDropped{
buff += toJSON[drate, n].to_string() + ', ';
}
buff += '], boost: ' + drate.to_string() + '},';
}
buff += ']';
return buff;
}
void makeJSONs(){
string[location, monster, item] json;
if (file_to_map(fName, timesDropped)){
print("map loaded");
} else {
abort("map not loaded");
}
foreach l, m, i in timesDropped{
json[l, m, i] = bayesJSON(timesDropped[l, m, i]);
}
if (map_to_file(json, "bayesjson.txt")){
print("map saved");
} else {
print("map not saved");
}
}
void main(string sloc, int advLen){
if (file_to_map(fName, timesDropped)){
print("map loaded");
} else {
abort("map not loaded");
}
location loc = sloc.to_location();
for i from 1 to advLen{
int[item] idrops;
foreach i, mon in loc.get_monsters(){
foreach it in mon.item_drops(){
idrops[it] = it.available_amount();
}
}
float drate = numeric_modifier("item drop");
adventure(1, loc);
monster mon = last_monster();
foreach it in mon.item_drops(){
int dropped = it.available_amount() - idrops[it];
timesDropped[loc, mon, it, drate, dropped] += 1;
//print("item spade," + drate + "," + it.to_string() + "," + last_monster().to_string() + "," + dropped.to_string());
}
}
if (map_to_file(timesDropped, fName)){
print("map saved");
} else {
print("map not saved");
}
}
I'll be dropping the result JSON strings into the Bayes tester (http://ludonomicon.com/kol/CoffeeBayes.html) and start spading missing data. Now, since I'd like this data to ultimately make its way into KoLmafia proper, I was wondering if folks could tell me if there's any obvious mistakes I've made in the code.
Also, I'll only be satisfied for a given drop rate once it passes 95% belief in the Bayes tester (using the Full Range analysis). I'll gladly submit all my raw data so that folks can verify it.
Last edited: