Bug - Fixed Semirare / Fortune Cookie Counter not working

unfako

New member
- During the last 2 ascensions, My semirare counter almost never worked (that should be the last two weeks). It worked fine, almost every time, up until then.
- The problem first occured when I was adventuring with a bad internet connections - the two counters that didn't get dropped didn't give me a semirare (I first attributed this to the bad connection)
- Since then, only about one in three fortune cookies gives me a counter that's being registered (all the lucky numbers seem to be outside the estimated semirare window most of the time and get dropped)
Lucky numbers: 110, 234, 148
Lucky number 110 ignored - too soon to be a semirare.
Lucky number 234 ignored - too large to be a semirare.
Lucky number 148 ignored - too soon to be a semirare.
- The only times I have gotten good counters were, when I hit a semirare somewhere by chance and ate a cookie right afterwards.
- I usually ascend oxycore and drop oxygenation after a few adventures.
- I restarted kolmafia right after ascension and rebuild / restart at least once a day from svn (Or git? The right one. Not the wrong one. I looked that up at some point. ;))
- I don't spend adventures outside kolmafia.
- I've been using free bander runaways, at least one champagne popper per ascension & I've been encountering nemesis quest hitmen (no other "strange turn spending stuff" I am aware off, no bricko monstert etc.)
- I noticed my yellow ray counter was off at least 4 adventures one time, too, don't know if that could be related
 
Last edited by a moderator:

Bale

Minion
I also oxydrop. I also rebuild from svn frequently. I also get only 1 of 3 good numbers. I also use bander runaways and encounter nemesis quest hit men. Sometimes I fight bricko monsters also.

Mafia's counters are good to me. It doesn't mater if I eat my cookie immediately after the semi-rare or not. I always get my semi-rare exactly when mafia tells me to. I'm not saying that you're experience is wrong, just offering that some of your data points were not contributing to your problem.

This may be completely superfluous, but I feel it necessary to ask since it is the only thing you didn't point out in your extremely detailed post. Are you remembering to alternate your semi-rare? That would explain why you're getting a semi-rare after an accidental semi-rare. If you attempt to get two semi-rares at the same location, in a row, you'll fail.
 

unfako

New member
Thanks! That means I have to look for other things… wish I knew where to look though.

Yes, I'm sure I didn't try the same one twice - this run, I missed the first one, maybe the first two.

Still have the detailed logs, but there it only says what the lucky numbers are, not that they got dropped.

What else could that be? This time, getting a semirare by chance too didn't seem to make a difference - I've got

Code:
[522] Haunted Billiards Room
Encounter: A Shark's Chum

… which is correctly inside the config file:

Code:
semirareCounter=522
semirareLocation=Haunted Billiards Room

Later, I did (already postet):

Code:
eat 1 fortune cookie
You gain 2 Adventures
Lucky numbers: 110, 234, 148
custom outfit Backup

[521] Spooky Forest

… wait a second, aren't those in the brackets the turncount or something? Guess not, or else I'd be adventuring backwards (which would explain the problem, but still….what/why?). Anyways, All three of the counters got dropped as posted above.

Mmmh… there's a part in between, where it skips back from 558 to 517, which for me doesn't look as if it was meant to, but I don't know, maybe it's supposed to look like this:

Code:
[559] Daily Dungeon (Room 10)
Encounter: Treasure!
You acquire an item: Boris's key

cast 1 The Ode to Booze
You acquire an effect: Ode to Booze (duration: 15 Adventures)

Distill 1 bottle of vodka

Distill 1 bottle of vodka

Mix
You acquire an item: vodka and tonic
You acquire an item: yellow brick road
Crafting used 1 each of bottle of Definit and tonic water
Crafting used 1 each of little paper umbrella and vodka and tonic

drink 1 yellow brick road
You gain 20 Adventures
You gain 46 Magicalness
You gain 4 Drunkenness

autosell: 3 meat stack
You gain 300 Meat

[517] Rest in your dwelling
You gain 8 hit points
You gain 10 Mojo Points

