SmartStasis -- a complex script for a simple CCS

Well... that's actually not entirely true. SS creates and generates a Macro that does nothing (executing WHAM from the Relay browser shows 1 round of "you twiddle your thumbs"). The generated macro contains batround only and nothing else which is... odd because I can see nothing in the code that I would expect to do that.

The generated macro can be seen in the example, if we extract just SS we get:
Code:
WHAM: Running SmartStasis
Profit per round: ActionProfitDamageOtherbase (0μ)0μ--
Building custom actions...
Custom actions built! (0 actions)
Constructed macro: scrollwhendone; sub batround; if haseffect 8 || haseffect 264 || haseffect 282 || haseffect 283 || haseffect 284; abort "BatBrain abort: poisoned"; endif; if pastround 49; abort "Stopping fight because it has gone on for too long (set WHAM_maxround to a higher value if you think this was in error)"; endif; endsub; ; call batround; 
Round 1: Arbos executes a macro!
KoLmafia thinks it is round 2 but KoL thinks it is round 1
Parsed round number: 1
Building options...
Options built! (13 actions)
Stasis action chosen: skill 11011 (profit: 40.92)
hot wing (30.0 @ +25.0): 32μ * 37.5% = 12.0
Imp Ale (30.0 @ +25.0): 25μ * 37.5% = 9.375
leather mask (5.0 @ +25.0): 65μ * 6.25% = 4.0625
Value of stat gain: 148.75μ
Attack action chosen: skill 11000
Top of the stasis loop.
Queued: skill 11011
Building options...
Options built! (12 actions)
Constructed macro: scrollwhendone; sub batround; if haseffect 8 || haseffect 264 || haseffect 282 || haseffect 283 || haseffect 284; abort "BatBrain abort: poisoned"; endif; if pastround 49; abort "Stopping fight because it has gone on for too long (set WHAM_maxround to a higher value if you think this was in error)"; endif; endsub; sub finito; skill 11011; call batround; endsub; call finito; repeat hasskill 11011 && (!hpbelow 134.0 && !mpbelow 32.0 && !pastround 25)
Round 2: Arbos executes a macro!
Round 2: Arbos casts INTIMIDATING BELLOW!
KoLmafia thinks it is round 3 but KoL thinks it is round 2
Round 3: g imp drops 16 attack power.
Round 3: g imp drops 16 defense.
Happened: skill 11011
Parsed round number: 2
Building options...
Options built! (12 actions)
Stasis action chosen: skill 2 (profit: -127.79)
hot wing (30.0 @ +25.0): 32μ * 37.5% = 12.0
Imp Ale (30.0 @ +25.0): 25μ * 37.5% = 9.375
leather mask (5.0 @ +25.0): 65μ * 6.25% = 4.0625
Value of stat gain: 148.75μ
Attack action chosen: skill 11000
This monster is not your huckleberry.
Stasis loop complete.
WHAM: SmartStasis complete.

As can be seen at the top SS generates a macro and executes that, after which Mafia gets confused and SS reparses the round number as still being 1.
 
Last edited:
Yeah, just fixed that. When I rearranged all the code, macro() ended up missing a check for an empty queue before submitting the macro. Since depending on the character that might mean a waasted server hit per fight, I'm posting that tiny but big update to the BB thread in just a few minutes!
 
There is still a bug on Cyrus.
I haven't isolated it yet but for some reason the property "usedagainstcyrus" keeps getting overwritten with an empty string. I think this is what is messing it up.
Or for whatever reason it keeps slinging the same pair.
 
Last edited:
Okay, as I mentioned in the BB thread, I didn't fix the empty macro submission like I thought with that last BB update. I did, however, fix it now in SS, but I'd like to add support for black boxes before posting a release. Tomorrow I expect to be able to add that, so a fixed version will be up then with black box support, and a fixed version of BB will also be up (there were some kinks in auto-funkslinging) and unless any serious bugs are reported that will be the last in this rash of (possibly annoying) updates for a while.

mredge: Hmmm. Okay, Cyrus will go on the list of things to investigate.
 
