#Save reloading after a game restart changes shuffles

1 messages · Page 1 of 1 (latest)

full smelt
#

Thanks to drspectred for telling me about this bug and showing me a way to reproduce it easily.

How to reproduce:
Start a run on the seed 86FCYI81 on Abandoned Deck, White Stake.
In round 1, win with a Four of a Kind of 5s. (Your actions here don't matter, this is just the fastest way.)
Open the Buffoon Pack, then close and reopen the game.
Buy DNA and Certificate.
In round 2, immediately duplicate the Gold Seal Ace of Spades and win with two Full Houses.
Open the Mega Arcana Pack.

Without this bug, you will see the Gold Seal Ace of Spades, but it doesn't appear if you relaunch the game mid-run.

#

next round shuffle on this seed; you again only get the gold seal ace of spades if you don't perform the bug

safe zephyr
#

this is a bug in vanilla or result of a mod?

full smelt
#

vanilla afaik

full smelt
safe zephyr
#

ah well that's not very good

full smelt
#

my guess is that the sort_id of cards get screwed up somehow

#

but why that would only happen on a full game restart puzzles me

slender urchin
#

I experienced something similar to this back then I did highest seeded score, it happened on to-do list joker, hand requirement was different when I relaunched the game

dense saddle
#

Also looked through the seed and found oops all 6s, space joker, brainstorm and trance in seed so maybe worth putting in #1156061354076155944

full smelt
#

I found a fix to this!

[[patches]]
[patches.pattern]
target = "card.lua"
pattern = "self.sort_id = cardTable.sort_id"
position = "after"
payload = "G.sort_id = math.max(self.sort_id, G.sort_id or 0)"
match_indent = true

The way Balatro knows how to sort cards is with a counter that starts at 0 when you launch the game and increases by 1 every time a card is created.
What this means is that when a card is added to the deck it will always have the highest sort ID when calculating a shuffle.

However, this order is messed up when loading a save that has higher sort IDs than the game's current sort ID, which means any RNG relying on that becomes inconsistent.

This patch adds a check to ensure that the game's sort ID is always large enough to not break shuffling.

spark glen
#

Assuming that I have a run on another profile with a sort Id close to the in overflow.

Is it possible to affect the id this way.

In my testing, the sort id was not linked to one profile alone and can be increased/influenced by all profiles

full smelt
#

Overflows don’t really happen in Lua because all numbers are doubles

#

And the limit is so large that it would take years to increase the sort_id to a large enough value

#

Which would then cause it to stop increasing

spark glen
#

Ok thx.
Assuming I load a (likely cheated) save before starting my run. This would then mess up everything. But that should then be easily detectable.

So thx again for the patch

full smelt
#

yw

full smelt
spark glen
full smelt
spark glen
#

Thx for this change 👍🏻
Then it is really only possible to do stupid stuff when you spend until the end of time to increase the counter

spark glen
#

Can you please move the timer further up. I know that it is irrelevant for most people but this run likely has over 400 cards in the deck at some point.

full smelt
spark glen
#

sorry wrong chat sry.

full smelt
#

its ok

full smelt
#

Update: It's also possible to manipulate the sort_id by creating cards in the HUD
(deck view, poker hand examples, redeemed vouchers, deck selection, collection, etc.)

spark glen
#

Did my replay file help you figure that out?

I only knew about the deck preview because in the run that I manipulated I noticed some rather consistent offsets and that was what I guessed

full smelt
#

It did - since it made me decide to dig deeper