I've got advanced disco rest but not the normal one - but I guess that's most likely not related, too… Gonna look around some more tomorrow, when I'm less tired. But I need a general direction, or I might end up posting a lot of irrelevant crap ;)
 

lostcalpolydude

Developer
Staff member
It seems that mafia is somehow tracking your turns spent based on turns remaining, and it misses you gaining adventures. Except I only see 20 adventures gained there, and it jumped back 42 turns. As a workaround, I think you could visit your character page after you consume anything to make sure mafia knows what turn number it is.
 

unfako

New member
Yes, looks like that after going through the logs again - I'll try manually updating after gaining adventures and before eating a cookie, thanks.

Just wonder why that happened so often during the last two weeks and never before - maybe my internet connection got worse or something.
 

lostcalpolydude

Developer
Staff member
I don't really know the cause, but a foolproof solution would be for mafia to use the turnsthisrun variable from the charpane.
 

HippoKing

Member
This looks weird as hell. I doubt that anyone is going to be able to fix it without a debug log though - get one of those next time you play your turns.
 

unfako

New member
Going to try that, but how?

I'm not familiar with java… I still have about 5000 lines of output it blabbered into the terminal over the last weeks, but that stuff looks mostly GUI-related (I have those often with normal programs too, so it doesn't look too suspicious) and mostly only during compiling - no Internet/Browser Stuff there…

Is that sort of output of interest (small excerpt)?
Code:
[ConditionalEventPump] Exception occurred during event dispatching:
java.lang.ArrayIndexOutOfBoundsException: 0
	at javax.swing.text.BoxView.getOffset(BoxView.java:1084)
	at javax.swing.text.BoxView.childAllocation(BoxView.java:678)
	at javax.swing.text.CompositeView.getChildAllocation(CompositeView.java:215)
	at javax.swing.text.BoxView.getChildAllocation(BoxView.java:436)
	at javax.swing.plaf.basic.BasicTextUI$UpdateHandler.calculateViewPosition(BasicTextUI.java:1979)
	at javax.swing.plaf.basic.BasicTextUI$UpdateHandler.layoutContainer(BasicTextUI.java:1955)
	at java.awt.Container.layout(Container.java:1421)
	at java.awt.Container.doLayout(Container.java:1410)
	at java.awt.Container.validateTree(Container.java:1507)
	at java.awt.Container.validateTree(Container.java:1513)
	at java.awt.Container.validateTree(Container.java:1513)
	at java.awt.Container.validate(Container.java:1480)
	at javax.swing.RepaintManager.validateInvalidComponents(RepaintManager.java:669)
	at javax.swing.SystemEventQueueUtilities$ComponentWorkRequest.run(SystemEventQueueUtilities.java:124)
	at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:209)
	at java.awt.EventQueue.dispatchEvent(EventQueue.java:597)
	at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:269)
	at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:184)
	at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:174)
	at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:169)
	at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:161)
	at java.awt.EventDispatchThread.run(EventDispatchThread.java:122)
Guess not...? Do I have to set a different verbosity / how? Also it would be great if I could have it saved to a file without piping it manually… If I have to restart the machine, it's all gone.
 

slyz

Developer
My guess is that you should turn on debug logging before eating (since that seems to be what messes with the turncount), in Help -> Start Debug Log, then attach the file to a post here or send it directly to Veracity maybe.

Another question, is "Log adventures left instead of adventures used" unchecked in Preferences -> Session Logs ?
 

unfako

New member
Oh god, thanks, I've been looking all over the place in folders & source for a variable or CLI option or something - that there might be something in the GUI didn't even cross my mind.
 

Veracity

Developer
Staff member
I don't really know the cause, but a foolproof solution would be for mafia to use the turnsthisrun variable from the charpane.
I am investigating this.

Unfortunately, "foolproof" is far from reality: when you spam adventures in the relay browser, you can get multiple charpane updates, updates out of order, dropped updates, whatever. (I wonder how houeland is going to deal with that in kolproxy; isn't session logging one of the things he's focusing on?)

