Page 1 of 3 1 2 3 LastLast
Results 1 to 10 of 21

Thread: Maximizer NullPointerException

  1. #1
    Senior Member ckb's Avatar
    Join Date
    Mar 2006
    Posts
    996

    Default Maximizer NullPointerException

    I seem to [sometimes] get a NullPointerException during Maximize in one of my scripts. Re-running the script after this happens continues as normal. Not sure what/why.
    DEBUG log attached.
    Attached Files

  2. #2
    Developer fronobulax's Avatar
    Join Date
    Feb 2009
    Location
    Central Virginia, USA
    Posts
    4,868

    Default

    What was ckb1 trying to do near turn 819 and 1188? Any chance the maximizer string got logged?

    If you set scriptMRULength to something greater than zero the next debug log will include the last script that was "registered" as recently used, which might help.

    I'd be interested in the items that are available for offhand use to ckb1 since that seems to be a consistent theme in the debug log.

  3. #3
    Senior Member MCroft's Avatar
    Join Date
    Feb 2009
    Location
    Texas
    Posts
    251

    Default

    I've started playing with the Maximizer dump/2 dump parameters recently. I wonder if that would fire before the error and list items being considered that might be null.

  4. #4
    Senior Member ckb's Avatar
    Join Date
    Mar 2006
    Posts
    996

    Default

    I ran a few scripts... not sure which one caused this. I will keep track of the maximizer string for next time it happens. I pulled this string out of my logs - it is a typical maximize string from my script.

    Code:
    1 hand, -equip red shirt, -equip saucepan, -equip Helps-You-Sleep, -equip HOA zombie eyes, 0.05 MP regen, -50.0 combat rate, 0.1 familiar weight, 2.0 item drop, -0.001 mana cost, 0.8 meat drop, 1.0 spell damage, +equip The Crown of Ed the Undying, +equip latte lovers member's mug, -familiar

  5. #5
    Developer Veracity's Avatar
    Join Date
    Mar 2006
    Location
    The Unseelie Court
    Posts
    13,671

    Default

    It's finding a null in your inventory. Can't even begin to speculate on how that happened.

  6. #6
    Senior Member ckb's Avatar
    Join Date
    Mar 2006
    Posts
    996

    Default

    It's finding a null in your inventory. Can't even begin to speculate on how that happened.
    Originally Posted by Veracity View Post
    This reminds me of another bug report from a while ago... and I found this:
    https://kolmafia.us/showthread.php?2...uring-maximize

    Still not sure how or why this happens (to me apparently).

  7. #7
    Senior Member ckb's Avatar
    Join Date
    Mar 2006
    Posts
    996

    Default

    More info pulled from my sleepy head this morning... I have the property 'maximizerCombinationLimit=333333' currently.
    With a very large inventory (in AfterCore) this sometimes fails to correctly meet all maximize requirements. Increasing the maximizerCombinationLimit sometimes helps, some I have noticed that if it is low enough, maximize runs a lot faster, but it will fail sometimes for a condition that is already met.
    For example, including "outfit Frat Warrior Fatigues" in the maximize string with a low maximizerCombinationLimit, maximize will try to change equipment with a limited set and not meet all conditions - such as ending up without the Frat Warrior Fatigues outfit on. Running maximize again with the same string will yield the expected results of wearing the outfit.

    Here is another post example I had, which I believe is related to this same issue of Maximize cutting short when maximizerCombinationLimit is low:
    https://kolmafia.us/showthread.php?2...-inconsistency


    So... perhaps something with how Maximize is hitting this limit is causing it to give a result of 'null' for a piece of equipment and hence causing the NullPointerException.

    My other hypothesis is that Maximizer with maximizerCombinationLimit will give different / inconsistent results depending on if some of the ideal equipment is currently being worn or not.
    Last edited by ckb; 10-08-2020 at 03:51 PM.

  8. #8
    Developer fronobulax's Avatar
    Join Date
    Feb 2009
    Location
    Central Virginia, USA
    Posts
    4,868

    Default

    I note the compareTo that is referenced in one of the logs is

    Code:
    		if ( this.compareTo( Maximizer.best ) > 0 )
    		{
    			Maximizer.best = (MaximizerSpeculation) this.clone();
    		}
    from MaximizerSpeculation.

    best is a static member of MaximizerSpeculation and successfully executing this compare is only one of two places that I can find that it gets set. (The other is in Maximizer, I think but I closed the search and don't need the right answer badly enough to do it again).

    I can certainly speculate about a code path where we are speculating and have not found anything good enough before we end up here.

    There are two obvious actions - one would be to check best for null and not make the compare if it is. That leaves it unset but may just cause something further on to fail. The other would be to set best to the clone of this if best is unset or if this is better.

    i.e.

    Code:
    		if ((Maximizer.best == null) || ( this.compareTo( Maximizer.best ) > 0 ))
    		{
    			Maximizer.best = (MaximizerSpeculation) this.clone();
    		}
    That approximates the pattern where you initialize a search with the first element.

    This being the Maximizer and in the presence of a whole lot of recursion I'm reluctant to make that change solely on my own understanding but I would try it if there are no better suggestions.

  9. #9
    Developer fronobulax's Avatar
    Join Date
    Feb 2009
    Location
    Central Virginia, USA
    Posts
    4,868

    Default

    Well I am running with the Maximizer.best == null added and so far, no problems. Of course since I couldn't reproduce the dump my experience really means nothing.

  10. #10
    Developer fronobulax's Avatar
    Join Date
    Feb 2009
    Location
    Central Virginia, USA
    Posts
    4,868

    Default

    try r20458.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •