Delay burning across rollovers?

Hello!

Is there a way to make Mafia remember which zones already had their delay burned in previous days?

Obviously these should reset after ascension, but currently (AFAICT) they are set in a way that causes Ezandora's Guide and some ascension scripts to waste resources burning delay in zones that are already burned (or even completed).

I'm assuming this can be fixed within the scripts themselves (on a case by case basis perhaps?), but maybe there's a Mafia can do it in a more universal way?
 

Darzil

Developer
Not exactly, and certainly not if the other days weren't played in Mafia.

I haven't ascended recently, but when I did with Guide the issue would come up whenever an item that caused non-combats without spending turns was used, as Guide would not handle that elegantly. Ideally Guide would understand that if a quest was complete (or progressed) that completed only after delay, that it meant there was no remaining delay worth burning.
 

lostcalpolydude

Developer
Staff member
What you are asking about is the turns_spent proxy value for a location, which Guide does use. Sometimes mafia doesn't track that properly. The most common cases are choices leading to combats and combats leading to choices.

I spent hours looking over that code trying to find a way to handle the common edge cases, and gave up. I will happily look over any patch that someone else provides, but I'm done trying to figure it out myself.

And yes, there are cases where Guide could check for a quest being completed in addition to just checking turns_spent (at least that's what I remember from last time I ascended).
 
turns_spent also seems to occasionally reset between days (resetting back to 0), as if it didn't get saved properly over rollover. This might be what is going on here, and I've been thinking about filing a bug report about that, but I was waiting to see if I could narrow down when it happened to include that in the bug report.
 
turns_spent also seems to occasionally reset between days (resetting back to 0), as if it didn't get saved properly over rollover. This might be what is going on here, and I've been thinking about filing a bug report about that, but I was waiting to see if I could narrow down when it happened to include that in the bug report.

Alright, doing some data collecting from my last run. This is day 3, right after kingliberation, before doing any aftercore turns. Unfortunately I only checked turns_spent on day 3. I checked my session logs to see how many turns I actually spent, and on which day.

I checked (most) locations Guide cares about (full list at line 3202).

Oh, one more thing I should note- It's possible that during the run I left mafia open overnight once, and closed then reopened it in the morning, after rollover. I'm not sure if this was the first or second rollover of the run. Hoping this does not contaminate this data.


Code:
> ash $location[the spooky forest].turns_spent

Returned: 12 (session logs say 7 on day 1, & 12 on day 2)

> ash $location[the boss bat's lair].turns_spent

Returned: 0 (7 on day 1)

> ash $location[the haunted bedroom].turns_spent

Returned: 0 (7 on day 1)

> ash $location[the oasis].turns_spent

Returned: 0 (3 on day 2)

> ash $location[the upper chamber].turns_spent

Returned: 0 (6 day 2)

> ash $location[the haunted gallery].turns_spent

Returned: 0 (11 on day 1)

> ash $location[the haunted bathroom].turns_spent

Returned: 1  (11 on day 1, & 1 on day 2)

> ash $location[the haunted ballroom].turns_spent

Returned: 7 (0 day 1, & 7 on day 2)

> ash $location[the penultimate fantasy airship].turns_spent

Returned: 0 (29 day 1)

> ash $location[The Castle in the Clouds in the Sky (Ground Floor)].turns_spent

Returned: 7 (9 on day 1, & 7 on day 2, 0 day 3) Note Sl_ascend decided to revisit this location, that's why it's >11

> ash $location[the outskirts of cobb's knob].turns_spent

Returned: 1 (11 day 1, 1 on day 2)

> ash $location[the hidden apartment building].turns_spent

Returned: 0 (9 on day 2)

> ash $location[the hidden office building].turns_spent

Returned: 0 (11 day 2)

> ash $location[the upper chamber].turns_spent

Returned: 0 (6 on day 2)

TL: DR
A couple of strange findings-
None of the checked locations were remembered between day 1 and 2.

Spooky forest and outskirts of cobb were remembered between day 2 & 3, but not day 1 & 2.
On the other hand, The Oasis was not remembered between day 2 to 3, so there's something deeper than "some rollovers reset the count, some don't", or "some locations work as intended, some don't". I think it also means that (if) mafia was left open overnight, it had no effect?

Well, I hope this can help narrow down what's going on. Thank you all!
 
Last edited:

Darzil

Developer
I have never seen that, but also never had mafia open over rollover (as it is early morning here)
 
I have never seen that, but also never had mafia open over rollover (as it is early morning here)

This (the reset to 0 on rollover) happens to me quite frequently, and leaving mafia open overnight is not something I often do.

I stayed an extra day in aftercore and checked again, all zones that had non-zero counts are still the same.

If there's any other data I can collect to help find the cause let me know.
 
Last edited:

Ezandora

Member
Are you on a Mac? Try typing "quit" into the Graphical CLI, versus the menu item. I suspect something changed with java or mac APIs, that KoLmafia menu>Quit no longer executes mafia's teardown code, and turns_spent is only written to disk then.

You can test this:
Code:
> ash $location[noob cave].turns_spent

Returned: 0

> adv1 noob cave

Visit to Mountain: Noob Cave in progress...
[etc]

> ash $location[noob cave].turns_spent

Returned: 1

> quit

(reopen)

> ash $location[noob cave].turns_spent

Returned: 1

> adv1 noob cave

Visit to Mountain: Noob Cave in progress...
[etc]

> ash $location[noob cave].turns_spent

Returned: 2

KoLMafia>Quit KoLmafia

(reopen)

> ash $location[noob cave].turns_spent

Returned: 1

I suspect it may have to do with the change in JDK 9 mentioned here and here. When I run mafia, the command line does output something about it:
Code:
WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by apple.dts.samplecode.osxadapter.OSXAdapter ([removed]/kolmafia-code/dist/KoLmafia-19.7.jar) to constructor com.apple.eawt.Application()
WARNING: Please consider reporting this to the maintainers of apple.dts.samplecode.osxadapter.OSXAdapter
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
WARNING: All illegal access operations will be denied in a future release
This version of Mac OS X does not support the Apple EAWT.  ApplicationEvent handling has been disabled (java.lang.ClassNotFoundException: com.apple.eawt.ApplicationListener)
This version of Mac OS X does not support the Apple EAWT.  ApplicationEvent handling has been disabled (java.lang.ClassNotFoundException: com.apple.eawt.ApplicationListener)
OSXAdapter could not access the About Menu
java.lang.NoSuchMethodException: com.apple.eawt.Application.setEnabledAboutMenu(boolean)
	at java.base/java.lang.Class.getDeclaredMethod(Class.java:2476)
	at apple.dts.samplecode.osxadapter.OSXAdapter.setAboutHandler(OSXAdapter.java:114)
	at net.sourceforge.kolmafia.CreateFrameRunnable.addOSXMenuItems(CreateFrameRunnable.java:357)
	at net.sourceforge.kolmafia.CreateFrameRunnable.decorate(CreateFrameRunnable.java:335)
	at net.sourceforge.kolmafia.CreateFrameRunnable.runConstruction(CreateFrameRunnable.java:302)
	at net.sourceforge.kolmafia.CreateFrameRunnable.createFrame(CreateFrameRunnable.java:182)
	at net.sourceforge.kolmafia.CreateFrameRunnable.run(CreateFrameRunnable.java:164)
	at java.desktop/java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:303)
	at java.desktop/java.awt.EventQueue.dispatchEventImpl(EventQueue.java:770)
	at java.desktop/java.awt.EventQueue$4.run(EventQueue.java:721)
	at java.desktop/java.awt.EventQueue$4.run(EventQueue.java:715)
	at java.base/java.security.AccessController.doPrivileged(Native Method)
	at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:85)
	at java.desktop/java.awt.EventQueue.dispatchEvent(EventQueue.java:740)
	at java.desktop/java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:203)
	at java.desktop/java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:124)
	at java.desktop/java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:113)
	at java.desktop/java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:109)
	at java.desktop/java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101)
	at java.desktop/java.awt.EventDispatchThread.run(EventDispatchThread.java:90)