We currently calculate adventures spent by comparing what the charpane says "adventures left" is compared to what we think they should be.
We could calculate adventures spent by comparing our current turncount directly with KoL's, as you suggest.

Assuming I can reject obvious bogus updates, updating adventure usage by comparing "turnsthisrun" rather than "turnsremaining" can hardly be less accurate. In fact, it seems more direct...
 

Veracity

Developer
Staff member
Well, what the heck. Revision 8264 now figures out "turns left" and "turns used" independently from both the charsheet and the charpane. Counters and stuff continue to be calculated relative to "turns used", but doing multiple adventure requests via the GUI or CLI also now depend on that value changing, rather than "turns left" going down. I removed the kludge that used to be needed to account for adventures being gained during a combat.

I'm going to mark this "fixed", even though I have no idea how your problem happened. I'm sire that if there are new problems, new bugs will be filed. ;)
 

lostcalpolydude

Developer
Staff member
And what do we do when we get charpanes out of order and the turncount goes backwards?
That does happen.

Would ignoring any charpane data that has a turnsthisrun value smaller than a previously received value work? As I recall, the out-of-order charpanes seemed to be the result of spamming ` for rapid repeated manual adventuring, and that generally isn't associated with setting any counters that would be sensitive to your turncount. I guess I don't know enough about how things work to know if this would make mafia less likely to stop someone adventuring when a counter comes up though.
 

Veracity

Developer
Staff member
That's exactly what I did: if turnsthisrun is not >= to what we think the turn count is, we drop the update.
 

lostcalpolydude

Developer
Staff member
Yeah, I managed to not see page 2 of the thread, and I should probably read what's been updated before bug reports anyway (the New Posts link got me reading stuff in a different order).
 

houeland

New member
I wonder how houeland is going to deal with that in kolproxy; isn't session logging one of the things he's focusing on?

Yes, you can't make kolproxy screw up stuff like this. That's a huge part of the reason for making a new codebase instead of e.g. hacking on mafia. Mafia has so many fancy features all around that I miss out on, but I wanted rock solid foundations, to make sure a) it doesn't send something to the servers when it shouldn't, or send the wrong thing b) it doesn't get confused about the state of the game.

(As part of b), I generally avoid modeling state unless it's really useful, and then keep it out of the core kolproxy internals. I mostly just expose what KoL tells you, like the current turn, since that's not a problem.)
 
Last edited:

Veracity

Developer
Staff member
Yes, you can't make kolproxy screw up stuff like this.
...
I mostly just expose what KoL tells you, like the current turn, since that's not a problem.)
Of course, when KoL sends back a charpane out of order because you are spamming the ` key, your turn count might go backwards. If you simply log that in your session log, you'll see multiple adventures on the same turn.

Is that, or is that not considered "screwing up"? ;)
 

lostcalpolydude

Developer
Staff member
I think kolproxy just won't let you spam the ` key, or do anything at all, until it receives the charpane (and other pages that should be received from a request), but I'm only guessing. Kind of the way that things don't get mixed up when you have mafia automate adventuring, maybe.
 

houeland

New member
Of course, when KoL sends back a charpane out of order because you are spamming the ` key, your turn count might go backwards. If you simply log that in your session log, you'll see multiple adventures on the same turn.

Is that, or is that not considered "screwing up"? ;)

Doesn't happen.

kolproxy doesn't rely on the player's web browser receiving charpane frame updates to know which turn it is for the logs, and additionally makes sure e.g. charpane responses aren't received out of order.

I think kolproxy just won't let you spam the ` key, or do anything at all, until it receives the charpane (and other pages that should be received from a request), but I'm only guessing. Kind of the way that things don't get mixed up when you have mafia automate adventuring, maybe.

You can spam the button, but that doesn't make kolproxy hit the KoL servers in a way that makes the order unpredictable. If you get the browser to send off 10 requests, kolproxy will order them for you before passing them on to the server, just like if you had requested them one at a time. (You should of course instead click "automate N turns", which would let it handle the fights etc. instead of just sending a bunch of page requests ;))
 
Last edited:
Top