Bug - Fixed boring binder clip isn't being automatically used

Bale

Minion
Boring binder clip isn't being automatically used when it is gained from the choice adventure to create the McClusky file (complete) .
 

Veracity

Developer
Staff member
Works for me.

[843] The Hidden Office Building
Encounter: Working Holiday
You acquire an item: boring binder clip
Verifying ingredients for McClusky file (complete) (1)...
Creating McClusky file (complete) (1)...
You acquire an item: McClusky file (complete)
Successfully created McClusky file (complete) (1)

> get autoCraft

true
 
there *was* a version earlier this week where this didn't work either, but it fixed itself by the next time I got to it again.
 

Bale

Minion
I attempted to replicate the error (with a debug log), but failed to reproduce it. :(

Dunno what happened, but if I cannot reproduce it then the bug report is useless so I'll consider this closed.
 

ckb

Minion
Staff member
FYI - I just finished this quest yesterday, with r14507, and had no issues (the binder clip way automatically used by Mafia).
 

Bale

Minion
Good/Bad news. I reproduced the bug and got a debug log of it.

The bug activated by automatic adventuring instead of relay browser adventuring.

Code:
[COLOR="#808000"]> inv file[/COLOR]

McClusky file (page 1)
McClusky file (page 2)
McClusky file (page 3)
McClusky file (page 4)
McClusky file (page 5)

[COLOR="#808000"]> inv binder[/COLOR]

boring binder clip

[COLOR="#808000"]> use boring binder clip[/COLOR]

Using 1 boring binder clip...
You acquire an item: McClusky file (complete)
Finished using 1 boring binder clip.

Debug log is an attachment:
 

Attachments

  • DEBUG_20140831.txt
    196.7 KB · Views: 31

Veracity

Developer
Staff member
OK. That debug log shows exactly the opposite of what your original bug report said you'd done:

"Boring binder clip isn't being automatically used when it is gained from the choice adventure to create the McClusky file (complete) ."

I interpreted that to mean "If I have 5 pages of the McClusky file and then find the boring binder clip in the choice adventure, it is not used to make the McClusky file (complete)". Therefore, I studied the code for that situation, saw no bugs, tested it, and saw no bugs.

What your debug log shows (other than lots and lots of calls to Guide) is this: You have the boring binder clip and 4 pages of the McClusky file. You then fight an accountant and get the 5th page, and the binder clip is not used at the end of the fight to make the (complete) file. Which has nothing to do with "using the binder clip when it is obtained in the choice adventure", which is what you reported.

I'm too tired, right now, but I'll look at this tomorrow. Maybe I will test it by going to the office building just long enough to get the binder clip before I go to the apartment, which is the opposite of what I always do, since if I go to the apartment building first, I have a chance to, maybe, banish lawyers, but, whatever.
 

Veracity

Developer
Staff member
Yeah, that's happened to me once or twice. Sometimes I get bunches of shamans and the first time I get the apartment NC, it's time for the spirit, without banishing the lawyers, and perhaps without even getting any pages. However, just as frequently, I get a bunch of accountants and by the time I see the NC the first time, I am not sufficiently cursed to fight the spirit, so I banish the lawyers.

Nothing is guaranteed. Even adventuring in the office first, I could get 5 accountants before I see the NC for the first time, and thus get the binder clip last - unless I intentionally run away. :)

I just looked at ResultProcessor.gainItem. A little while ago, I changed:

Code:
		case ItemPool.MCCLUSKY_FILE_PAGE5:
			if( Preferences.getBoolean( "autoCraft" ) &&
			    InventoryManager.getCount( ItemPool.BINDER_CLIP ) == 1 )
			{
				RequestThread.postRequest( UseItemRequest.getInstance( ItemPool.BINDER_CLIP ) );
			}
			break;
to:

Code:
		case ItemPool.MCCLUSKY_FILE_PAGE5:
			ResultProcessor.autoCreate( ItemPool.MCCLUSKY_FILE );
			break;
Note that the identical ResultProcessor.autoCreate call is also used when you acquire the binder clip in the choice - and that that same method is used repeatedly elsewhere in ResultProcessor.gainItem. Hard to imagine that anything changed, which makes we wonder how/if it ever worked. I'll look at in the debugger today, when I do the Hidden City.
 

