[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.
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.