home
about
logo
blog
contact
portfolio music conlangs video games board games puzzles square dancing

A Slay the Spire puzzle

2024-02-21 23:56 -0500 gamesvideo gamesslay the spirepuzzlesmath

You are peacefully going about your day when you are suddenly thrust into the following position in a game of Slay the Spire. What do you do?

(This puzzle is probably not particularly accessible to readers who haven't played Slay the Spire, but if you want to try it anyway, here's an excessively detailed explanation of all the mechanics at play.)

Obviously, the rest of this blog post contains spoilers for the puzzle, so stop reading if you want to solve it yourself.

how did we get here?

On my path to unlocking all the Watcher ascensions, I found myself on floor 48 (the floor before the final act 3 campfire) with a deck that absolutely would not beat Awakened One. It had literally no scaling, and my plan for pretty much all of act 3 was "I have two Scrawls and if I find Rushdown I go infinite". I don't have screenshots from before the boss fight, but the deck was:

Floor 48 was a shop, which I had pathed to in order to find literally anything to save me -- maybe a potion, but realistically probably an infinite enabler. (Which in practice means, yes, I was basically just thinking "hello please give me Rushdown".)

I opened the shop, and I did not find a Rushdown. Instead, I stared at the shop, thought for a long time, and decided there was exactly one thing I could do in that shop to maximize my chances of survival: remove a Strike, buy a Blessing of the Forge, and buy both colorless cards on offer:

Certainly unconventional, but the justification was that my only hope was pulling an infinite out of the Chrysalis. And as you might guess, that's what the puzzle is about.

(I am about to reveal the answer, so now is your last chance to stop reading if you want to try finding it!)

the provable infinite

It is possible to guarantee infinite damage/energy/block on both phases of Awakened One, and therefore provably win the game, from the pictured state. As a reminder if you don't want to scroll up, the hand is

and the draw pile is

The infinite, assuming all cards in hand, goes like this:

  1. Cut Through Fate drawing Empty Mind+
  2. Worship for +5 mantra
  3. Inner Peace to enter calm
  4. Empty Mind+ for +2 energy drawing Cut Through Fate, Worship, Inner Peace

Since Worship is free from Chrysalis, each cycle costs 3 energy. But you get 2 back from leaving calm, so each cycle costs net 1 energy. And every other cycle you enter divinity and gain 3 energy, for an overall gain of 1 energy every two cycles. In the meantime, Cut Through Fate has been doing infinite damage (and you can replace Worship with Pressure Points after accumulating enough energy to speed things up greatly).

How do you guarantee it? Exhausting down to 6 cards is definitely enough, since if your initial draw has Cut Through Fate you just start the cycle, and if not you play Empty Mind first. This amounts to playing Purity+ for 5, and also playing Collect for anything. Scrawl draws all but 3, and then Inner Peace followed by Empty Mind just leaves 1. If it's Purity or Collect, you have Cut Through Fate, so play it. Finally, drink the Blessing of the Forge, play Collect, and play Purity on 5 garbage cards (there are only 4 cards in the infinite, 2 of which are in discard, and there are 8 other cards in your hand, so at least 8 - 2 = 6 of them are garbage).

Of course, you might not have to do any of this -- I Scrawled into Purity Collect and was able to immediately start the infinite. It's probably possible to guarantee actually executing the infinite this turn, especially with Duplication Potion and Distilled Chaos, but I didn't bother figuring it out since you can tank the current hit anyway.

Cool! So that's it for this post, right?

that's it for this post, right?

... well.

That was a pretty lucky Chrysalis. The entire strategy hinged on the free Worship that it generated. So just how lucky did I have to get to win this game?

For the sake of simplicity, let's say I win if I go infinite and I lose if I don't. This isn't really true, because I'm sure there are plenty of ways 3 free skills can be good enough without being infinite, but it's obviously impractical to analyze them all, so this will at least give a lower bound.

It's still impractical to compute the probability of an infinite, right? Well let's do it anyway. Here's a categorization of all the Watcher skills based on what they would do for my deck:

Great! Let's run the numbers. Barring garbage turn 1s like Strike Strike Defend Eruption Empty Fist, it's reasonably safe to assume that by the end of turn 2, we can achieve the following:

After all of that, the deck will have 7 cards left: 9 non-exhausting cards originally, plus 3 from Chrysalis, minus 5 from Purity+. Is that enough to get the infinite up consistently? If you can manage to end turn 2 in calm, the answer is yes: you draw at least one of Cut Through Fate, Inner Peace, or Empty Mind+ on turn 3. If not... the answer is still probably yes, because even if you bottom deck both Cut Through Fate and Empty Mind+, there are ways to save yourself (e.g. either potion, if you didn't use them both during setup).

... unless your infinite is Evaluate or Sanctity, which only block, because then it needs to work for probably hundreds of turns as you slowly chip away at Awakened One's HP (which is regenerating). Ouch. For Sanctity, once you get your infinite once, you can choose to end the cycle when you're in calm, so 7 cards is fine. Awakened One is sometimes giving you Voids, but you will still draw at least one of Sanctity Cut Through Fate Inner Peace Empty Mind+, and the infinite only has a startup cost of 2.

It's worse for Evaluate. You definitely need the Insight to be retained at the end of each turn (otherwise you have 9 cards including Insight and Void, and only 4 of them say draw, so in one of the hundreds of turns you will almost definitely miss all 3). But that means you can't end your turns in calm, so you still lose, because even with only 8 cards, now Inner Peace stops saying draw. So you need at least one of your Chrysalis cards to come from the Exhaust/Retain category above. That lets you end all your turns in calm, and then you have 8 cards and can't miss all of Insight Cut Through Fate Inner Peace Empty Mind+.


Ok! So after all of that... what you need out of Chrysalis is either:

Let's take care of the first case first: there are 32 legal Watcher skills, and 6 of them are hits, so the probability that you get any of them is 1 - (1 - 6/32)³ = 46.36%. Okay, that's not bad.

Now for the Evaluate case. Let's count the ways to draw a good Evaluate infinite by splitting on how many you get. There's 1 way to draw three Evaluates. There's 3*25 ways to draw two Evaluates plus a non-infinite non-Evaluate card. And there's 3*(14*25 + 25*14 - 14*14) ways to draw exactly one Evaluate and two non-infinite non-Evaluate cards, at least one of which is in the set of 14. So the chance you don't get any of the easy infinites but you do get an Evaluate infinite is 1588/32768 = 4.85%.

Adding those together, it comes out to a 51.21% chance of Chrysalis giving you what you need. So just over half! Given that I think almost any other decision at the shop would have given me a <10% chance of survival (this relies on all 4 purchases of Chrysalis, Purity, Blessing of the Forge, card remove), I feel vindicated in my decisions.

... er, hang on a second.

I just counted the Watcher skills again, and there's actually 34 of them, not 33. Did I forget one?

... oh no.

oh no

I saved this one for last because it adds, uh, a bit more complexity, shall we say. (The probability that it matters is many times lower than the effect of various other assumptions I made, so I could just ignore it, but that would be lame.)

The upgrade says "it costs 0 this turn", but unfortunately that actually means "it costs 0 until leaving your hand", so it's basically useless. Also, you're allowed to skip the card, so at worst Foreign Influence goes under "Exhaust/Retain" (and therefore enables Evaluate all the same). So we only need to consider cards that actually go infinite themselves.

Let's start with all the whiffs. Fundamentally, the problem with the deck as is is that the infinite cycle Cut Through Fate Inner Peace Empty Mind+ is net -1 energy. So you need something that either generates energy or draws for cheaper. None of these cards can help with that:

Anger Bash Blood for Blood Bludgeon Body Slam Carnage Clash Cleave Clothesline Fiend Fire Headbutt Heavy Blade Hemokinesis Immolate Iron Wave Perfected Strike Pummel Rampage Reckless Charge Searing Blow Sever Soul Sword Boomerang Thunderclap Twin Strike Uppercut Whirlwind Wild Strike All-Out Attack Backstab Bane Choke Dagger Spray Dash Die Die Die Endless Agony Eviscerate Finisher Flechettes Flying Knee Glass Knife Grand Finale Masterful Stab Poisoned Stab Predator Riddle with Holes Skewer Slice Sneaky Strike Sucker Punch Unload All for One Ball Lightning Barrage Beam Cell Blizzard Bullseye Claw Cold Snap Compile Driver Core Surge Doom and Gloom FTL Go for the Eyes Hyperbeam Melter Rebound Rip and Tear Streamline Sunder Thunder Strike Bowling Bash Brilliance Carve Reality Conclude Consecrate Crush Joints Empty Fist Fear No Evil Flurry of Blows Flying Sleeves Follow-Up Just Lucky Ragnarok Reach Heaven Sands of Time Sash Whip Signature Move Talk to the Hand Tantrum Wallop Weave Windmill Strike Dramatic Entrance Hand of Greed Mind Blast Swift Strike

Of the remaining ones:

So that's just 3 out of 107 cards that might work, and two of them have pretty strong caveats given that the deck has no source of vulnerable/weak. How can we get those?

Unsurprisingly, these probabilities are extremely obnoxious to compute. I've hidden the details for your sake, but you can still see them if you really want to.

show/hide details

Alright, so let's count how many ways there are to draw something good by casework again, at the same scale for sanity (so that e.g. the number of ways to draw a Foreign Influence as your first Chrysalis card which gives Dropkick as the first choice is 1/107). There are 33 legal Watcher skills to come out of Chrysalis; we're assuming we didn't get any of the 7 infinite enablers, so we're actually working with a pool of 26.

For futher sanity, we can define f(n) = 1-((107-n)/107)((106-n)/106)((105-n)/105) to be the probability that you find any of n cards in a Foreign Influence roll. Also, f(n,m) = (1-f(m))(1-((107-n-m)/(107-m))((106-n-m)/(106-m))((105-n-m)/(105-m))) is the probability you failed to find any of m cards but did find any of n cards.

With multiple Foreign Influences, you need to specify a strategy -- fortunately, there's a clearly best one, which is to pick the card resulting in the largest increase in number of possible cards to complete an infinite.

Here's some Ruby code to add everything up:

def g n, t; 1-((t-n)/(t-0))*((t-1-n)/(t-1))*((t-2-n)/(t-2)); end
def f n, m=0; (1-g(m, 107.to_r))*g(n, 107.to_r-m); end
def out x; puts x; puts x.to_f; end

one = 3 * (2*f(3) + 2*(2*24-1)*f(2) + 23*23*f(1))
twofi = f(1) + f(2,1)*f(6) + f(1,3)*f(3) + f(8,4)*f(2) + (1-f(12))*f(1)
two = 3 * (2*(f(2) + f(5,2)*f(3) + (1-f(7))*f(2)) + 23*twofi)
three = f(1) + f(2,1)*(f(6) + f(1,6)*f(10) + f(4,7)*f(7) + (1-f(11))*f(6)) +
    f(1,3)*(f(3) + (1-f(3))*f(3)) +
    f(8,4)*(f(2) + f(1,2)*f(7) + f(5,3)*f(3) + (1-f(8))*f(2)) +
    (1-f(12))*twofi

total = 33**3

out one/total
out two/total
out three/total
out (one+two+three)/total

Which gives the output:

4012997/2377651815
0.001687798429813408
71552617889/471928220500275
0.00015161758670237925
103503659463493/31223557615332361125
3.3149220450352337e-06
57536615629709323/31223557615332361125
0.0018427309385608227

When all is said and done, it turns out the probability that you don't get an immediate infinite, but Foreign Influence saves you, is... 0.184%.

Redoing the numbers from before, we get a 1 - (1 - 6/33)³ = 45.23% chance of a 1-card infinite, and a 1744/35937 = 4.85% chance of an Evaluate infinite. Adding everything up, the chance of any infinite is 50.266%, which is lower than if Foreign Influence didn't exist (obviously) but still just above half!

but why?

idk math is fun

comments

There are no comments yet.

formatting is supported. comments require manual approval.