Veracity

Developer
Staff member
A-yup. Worked for me.

Code:
[584] The Hidden Apartment Building
Encounter: pygmy witch accountant
Round 0: Veracity loses initiative!
You lose 33 hit points
Round 1: Veracity casts POCKET CRUMBS!
Round 2: pygmy witch accountant drops 29 attack power.
Round 2: pygmy witch accountant drops 29 defense.
Round 2: Thct'ul Grrl caresses your mind with gentle ethereal tentacles.
Round 2: You gain 12 Mojo Points.
Round 2: Veracity casts SAUCESTORM!
Round 3: pygmy witch accountant takes 81 damage.
Round 3: pygmy witch accountant takes 40 damage.
Round 3: Thct'ul Grrl caresses your mind with gentle ethereal tentacles.
Round 3: You gain 10 Mojo Points.
You lose 21 hit points
Round 3: Veracity attacks!
Round 4: pygmy witch accountant takes 66 damage.
Round 4: Thct'ul Grrl caresses your mind with gentle ethereal tentacles.
Round 4: You gain 10 Mojo Points.
You lose 21 hit points
Round 4: Veracity attacks!
Round 5: pygmy witch accountant takes 66 damage.
Round 5: Veracity wins the fight!
After Battle: Thct'ul Grrl surveys the scene from your back, and gains 1 Experience.
You gain 252 Meat
You acquire an item: adder
You acquire an item: pygmy adder oil
You acquire an item: McClusky file (page 5)
Verifying ingredients for McClusky file (complete) (1)...
Creating McClusky file (complete) (1)...
You acquire an item: McClusky file (complete)
Successfully created McClusky file (complete) (1)
After Battle: Raven 'Raven' Ravengrrl draws a picture of your opponent morbidly obese with buck teeth and acne. It comes to life and starts crying, which makes Raven 'Raven' Ravengrrl smile a wicked smile. (+5 Stats)
You gain 18 Fortitude
You gain 13 Magicalness
You gain 42 Chutzpah
You recover 7 drops of Rain
I have this:

> get autoCraft

true
That setting has always been required, as you can see from the code I quoted above. What do you have it set to?
 

Veracity

Developer
Staff member
I have no ideas. I stepped through the code with Eclipse in both cases - finding the binder clip in the choice adventure, and finding the last file after a fight - and everything was exactly as I expected.

I did notice the following in your log:

Code:
After Battle: A little pile of hot ashes falls out of the bottom of Alva Veterinarian.
You acquire an item: hot ashes
Processing result: hot ashes
Starting relay script: relay_Guide.ash
You acquire an item: McClusky file (page 5)
Processing result: McClusky file (page 5)
Guide started executing right in the middle of result processing for this battle. Right before we found the fifth file, in fact. I wonder if that, somehow, set something that made auto crafting think that it couldn't do anything right then.
 

Veracity

Developer
Staff member
Actually, I think I have a clue. You DID say you were automating - and, for some reason, we defer concoction refreshing while that happens unless you have a goal that requires creating something. autoCrafting requires concoction refreshing, so, unless you had a goal like "McClusky file (complete)", it would not work while automating.

It could be as simple as changing KoLmafia.executeRequest from this:

Code:
		boolean deferConcoctionRefresh = true;
to this:

Code:
		boolean deferConcoctionRefresh = !Preferences.getBoolean( "autoCraft" );
... although other code could be simplified, too. I need to study that method some more.
 

Bale

Minion
Actually, I think I have a clue. You DID say you were automating - and, for some reason, we defer concoction refreshing while that happens unless you have a goal that requires creating something. autoCrafting requires concoction refreshing, so, unless you had a goal like "McClusky file (complete)", it would not work while automating.

That sounds likely. It created the report when I got it during relay adventuring. It was only the automation that was involved. Both times it happened, I was doing automatic adventuring and it never happened in the relay browser.
 
I concur. I remember when it happened to me, I was automating because I figured I'd set the goal (fight spirit or get binder clip or fight accountant) and be done, and I knew I already had the 5 pages. I have since stopped automating and it's always worked fine in the relay browser which was why I thought I was imagining the whole thing in the first place and didn't report it myself.

