Intelligent cookie eating

Banana Lord

Member
I'm trying to make Harvest a little more intelligent about eating fortune cookies. Currently it simply checks to see if you have an active fortune cookie counter and if not it eats a cookie before letting ED (or the specified consumption script) loose on your organs. If you do have a fortune cookie counter active then it simply tells ED to keep one fullness spare to allow another cookie to be eaten later.

Ideally it would look at your smallest fortune cookie counter (or semirare window counters if you have none) and determine whether or not to eat a cookie before consuming, and how much space should be left for cookies later on (taking the average time before SRs to be 180 adventures). The problem is I'm not entirely sure how to access counters properly. get_counters is useful for telling me if a counter is active or not, but I'm not sure how to extract the number of turns from it. Also, are these properties relevant, and if so what do they track?

lastSemirareReset
semirareCounter
 

slyz

Developer
lastSemirareReset is used internally to check if your counters have been already wiped on your current ascension.
semirareCounter is the turn on which you found your last semi rare.

To see in how many turns a Fortune Cookie counter is due, you need to go through all the possibilities yourself:
PHP:
int [ int ] sr_turns;
for i from 0 to 200
	if ( get_counters( "Fortune Cookie", i, i ) != "" )
		sr_turns[ sr_turns.count() ] = i;

foreach i, turns in sr_turns print( "Possible semi-rare in " + turns + " turns" );
 
Not sure if this is "neater":
Code:
int now = my_turncount();
string txt = get_property("relayCounters");
matcher puller = create_matcher("(\\d+):Fortune Cookie:fortune.gif", txt);
if (puller.find()) 
            print(to_int(puller.group(1))-now);
 

Banana Lord

Member
Awesome, thanks! Just to confirm (I know nothing about matchers or regex), the number that is returned is always the smallest cookie counter isn't it?
 
Awesome, thanks! Just to confirm (I know nothing about matchers or regex), the number that is returned is always the smallest cookie counter isn't it?

Yes, it returns the smallest cookie counter. If you want to access the second smallest cookie counter, replace puller.group(1) with puller.group(2).
 
Top