Bug - Not A Bug Autoadventure continues after target amount of turns

fronobulax

Developer
Staff member
http://pastebin.com/3KGA9xH3

That's a ctrl+c of my CLI window just now. It's the first time I've noticed it, but there were a few times when I noticed I had fewer turns than I expected, so it may have happened before.

I note that your session has [203078] followed by [203080] with [203079] missing. Lag? I'm pretty sure that is an adventure count that mafia gets from KoL but there is no attempt to predict what the next one should be and take action if the prediction is not correct.
 

xKiv

Active member
I note that your session has [203078] followed by [203080] with [203079] missing. Lag? I'm pretty sure that is an adventure count that mafia gets from KoL but there is no attempt to predict what the next one should be and take action if the prediction is not correct.

That looks like running out of Fishy, since the adventures after that are also spaced by 2.
What's surprising is that request 250/250 is followed by request 2/250 there.
 

fronobulax

Developer
Staff member
One sign of advanced age is losing one's memory. I forget what the others are. I had an education from veracity that unfortunately did not stick as well as it should have. Key points I do remember is that mafia does distinguish between adventures spent in a location and the number of times a location is visited. This makes a difference in the Sea, in the desert when auto-hydrating and and anywhere else where more than one adventure can be consumed. mafia also does not keep track of adventure counts internally. It updates them from what KoL tells mafia. I have not synthesized all of these half-remembered items to something that explains what was observed but it seems like could be done and might shed some light on exactly what is happening.
 
What happened is that you told mafia to adventure in the sea N times, and since you didn't have fishy you spent 2N total adventures. Been like that for ages, though I'll admit I was surprised the first time I realized this. It could get complicated to do it otherwise: what if you start with fishy, but it runs out part way through? What if you are also using a sea familiar with a hookah, which could at any time give you more fishy (possibly after it expires the first time)? What if you're running a mood/script that will automatically do something about getting more fishy for you? And even if you try to have it compute "starting turns - current turns" until it hits the given amount, what happens if you gain adventures along the way? Say your v-mask goes off and gives you an extra? Or you have a script that does something to give you more adventures? The last one could really mess you up if mafia loses the response to your script's actions and never even sees the adventure gains. As long as it sees every adventure gain/loss there's a chance, at least. Mafia would have to recompute things after every single adventure attempt, and cross its fingers it doesn't miss anything (which it sometimes does anyway, but why add in that chance on EVERY turn).
 
It could get complicated to do it otherwise: what if you start with fishy, but it runs out part way through? What if you are also using a sea familiar with a hookah, which could at any time give you more fishy (possibly after it expires the first time)? What if you're running a mood/script that will automatically do something about getting more fishy for you? And even if you try to have it compute "starting turns - current turns" until it hits the given amount, what happens if you gain adventures along the way? Say your v-mask goes off and gives you an extra? Or you have a script that does something to give you more adventures?
Actually, it wouldn't be complicated at all, mafia would just adventure until you got to adventure X (or possibly less if the next action would put you over X, depending on how you set it up).
Whether or not mafia -should- behave this way is a different subject. I like the behavior as is, but it wouldn't be hard to get used to it if it were to change.
 

slyz

Developer
I don't think the problem is the number of adventures used. Xkiv pointed out that Mafia started a new batch of 250 requests without user intervention, apparently. This is what should be tracked down.
 

fronobulax

Developer
Staff member
Actually, it wouldn't be complicated at all

I look forward to seeing your proposed patch ;-)

There are two issues here. One is, what does the number mean that you put into the box on the adventure tab? The other is what happened with Sarmatron and was it "correct" or explainable behavior? I believe the answer to the former is "number of visits to the location", which may or may not be the number of adventures used, and the user is just going to have to understand that the two are not always the same. The latter is worthy of investigation although I personally am quite content to attribute it to lag (or something else not necessarily being a mafia problem) given that mafia apparently does not know what happened in adventure 203079.
 

xKiv

Active member
I look forward to seeing your proposed patch ;-)

There are two issues here. One is, what does the number mean that you put into the box on the adventure tab?