The code at addOSXMenuItems() in CreateFrameRunnable.java:
Code:
OSXAdapter.setQuitHandler( KoLmafia.class, KoLmafia.class.getDeclaredMethod( "quit", (Class[]) null ) );
OSXAdapter.setAboutHandler( KoLmafia.class, KoLmafia.class.getDeclaredMethod( "about", (Class[]) null ) );
OSXAdapter.setPreferencesHandler( KoLmafia.class, KoLmafia.class.getDeclaredMethod( "preferencesThreaded", (Class[]) null ) );
Perhaps change those to use java.awt.Desktop.setQuitHandler() / etc?
 

Veracity

Developer
Staff member
The code at addOSXMenuItems() in CreateFrameRunnable.java:
Code:
OSXAdapter.setQuitHandler( KoLmafia.class, KoLmafia.class.getDeclaredMethod( "quit", (Class[]) null ) );
OSXAdapter.setAboutHandler( KoLmafia.class, KoLmafia.class.getDeclaredMethod( "about", (Class[]) null ) );
OSXAdapter.setPreferencesHandler( KoLmafia.class, KoLmafia.class.getDeclaredMethod( "preferencesThreaded", (Class[]) null ) );
Perhaps change those to use java.awt.Desktop.setQuitHandler() / etc?
Huh. That doc says that java.awt.Desktop is since 1.6, which we now require, although we did not when this code was originally written.

The following are all "since 9":

public void setQuitHandler​(QuitHandler quitHandler)
public void setAboutHandler​(AboutHandler aboutHandler)
public void setPreferencesHandler​(PreferencesHandler preferencesHandler)

However, the following is since 1.6:

public boolean isSupported​(Desktop.Action action)

as is Desktop.Action. Unfortunately, the enum values needed are also since 9.

public static final Desktop.Action APP_ABOUT
public static final Desktop.Action APP_PREFERENCES
public static final Desktop.Action APP_QUIT_HANDLER

Looks like we could recode to use java.awt.Desktop, but it would only compile on 9+.
I can experiment.
 
Top