I know I can script
foreach it in $items[]
if (item_type(it)=="food") do something
to check my inventory for food, but is there a way to narrow it to the quality of food (i.e. Awesome, Epic) without manually looking up each item on the wiki and hard-coding each into the script?
int[item][int][int][string] food;
file_to_map("fullness.txt", food);
foreach item,fullness,level,adventures in food {
int avgadventures = 0;
if(contains_text(adventures,"-")) {
string[int] advs = split_string(adventures,"-");
avgadventures = (advs[0].to_int() + advs[1].to_int()) / 2;
} else {
avgadventures = adventures.to_int();
}
if(fullness != 0) {
print(item.to_string() + " " + avgadventures/fullness);
}
}
int[item][int][int][string] food;
file_to_map("fullness.txt", food);
foreach item,fullness,level,adventures in food {
foreach it in $items[] {
if (it == item) {
float avgadventures = 0;
if(contains_text(adventures,"-")) {
string[int] advs = split_string(adventures,"-");
avgadventures = (advs[0].to_float() + advs[1].to_float()) / 2;
} else {
avgadventures = adventures.to_float();
}
if(fullness != 0) {
print(item.to_string() + " " + avgadventures/fullness);
}
}
}
}
float[item] foodbyquality(float minadvsperfull) {
int[item][int][int][string] food;
float[item] returnfood;
file_to_map("fullness.txt", food);
foreach item,fullness,level,adventures in food {
if(fullness != 0) {
float avgadventures = 0;
if(contains_text(adventures,"-")) {
string[int] advs = split_string(adventures,"-");
avgadventures = (advs[0].to_float() + advs[1].to_float()) / 2;
} else {
avgadventures = adventures.to_float();
}
if (avgadventures >= minadvsperfull) {
returnfood[item] = avgadventures;
}
}
}
return returnfood;
}
void main() {
float[item] foodvalues = foodbyquality(20);
foreach item in foodvalues {
print(item.to_string() + " " + foodvalues[item]);
}
}
I can't believe I never saw it, bump bump bump! excellent idea!
int[item][int][int][string] food;
file_to_map("fullness.txt", food);
foreach it,fullness,level,adventures in food {
if(fullness != 0) {
float avgadventures = 0;
if(contains_text(adventures,"-")) {
string[int] advs = split_string(adventures,"-");
avgadventures = (advs[0].to_float() + advs[1].to_float()) / 2;
} else {
avgadventures = adventures.to_float();
}
string desc = visit_url("desc_item.php?whichitem=" + it.to_item().descid);
string type = "Unknown";
if (contains_text(desc,"<font color=blueviolet>(EPIC)</font>")) {
type = "EPIC";
} else if (contains_text(desc,"<font color=blue>(awesome)</font>")) {
type = "awesome";
} else if (contains_text(desc,"<font color=green>(good)</font>")) {
type = "good";
}else if (contains_text(desc,"<b>food (decent)</b>")) {
type = "decent";
}else if (contains_text(desc,"<font color=#999999>(crappy)</font>")) {
type = "crappy";
}else if (contains_text(desc,"<font color=green>?</font><font color=red>?</font><font color=#999999>?</font>")) {
type = "???";
} else {
}
print(it.to_string() + " " + avgadventures/fullness + " " + type);
}
}
3vi1 pr0n m4nic0tti 2.75 awesome
a dance upon the palate 3.0 crappy
abominable snowcone 1.75 decent
ancient frozen dinner 1.5 decent
ancient unspeakable fruitcake 1.5 decent
angel-food cake 1.0 crappy
antique packet of ketchup 1.0 crappy
asparagus lo mein 4.1666665 awesome
asparagus stir-fry 3.0 good
astral hot dog 2.0 ???
babycakes 1.0 crappy
badass pie 4.5 awesome
balaclava baklava 1.25 decent
ballroom blintz 1.8333334 decent
banana 1.0 crappy
banana cream pie 3.0 good
banana milkshake 3.5 awesome
banana-frosted king cake 1.0 crappy
Bash-Ōs cereal 1.0 crappy
bat haggis 2.25 decent
bat wing chow mein 5.0 awesome
bat wing kabob 1.75 decent
bat wing stir-fry 3.3333333 awesome
bat-shaped Crimboween cookie 4.5 awesome
bean burrito 1.8333334 decent
beautiful soup 3.0 good
beefy fish meat 2.5 good
beer basted brat 4.8333335 awesome
bell-shaped Crimbo cookie 4.5 awesome
KoLmafia declares world peace.
(crappy) Gives no more than 1 adventure per fullness
(decent) Gives more than 1 and at most 2 adventures per fullness
(good) Gives more than 2 and at most 3 adventures per fullness
(awesome) Gives more than 3 and at most 5 adventures per fullness
(EPIC) Gives more than 5 adventures per fullness
I'm confused about the second foreach loop! is it necesary?
You are looping through the whole inventory with every iteration of fullness.txt until you find the item again?
foreach it in $items[...] {
foreach fullness, level, adventures in food[it] {
foreach it in $items[] {
if((item_type(it) == "food") & (it.quality=="epic") ) {
print(it);
}
}
Wouldn't this be better?
Code:foreach it in $items[] { if((it.fullness > 0) & (it.quality=="epic") ) { print(it); } }
(does not go around the problem that you're going through the entire item-database though)
You could try to hype up the time function in bordemstirs time FReq of last halloween... specifically, the gametime_to_int patch made so he could check server time without needing to do a server hit. Examples of how to use it in the post 13 in that thread, but basically what it does is make gametime_to_int return the server time in MS, so you can use it for timing and all sorts of useful things as well.
You could try to hype up the time function in bordemstirs time FReq of last halloween... specifically, the gametime_to_int patch made so he could check server time without needing to do a server hit. Examples of how to use it in the post 13 in that thread, but basically what it does is make gametime_to_int return the server time in MS, so you can use it for timing and all sorts of useful things as well.
int starttime =0;
for a from 1 to 3 {
print("Test 1");
starttime = gametime_to_int();
for i from 1 to 1000 {
int epiccount = 0;
foreach it in $items[] {
if((item_type(it) == "food") & (it.quality=="epic") ) {
epiccount +=1;
}
}
}
print("1000 Iterations full loop (type=\"food\" took " + (gametime_to_int() - starttime) + "ms");
print("Test 2");
starttime = gametime_to_int();
for i from 1 to 1000 {
int epiccount = 0;
foreach it in $items[] {
if((it.fullness > 0) & (it.quality=="epic") ) {
epiccount +=1;
}
}
}
print("1000 Iterations (full loop, fullness > 0) took " + (gametime_to_int() - starttime) + "ms");
print("Test 3");
starttime = gametime_to_int();
for i from 1 to 1000 {
int epiccount = 0;
int[item] food;
file_to_map("fullness.txt", food);
foreach it in food {
if((it.fullness > 0) & (it.quality=="epic") ) {
epiccount +=1;
}
}
}
print("1000 Iterations (fullness.text) took " + (gametime_to_int() - starttime) + "ms");
print("Test 4");
int[item] food;
file_to_map("fullness.txt", food);
starttime = gametime_to_int();
for i from 1 to 1000 {
int epiccount = 0;
foreach it in food {
if((it.fullness > 0) & (it.quality=="epic") ) {
epiccount +=1;
}
}
}
print("1000 Iterations (fullness.text(pre loaded)) took " + (gametime_to_int() - starttime) + "ms");
}
Test 1
1000 Iterations full loop (type="food" took 8073ms
Test 2
1000 Iterations (full loop, fullness > 0) took 12169ms
Test 3
1000 Iterations (fullness.text) took 4118ms
Test 4
1000 Iterations (fullness.text(pre loaded)) took 966ms
Test 1
1000 Iterations full loop (type="food" took 8137ms
Test 2
1000 Iterations (full loop, fullness > 0) took 12462ms
Test 3
1000 Iterations (fullness.text) took 4094ms
Test 4
1000 Iterations (fullness.text(pre loaded)) took 971ms
Test 1
1000 Iterations full loop (type="food" took 8198ms
Test 2
1000 Iterations (full loop, fullness > 0) took 12297ms
Test 3
1000 Iterations (fullness.text) took 3975ms
Test 4
1000 Iterations (fullness.text(pre loaded)) took 965ms
foreach it in $items[]
if ((item_type(it)=="food") & (it.quality=="epic") & (item_amount(it) > 0))
'DoStuff';
else if ((item_type(it)=="booze") & (it.quality=="epic") & (item_amount(it) > 0))
'DoStuff';
foreach it in $items[]
if ((it.quality=="epic") & (item_amount(it) > 0))
'DoStuff';