That's the number of turnips to execute, duh.
(turnip = turn or trip, skipped adventures don't count)

given that mafia apparently does not know what happened in adventure 203079.
I suspect there was no adventure 203079, like so:
203077 was still started with Fishy, so it only cost 1.
203078 was started without Fishy, so it cost 2, and the next adventure was 203080.
 

Theraze

Active member
Wondering if it's possible that mafia was looking for adventure 203081 to stop auto-adventuring on, and when it failed to happen, it continued? Or maybe one of those lovely grey gCLI bugs happened. But I'm thinking that not finding the adventure it expected to stop on is more likely...
 

fronobulax

Developer
Staff member
That's the number of turnips to execute, duh.
(turnip = turn or trip, skipped adventures don't count)

From here.
The counter on the KoLmafia GUI specifies how many turns you want to spend in the zone you selected.

All I'm trying to do is paraphrase veracity. I can't tell from the comment whether we are in violent agreement or we are having trouble communicating in English.

Regardless, it is a moot point in this discussion because we suddenly have 2/250 which has yet to be explained.
 

Veracity

Developer
Staff member
Looking at the code in KoLmafia.java:

Code:
	private void executeRequest( final Job request, final int totalIterations, final boolean wasAdventuring )
	{
		boolean isAdventure = request instanceof KoLAdventure;
		...
		KoLmafia.forceContinue();
		...
		int currentIteration = 0;
		...
		while ( KoLmafia.permitsContinue() && ++currentIteration <= totalIterations )
		{
			int runBeforeRequest = KoLCharacter.getCurrentRun();
			...
			this.executeRequestOnce( request, wasAdventuring, currentIteration, totalIterations, items, creatables );

			if ( isAdventure && KoLmafia.redoSkippedAdventures &&
			     runBeforeRequest == KoLCharacter.getCurrentRun() )
			{
				--currentIteration;
			}
			...
		}
		...
	}
I stripped out things that were not apropos to this discussion.

1) When you say "adventure 50 times in a zone", that means make 50 visits to that zone. It does NOT mean "spend 50 turns". turnips, not turns.
2) The loop is controlled strictly by the number you entered in the count field in the GUI - or the count parameter of the "adventure" command or function in the CLI or ASH.
3) We DO look at the KoL-supplied run counter to see if an adventure was consumed - and if you took a choice, say, which didn't actually consume an adventure, we don't count that as an iteration.

Basically, xKiv got it exactly right.

Regarding this report, I am suspicious that the session log skips an adventure an starts again at "2 of 250". Presumably, the skipped one was "1 of 250". My personal belief is that the OP actually did - presumably inadvertently - tell KoLmafia to spend another 250 adventures, rather than that the loop, which I copied into a code block in the reply - miraculously restarted itself.
 

Sarmatron

Member
And wait, are you saying that I deliberately removed adventure 1 of 250 from the log I pasted, what, just to fuck with you? Why would I do that?
 

lostcalpolydude

Developer
Staff member
The statement meant that you might have unintentionally and unknowingly told mafia to start adventure again, somehow.
 

fronobulax

Developer
Staff member
And wait, are you saying that I deliberately removed adventure 1 of 250 from the log I pasted, what, just to fuck with you? Why would I do that?

Chill. No one is accusing you of anything except perhaps not reading posts carefully and considering all possible meanings before you decide what was being said.

veracity was suggesting that the 2/250 "restart" could have been caused by the operator, although unintentionally. I know that under certain circumstances KoLmafia will adjust the visit count you enter if it is greater than the number of adventures left. So if I have 100 adventures and enter 9999 it will replace what I entered with 100. What I do not know is whether the replaced value is ever printed or not. If it is printed then the xxx/250 followed by 2/250 suggests that you had 500 adventures in the session. If that is true then I would like lessons on eating, drinking and spleen from you. Otherwise it may be evidence that the second loop was not operator triggered or at least was triggered in a way that somehow bypassed the compare to adventure check.

Regardless, what is the point of the log at http://pastebin.com/CU0wcXYY ? I don't see anything unusual except the absence of the xxx/yyy information and the fact that 203837 was the last adventure with fishy active.
 

Veracity

Developer
Staff member
veracity was suggesting that the 2/250 "restart" could have been caused by the operator, although unintentionally.
I specifically used the words "presumably inadvertent".

I know that under certain circumstances KoLmafia will adjust the visit count you enter if it is greater than the number of adventures left. So if I have 100 adventures and enter 9999 it will replace what I entered with 100. What I do not know is whether the replaced value is ever printed or not. If it is printed then the xxx/250 followed by 2/250 suggests that you had 500 adventures in the session.
2) The loop is controlled strictly by the number you entered in the count field in the GUI - or the count parameter of the "adventure" command or function in the CLI or ASH.
If you enter a number in the GUI, KoLmafia will adjust it down to the number of available adventures, if necessary. On the other hand, if a script calls "adventure( xxx, 500 )" - which turns into the "adventure 500 xxx" CLI command - the loop is called with the unadjusted number.

I saw two calls on the loop in the original CLI log.
The second log was a session log and showed nothing about how the adventures were split into groups.
As frono points out, it does show that Fishy ran out at some point.

How did you do this adventuring? Do you have a script, or is all that purchasing and sushi rolling and stuff done manually through Purchases and the Item Manager and such - or, perhaps, the CLI?

Could we see your script, please?

Thanks.
 
Top