May I, now that the boss-proxy field exists, suggest that the Stomping Boots-check in SS gets turned into:
Code:
  // release the boots!
   if (my_familiar() == $familiar[stomping boots] && my_location() != $location[none] && get_property("bootsCharged") == "true" && 
       count(get_monsters(my_location())) > 1 && m.boss == false)) {

(since $phylum[none] no longer is unique for bosses and a lot of them now has a phylum)
 
I've got a problem with SS in BorisCore. Okay, technically this may be a problem with stasis_action()...

SS loves to use Intimidating Bellow on weak monsters that I can (and will) kill in a single hit. There's no profit in casting a 3 mp skill when I can kill the monsters for 0 mp without it.

This happens because if the monster is capable of hitting me, the massive delevel will reduce the monster to not being able to hit me and to_profit() multiplies that difference in damage by meatperhp. The only sane way to account for that is for stasis_action() to only count it as profit if kill_rounds(attack_action()) is greater than 1.

Here's a sample at verbosity 8:

Code:
Encounter: white chocolate golem
Round 0: bale wins initiative!
Running ZLib version: r35 (current)
Running Character Info Toolbox version: 0.6.5.0.1
Running ZLib version: r35 (current)
[COLOR="#880000"]1 HP costs 11.333μ. ( 382 / 382 )[/COLOR]
[COLOR="#000088"]1 MP costs 17μ. ( 61 / 93 )[/COLOR]
[COLOR="#D3D3D3"]Running BatBrain version: 1.20 (current)
Running SmartStasis version: 3.14 (current)
Running Destroy All Monsters version: 0.3.5.1 (current)[/COLOR]
white chocolate chips (50.0 @ +83.90416): 24μ * 91.95208% = 22.068499
Value of stat gain: 297.5μ
white chocolate chips (50.0 @ +83.90416): 24μ * 91.95208% = 22.068499
Value of stat gain: 297.5μ
ATT: [B]112[/B] (94% × 24.26, death in 17)
DEF: [B]100[/B] (95.45% × 477.01, win in 2)
HP: [B]96[/B], Value: [B][COLOR="green"]319.57 μ[/COLOR][/B]
Parsed round number: 1
Stasis action chosen: skill 11011 (profit: 200.67)
Profit per round: ActionProfitDamageOtherbase (0μ)0μ--
Stasis action chosen: skill 11011 (profit: 200.67)
white chocolate chips (50.0 @ +83.90416): 24μ * 91.95208% = 22.068499
Value of stat gain: 297.5μ
Attack action chosen: skill 11000
Queued: skill 11011
Constructed macro: scrollwhendone; sub batround; if haseffect 8 || haseffect 264 || haseffect 282 || haseffect 283 || haseffect 284; abort "BatBrain abort: poisoned"; endif; endsub; sub finito; skill 11011; call batround; endsub; call finito; repeat hasskill 11011 && (!hpbelow 382.0 && !mpbelow 61.0 && !pastround 25)

With my current strength of 211 and huge damage bonuses, using mighty axing will crush that puny monster with impunity so it certainly wasn't worth 200.67 to spend those 3 mp. I admit I can afford the mp cost, but it is a wasted server hit.
 
Last edited:
Ugh. This is a problem I've been having. In one of these fights it used my flyers. In the other fight it did not try to flyer. Why? It does not seem to be because of a lack of MP.


Code:
> zlib verbosity = 8

Previous value of verbosity: 3
Changed to 8.
Validating adventure sequence...
Condition added: tomb ratchet (3)

Running ZLib version: r35 (current)

Request 1 of 2 (Pyramid: The Upper Chamber) in progress...

[718] The Upper Chamber
Encounter: tomb rat
Strategy: C:\Documents and Settings\David.QUICKSILVER\My Documents\My Dropbox\KolMafia\ccs\default.ccs [default]
Round 0: bale wins initiative!
Running ZLib version: r35 (current)
1 HP costs 5.333μ. ( 277 / 416 )
1 MP costs 8μ. ( 16 / 105 )
Running BatBrain version: 1.20 (current)
Running SmartStasis version: 3.14 (current)
Running Destroy All Monsters version: 0.3.5.1 (current)
tomb ratchet (20.0 @ +116.749374): 2,000μ * 43.349873% = 866.99744
leathery rat skin (30.0 @ +116.749374): 150μ * 65.02481% = 97.53722
unidentified jerky (12.0 @ +116.749374): 90μ * 26.009924% = 23.40893
Value of stat gain: 626.88μ
tomb ratchet (20.0 @ +116.749374): 2,000μ * 43.349873% = 866.99744
leathery rat skin (30.0 @ +116.749374): 150μ * 65.02481% = 97.53722
unidentified jerky (12.0 @ +116.749374): 90μ * 26.009924% = 23.40893
Value of stat gain: 626.88μ
ATT: 236 (94% × 105.11, death in 3)
DEF: 216 (95.45% × 132.6, win in 3)
HP: 250, Value: 1,727.32 μ
Parsed round number: 1
Stasis action chosen: skill 11011 (profit: 228.36)
Profit per round: ActionProfitDamageOtherbase (0μ)0μ--
Stun action chosen: skill 11003
Stun action chosen: skill 11003
Custom action: use 2405 (stun first with skill 11003)
Stun action chosen: skill 11003
Queued: skill 11003
Queued: use 2405
Stasis action chosen: use 2678 (profit: 6)
tomb ratchet (20.0 @ +116.749374): 2,000μ * 43.349873% = 866.99744
leathery rat skin (30.0 @ +116.749374): 150μ * 65.02481% = 97.53722
unidentified jerky (12.0 @ +116.749374): 90μ * 26.009924% = 23.40893
Value of stat gain: 626.88μ
Attack action chosen: skill 11000
Attack action chosen: Mighty Axing
Queued: skill 11011
Destroy with: Intimidating Bellow
Attack action chosen: Mighty Axing
Queued: skill 11000
Destroy with: Mighty Axing
skill 11003
use 2405
skill 11011
skill 11000
Constructed macro: scrollwhendone; sub batround; if haseffect 8 || haseffect 264 || haseffect 282 || haseffect 283 || haseffect 284; abort "BatBrain abort: poisoned"; endif; endsub; skill 11003; call batround; use 2405; call batround; skill 11011; call batround; skill 11000; call batround; 
Round 1: bale executes a macro!
Round 1: bale casts BROADSIDE!
Round 2: bale uses the rock band flyers!
Round 3: bale casts INTIMIDATING BELLOW!
Round 4: tomb rat drops 71 attack power.
Round 4: tomb rat drops 71 defense.
Round 4: bale casts MIGHTY AXING!
Round 5: tomb rat takes 431 damage.
Round 5: bale wins the fight!
You gain 8 Muscularity Points
You gain 102 Meat
You acquire an item: tomb ratchet
You acquire an item: unidentified jerky
You gain 39 Strongness
You gain 13 Mysteriousness
You gain 13 Roguishness
Happened: skill 11003
Happened: use 2405
Happened: skill 11011
Happened: skill 11000
Parsed round number: 5
Look! You found 1 tomb ratchet (2,000μ)!
Look! You found 1 unidentified jerky (90μ)!
Happened: crit
Happened: skill 11003
Happened: use 2405
Happened: skill 11011
Happened: skill 11000
Parsed round number: 5
Look! You found 1 tomb ratchet (2,000μ)!
Look! You found 1 unidentified jerky (90μ)!
Happened: crit

Running ZLib version: r35 (current)
Restoring MP! Currently at 287 of 416 HP, 11 of 105 MP, current meat: 21065 ... Target MP = 21.
Purchasing black cherry soda (1 @ 80)...
You acquire an item: black cherry soda
You spent 80 Meat
Purchases complete.
Using 1 black cherry soda...
You gain 9 Muscularity Points
Finished using 1 black cherry soda.
Purchasing black cherry soda (1 @ 80)...
You acquire an item: black cherry soda
You spent 80 Meat
Purchases complete.
Using 1 black cherry soda...
You gain 9 Muscularity Points
Finished using 1 black cherry soda.

Request 2 of 2 (Pyramid: The Upper Chamber) in progress...

[719] The Upper Chamber
Encounter: tomb rat
Strategy: C:\Documents and Settings\David.QUICKSILVER\My Documents\My Dropbox\KolMafia\ccs\default.ccs [default]
Round 0: bale wins initiative!
Running ZLib version: r35 (current)
1 HP costs 5.333μ. ( 287 / 416 )
1 MP costs 8μ. ( 29 / 105 )
Running BatBrain version: 1.20 (current)
Running SmartStasis version: 3.14 (current)
Running Destroy All Monsters version: 0.3.5.1 (current)
tomb ratchet (20.0 @ +116.749374): 2,000μ * 43.349873% = 866.99744
leathery rat skin (30.0 @ +116.749374): 150μ * 65.02481% = 97.53722
unidentified jerky (12.0 @ +116.749374): 90μ * 26.009924% = 23.40893
Value of stat gain: 626.88μ
tomb ratchet (20.0 @ +116.749374): 2,000μ * 43.349873% = 866.99744
leathery rat skin (30.0 @ +116.749374): 150μ * 65.02481% = 97.53722
unidentified jerky (12.0 @ +116.749374): 90μ * 26.009924% = 23.40893
Value of stat gain: 626.88μ
ATT: 236 (94% × 105.11, death in 3)
DEF: 216 (95.45% × 109.94, win in 3)
HP: 250, Value: 1,727.32 μ
Parsed round number: 1
Stasis action chosen: use 2678 (profit: -386.09)
Profit per round: ActionProfitDamageOtherbase (0μ)0μ--
Stasis action chosen: use 2678 (profit: -386.09)
No valid attacks.
Attack action chosen: Cleave
Queued: skill 11001
Destroy with: Cleave
skill 11001
Constructed macro: scrollwhendone; sub batround; if haseffect 8 || haseffect 264 || haseffect 282 || haseffect 283 || haseffect 284; abort "BatBrain abort: poisoned"; endif; endsub; skill 11001; call batround; 
Round 1: bale executes a macro!
Round 1: bale casts CLEAVE!
Round 2: tomb rat takes 600 damage.
Round 2: bale wins the fight!
You gain 7 Muscularity Points
You gain 115 Meat
You acquire an item: leathery rat skin
You gain 40 Strongness
You gain 11 Wizardliness
You gain 13 Sarcasm
Happened: skill 11001
Parsed round number: 2
Look! You found 1 leathery rat skin (150μ)!
Happened: crit
Happened: skill 11001
Parsed round number: 2
Look! You found 1 leathery rat skin (150μ)!
Happened: crit

Conditions not satisfied after 2 adventures.

> flyer

Completed 7534 out of 10,000 = 75.34%.
 
I found a limit to enqueue_combos(). Unfortunately it removes each combo from the list as it enqueues it. That means I cannot test several macros that combos.

Is there any advantage to remove combos[n] or will you remove it from the next version? Since SS only calls that function from try_combos(), the same result will be caused by adding clear(combos) to the end of try_combos().


Edit: Huh. I just deleted that line from my version of SS and I'm still not getting combos in my macros. More investigation is needed since there may be another problem. Still, this was definitely not helpful.
 
Last edited:
I found the other half of my problem, but I don't understand it. For some reason reset_queue() prevents all the combos from being queued.... Huh? I cannot figure that one out.
 
The "correct" fix to this is my original plan of simply adding combos to opts[] as part of build_options() rather than their own separate deal, which is a vestigial format from the pre-BB SS. Once that fairly big rewrite is done, profitable combos will naturally occur as part of the stasis loop, and the build/enqueue/try combos functions will be no more.

Until then, if we (meaning mostly you) work out an alternative solution I'll definitely give it a go, but I don't have a whole lot of motivation to get that working given the long view. Are you calling build_combos() again to populate combos after you reset the queue? If you're not, you need to -- enqueue_combos() will not also rebuild the combo list.

Also, what??

BatBrain does not exclude "once" items based on happened()

It totally does.
 
Are you calling build_combos() again to populate combos after you reset the queue? If you're not, you need to -- enqueue_combos() will not also rebuild the combo list.

reset_queue() removes the work done by build_combos() and build_custom()? That would explain my problem. Oy gevalt! Simple enough to fix although a little troubling. It means calling buld_combos() and build_custom() a few more times than I would like to do so.

Thank you for the simple solution.

It totally does.

Just took a look. You're right. Once upon a time it did not so I had to build in a work-around in DAM. I guess I don't need that anymore.
 
Last edited:
Siphon Spirits is looking a little tricky.

First, always use it to get goal drinks.

Second, always use it when red. Wait, no, because maybe you only want to get drinks that boost your primestat.

Well, always use it for primestat red-aura drinks then? Okay.

Maybe some players want to use it for any red-aura drink regardless of stat, to get maximum +turns from their familiar. Okay, we'll need a setting, perhaps named siphon_primestat_only. If it's false, it won't discriminate based on stat.

Should we pay attention to level requirements? Probably most HC players will not reach level 8 on Day 1, so they wouldn't even be able to drink a Day 1 red-aura drink. They should thus stick to blue or orange. But maybe they want to stockpile drinks for later!

I'm kind of drawing a blank on how best to support this. Those who requested support for it: how would you like SS to support this skill? Am I on the right track with the first couple bits at least?

@Winterbay: Just saw your post about not stomping bosses. Will be in the next release, but I'm still skipping gooey paste and $item[none].
 
Last edited:
I'd go with a zlib ss_siphon_color setting that would specify what color to siphon at, maybe with a "none" setting for disabling.
 
Mighty Axing doesn't work if Trusty isn't equipped. Pretty certain this is a SS/BB issue as both WHAM and DAM are happily using it to no effect.

Edit: Errr, maybe not actually.

Also, I am forcing Boris to use Mighty Axing instead of Attack to workaround a currently existing bug in BatBrain.

I'll go post over there, although WHAM is doing the same thing.
 
Last edited:
Back
Top