Char Pane request changes.

Veracity

Developer
Staff member
[quote author=lostcalpolydude link=topic=2152.msg11080#msg11080 date=1231955302]
Adventuring quickly does seem to be the cause. However, instead of having duplicate adventure numbers, I've seen adventure numbers skip a number. I tend to see it when I'm spamming the ~ key, and I guess jasonharper and Veracity don't do that much (it probably would make sense to autoadventure in mafia for most of those cases), so they never see it and therefore can't very well fix it.[/quote]
The issue being discussed is the fortune cookie counters getting out of synch. Or, perhaps more accurately, KoLmafia (temporarily) losing track of what adventure number you are currently on.

KoLmafia reads your current adventure number (within this ascension) from your Character Sheet when you log in. It attempts to track how many adventures various activities consume: adventuring takes 1 (or 2 in the Sea), making things without an in-a-box takes 1 per step, and so on. Some things take unexpectedly more: succumbing to gas in the Daily Dungeon, putting a bad sphere in a Hidden City Altar, fully experiencing the life of an enslaved Bugbear, and so on. KoLmafia therefore constantly corrects its idea of the current adventure number by looking at "Adventures Remaining" on the Character Pane - the sidebar you see on the main KoL GUI - and updating to correspond with KoL's idea.

So, if you are doing normal things - like adventuring - and KoLmafia is, somehow, losing synch of adventure number, it's probably because of some weird Character Pane interaction. For example, if it somehow got an OLD Character Pane, it might think it was erroneously in advance of KoL's adventure number and reset backwards.

I recently noticed in my debug logs that it sure seemed like we were fetching the Character Pane a lot. Twice in a row, sometimes. Often. So I added this to my list of things to look into - and revisions 6762 and 6763 are the result.

1) During automated adventuring, I found that whenever you got redirected into a Fight, KoLmafia would complete the fight - and update the Character Pane, as directed by the Fight - and would then update it again. So, we'd see sequences like this (for 1-hit kills):

Adventure
Fight Round 0 (the initiative round)
Fight Round 1 (the kill round)
Character Pane update
Character Pane update
(repeat)

I removed certain forced Character Pane updates. If KoL itself forces one, or if you get results (stat gains, items), or if we think the encounter took an adventure, we force one - and no longer automatically do one after every redirected Fights. I am now seeing sequences like:

Adventure
Fight Round 0 (the initiative round)
Fight Round 1 (the kill round)
Character Pane update
(repeat)

I have tested with Combats, Noncombats, and Choices. All seems peachy. This is revision 6762 - a potential 20% reduction in # of requests during automated adventuring. Please tell me of problems.

2) I then looked at adventuring in the Relay Browser. I noticed that every time we fetched the Character Pane, we seemed to do it twice.

Turns out, the Relay Browser only does requests that the Browser itself requests - except, if we see a Character Pane update and we think it's a "between battle" situation, we do our "between battle" checks - scripts, HP and MP recovery, buff casting - as directed by preferences - and then we repeat the request. So, even if you are doing NOTHING between battles, you get two Character Pane updates for every one that KoL thinks you need.

I removed the second one. Because of my previous fix, I think that any time you NEED a Character Pane update because of actual "between battle" actions, you will get one. Since we cache such updates, after running "between battle" checks, I use the most recent Character Pane update - either the one we just fetched, or the one generated by the "between battle" checks.

Therefore, no more extra Character Pane updates that are not forced by the browser itself. This is revision 6763.

Now, no promises, but this could very well have some effect on those of you who "spam the ~ key" to repeatedly adventure. Unless you have complicated "between battle" actions which force KoLmafia to make requests of the server to heal up and cast buffs and such - which you honestly can't expect to work well, if you are simultaneously and asynchronously spamming the browser with "adventure again" requests, can you? - KoLmafia will update its current adventure count exactly when the browser requests a Character Pane update - which is exactly when your greasemonkey script gets to look at it.

It just might help this problem.

Please tell me how things work, both automated and in the Relay Browser. These fixes SHOULD be a significant performance improvement and also improve reliability - but there might be problems which my testing did not reveal. I'll need actual debug logs to diagnose it, if you do have problems.

Thanks.
 

lostcalpolydude

Developer
Staff member
As posted in the Daily Builds thread, mafia fails to modify the character pane at the end of a combat. Also, the fortune cookie counters were off again (by 2 this time), so that problem hasn't been fixed. I'm not even spamming ~ this time. No debug log, unfortunately.

Edit: So now mafia IS modifying the character pane at the end of fights, and I have no idea what changed.
 

Ethelred

Member
I'm sad to say that I still see a couple of instances where Mafia's turn count and the actual count get out of sync.

First, if my box servant, chef in this case, blows up during an operation and is auto replaced, the count will be off by the number of cooking steps that would have been required to manually finish the operation. This can be seen in the following bit of gCLI transcript:

Code:
Need to bake peach pies.
Verifying ingredients...
Verifying ingredients for peach pie (20)...
Verifying ingredients for pie crust (20)...
Creating pie crust (20)...
You acquire pie crust (20)
Successfully created pie crust (20)
Creating peach pie (20)...
You acquire peach pie (8)
You acquire an item: spring
You acquire an item: chef's hat
You acquire an item: disembodied brain
You acquire an item: broken skull
You acquire an item: white chocolate chip cookies
You acquire an item: ghuol guolash
You acquire an item: white chocolate chip cookies
You acquire an item: chorizo taco
Your box servant has escaped!
Successfully created peach pie (8)
Using 1 chef-in-the-box...
Finished using 1 chef-in-the-box.
Creating peach pie (12)...
You acquire peach pie (12)
Successfully created peach pie (12)