Excellent detective work, again, Veracity.
 

Bale

Minion
Veracity can discover anything if you give her a debug log to work with. She's a debug detective.
 

Veracity

Developer
Staff member
Thanks!

I've thought more about this issue and I think that a better solution is needed.

Refreshing concoctions is a time consuming process. Since the "ingredients" that are used to make a recipe include items, turns and Meat, all of which change over the course of adventuring, in theory, if we want to keep the GUI (the various panels on the Item manager) up to date, we should refresh after every single adventure. However, as an optimization, we decided that we could "defer" the refresh until the sequence of automated adventures was complete, since the GUI was disabled while that was happening anyway.

We do not defer the refresh if you have at least one goal (condition) which is something which can be created from ingredients, since we are willing to fulfill goals by creating them. That's why you can set a goal of "digital key" and adventure for pixels, and as soon as we can come up with 30 white pixels (via creation from RGB pixels, if necessary), we make it. Similarly for star hat, and so on, in the Hole in the Sky. But if you don't have goals like that, we defer the refresh, and automated adventuring is noticably faster.

autoCraft is similar, but different. There are specific times when KoLmafia will attempt to auto-create items. This is regardless of your goals; we will autoCraft a boring binder clip with 5 McClusky files to get the complete file, but if you turn off autoCraft, you can still set "McClusky file (complete)" as a goal and start automating and we will create it when you have collected all the components. autoCraft means you don't have to manually change your goals to make that happen.

So, how does autoCrafting work? When we say "create the item if you can" (because you acquired a particular item), it force refreshes concoctions and, if the "creatable" amount of the desired item is greater than 0, it creates it.

Unfortunately, even "force refreshing concoctions" is overridden by "deferring concoction refresh". And THAT is what I think I need to look at, rather than saying "don't defer refreshes if you have autoCraft active", since it is default for it to be active, and that will take away the big performance improvement for normal automation when you aren't explicitly asking for goals to be created.

I'm tired and must sleep, but tomorrow I will see about refactoring concoction refreshing so that that "refresh right NOW" will not get deferred and so that the deferring concoction refresh optimization can be used again.
 

Bale

Minion
Refreshing concoctions is a time consuming process. Since the "ingredients" that are used to make a recipe include items, turns and Meat, all of which change over the course of adventuring, in theory, if we want to keep the GUI (the various panels on the Item manager) up to date, we should refresh after every single adventure. However, as an optimization, we decided that we could "defer" the refresh until the sequence of automated adventures was complete, since the GUI was disabled while that was happening anyway.

We do not defer the refresh if you have at least one goal (condition) which is something which can be created from ingredients, since we are willing to fulfill goals by creating them. That's why you can set a goal of "digital key" and adventure for pixels, and as soon as we can come up with 30 white pixels (via creation from RGB pixels, if necessary), we make it. Similarly for star hat, and so on, in the Hole in the Sky. But if you don't have goals like that, we defer the refresh, and automated adventuring is noticably faster.

autoCraft is similar, but different. There are specific times when KoLmafia will attempt to auto-create items. This is regardless of your goals; we will autoCraft a boring binder clip with 5 McClusky files to get the complete file, but if you turn off autoCraft, you can still set "McClusky file (complete)" as a goal and start automating and we will create it when you have collected all the components. autoCraft means you don't have to manually change your goals to make that happen.

I'll just toss out a fact that probably occurs to you. For the Hidden Office Building, the default goal is "1 crackling stone sphere" but you cannot get that unless you create the McClusky file. I've got a preAdventureScript that adjusts the choice adventure from "get a boring binder clip" to "fight boss" based on inventory so theoretically if I was feeling bored I'd just tell it to automate the entire zone and hope it would create the McClusky file on schedule so that it can fight the boss. Then stop when it gets the sphere.

This is one case, perhaps the only case, where autocrafting is connected to the goal where the goal is not crafted.
 

Veracity

Developer
Staff member
OK, revision 14539 should allow us to keep the "defer concoction refresh" optimization but still force immediate concoction refreshing for places that really do need to have it happen before they can proceed - like autoCraft.
 
Top