> call scripts/Stats.ash

Moxie 30 437 432 860 13232

> call scripts/Stats.ash

Moxie 30 437 432 860 13220

The last number reported by Stats.ash is the turn count, as reported by my_turncount(). The only difference between the first and second call was a refresh of the character pane in the relay browser. Note that the 2 turn counts differ by 12, the number of pies created after the chef replacement.

The second case is my ash script to get the days clovers.

Code:
Purchasing chewing gum on a string (10 @ 30)...
You acquire chewing gum on a string (10)
Purchases complete.

Request 1 of 10 (Town: Unlucky Sewer) in progress...

[13221] Unlucky Sewer
You acquire an item: seal-clubbing club

Request 2 of 10 (Town: Unlucky Sewer) in progress...

[13223] Unlucky Sewer
You acquire an item: spices

Request 3 of 10 (Town: Unlucky Sewer) in progress...

[13224] Unlucky Sewer
You acquire an item: helmet turtle

Request 4 of 10 (Town: Unlucky Sewer) in progress...

[13225] Unlucky Sewer
You acquire an item: disco ball

Request 5 of 10 (Town: Unlucky Sewer) in progress...

[13226] Unlucky Sewer
You acquire an item: disco ball

Request 6 of 10 (Town: Unlucky Sewer) in progress...

[13227] Unlucky Sewer
You acquire an item: worthless trinket

Request 7 of 10 (Town: Unlucky Sewer) in progress...

[13228] Unlucky Sewer
You acquire an item: mariachi pants

Request 8 of 10 (Town: Unlucky Sewer) in progress...

[13229] Unlucky Sewer
You acquire an item: stolen accordion

Request 9 of 10 (Town: Unlucky Sewer) in progress...

[13230] Unlucky Sewer
You acquire an item: turtle totem

Request 10 of 10 (Town: Unlucky Sewer) in progress...

[13231] Unlucky Sewer
You acquire an item: worthless gewgaw

Robbing the hermit...
You acquire ten-leaf clover (3)
Hermit successfully looted!
Using 3 ten-leaf clover...
You acquire disassembled clover (3)
Finished using 3 ten-leaf clover.
Traded 3 clovers from the hermit.

Note that after the first adventure in the sewer, the turn count increases from 13221 to 13323 while all the other steps only increment the turn count by 1. Stats.ash once again shows the difference by comparing the output before and after refreshing the character pane.

Code:
> call scripts/Stats.ash

Moxie 30 437 432 860 13231

> call scripts/Stats.ash

Moxie 30 437 432 860 13230

The code to adventure in the sewers is:
Code:
		adventure( 10, $location[unlucky sewer] );
so there's no reason the first turn is different than the others as far as my script is aware.

These are not isolated incidents, nor have they just appeared with version 6764. This behaviour has been around for over a year. Since it's mainly a minor cosmetic problem and doesn't actually affect any functionality for me, I haven't posted them before. I post this now in case it can help get to the bottom of turn the count synchronization problem that may be showing up in other areas.
 

Veracity

Developer
Staff member
[quote author=lostcalpolydude link=topic=2153.msg11102#msg11102 date=1232003736]
As posted in the Daily Builds thread, mafia fails to modify the character pane at the end of a combat.[/quote]
This should be fixed by 6765.

Also, the fortune cookie counters were off again (by 2 this time), so that problem hasn't been fixed. I'm not even spamming ~ this time. No debug log, unfortunately.
Without a debug log, I am helpless.

[quote author=Ethelred link=topic=2153.msg11107#msg11107 date=1232010721]
First, if my box servant, chef in this case, blows up during an operation and is auto replaced, the count will be off by the number of cooking steps that would have been required to manually finish the operation.[/quote]
Yes. I saw two problems in the detection of box servant explosion.

1) It first removed the servant from your campsite and THEN adjusted turn usage as if you didn't have a servant to start with.
2) More importantly, it need not have adjusted turn usage at all, since we no longer track turns manually, but depend on the Char Pane. That was a vestige of the way things used to work.

Note that after the first adventure in the sewer, the turn count increases from 13221 to 13323 while all the other steps only increment the turn count by 1.
Again, the Sewer Request code was manually adjusting the turn count if it thought the visit succeeded. I'm not sure why it only did it once, but again, that is a vestige of the way things used to work. We no longer need to do that at all; upon gaining an item, we get the Char Pane, and the turns are accounted for normally.

These are not isolated incidents, nor have they just appeared with version 6764. This behaviour has been around for over a year.
Those are two vestiges of old obsolete code. I have fixed both.

I see no other instances in KoLmafia where we manually adjust the turn count, except for training your familiar in the Arena, where it deducts a turn and 100 meat. I suspect that is no longer correct, as well. I'll experiment.

In the mean time, revision 6766 should fix the exploding box servant and sewer adventuring issues.
 

zarqon

Well-known member
Thanks a lot for this! I had noticed the sewer seemed to throw off the count before, because I could never use the sewer as my adventuring location with Wormwood scripts, but I didn't have enough information to report it. Also, particularly happy about the reduction of server hits, which should also speed up relay browsing. I admire and appreciate your dedication.
 
Top