XaiJu
Shattered Pixel
Shattered Pixel

patreon


Seeded Deck Sequences | Patreon Weekly #229

Hey Patrons, I’m taking a short break from new development, so in this weekly I’m going to briefly talk about v2.2.0’s release and do a little deep-dive into a bug I fixed recently.

There’s also new Shattered Secrets this week! In this Shattered Secrets I share a rough idea for another new challenge!

Lastly, next week’s weekly will have an audio Q&A segment! Feel free to ask questions either here or on the Patreon discord.

v2.2.0 Release

v2.2.0 released on Wednesday last week, and so far has been doing extremely well! Mostly the results are within the expected range for an update of this size, but one notable difference is how I’ve handled this update’s release on Steam.

I decided to pair the update with a Steam sale event and some mild changes to the game’s store assets to highlight that it was recently updated. The result has been astounding, with more sales and activity in the last couple days than any time since the game’s release, even beating v2.0.0. Take a look at this chart of active Steam players!

The initial peak and level off is the game’s release of course, and the two spikes are v2.0.0 and v2.2.0 respectively. Other sale events and update releases barely even register.

Settings up sales and slightly changed store assets is extremely easy, so I’ll definitely be doing that with every major update on Steam moving forward.

I’m also beginning work on a v2.2.1 patch that will mostly be bug fixes, but may include some balance tweaks (depending on analytics numbers), and might include a couple more spritework improvements too.

Bugs with Seeded Runs and Weapon Decks

This somewhat wordy section covers a bug I recently found and fixed just before releasing v2.2.0.

ShatteredPD can be given a ‘seed’ value when generating a dungeon. The same seed value always results in the same output from the random number generator Shattered uses for levelgen. So, if two runs use the same seed, you get the same dungeon in each.

Or at least, that’s what’s supposed to happen. Unfortunately, a little bit ago I got a report from a player who was streaming some seeded runs and happened to do two runs of the same seed back to back. On floor 6, in a traps room, they first found a round shield, and then next run they found a longsword.

Whoops. I had actually gotten sporadic reports of weapons differing before as well, but nothing that was nearly this concrete. So why were the weapons differing?

Shattered uses a sort of deck system when determining what specific items are dropped as part of level generation, to increase overall consistency. For example, if the game generates a T3 weapon, it uses a shuffled deck where each T3 weapon has 2 cards. These decks are only supposed to be used during level generation.

But very clearly something had happened here, because the decks were in different states. Something had caused the run on the right to draw an extra card at some point, putting the runs out of sync. Even worse, after pouring over footage I noticed that one run had a shortsword in the shop and the other had a sickle.

Those are T2 weapons, which use a different deck! So not only was there a bug, but it had happened multiple times to different weapon categories! I spent a lot of time going through footage and was stumped. It seemed that whatever caused this was totally unrelated to the items the player actually got on floors 1-5.

After looking over more footage and comparing it to my own generated run using the same seed, I noticed another error in the second run (first run ended in the prison). T4 weapons eventually got out of sync too on floor 12. Then I noticed something in floor 11: A statue room.

This seed also had a statue room on floor 1. I previously hadn’t considered statue rooms, as they are pretty obviously generated one time as part of levelgen. But having a statue room appear shortly before every inconsistency didn’t seem like a coincidence. When looking at statue code I noticed the problem:

Weapons were being generated every time a statue was created and added to the game world, regardless of whether they were being spawned by levelgen or by level loading. When the statue loads, it draws a new weapon from the deck, then discards it when its saved properties are loaded in.

The inconsistency was caused by the player choosing to return to the floor 1 statue to fight it after gearing up, which caused it to silently draw extra weapons from the deck! The same thing happened again in the second run when the player left and re-entered floor 11 while ferrying items to the shop!

With the cause found, fixing the bug was pretty simple. Nowadays most bugs with Shattered are pretty easy to peg down, so it was interesting to find one that required such a deep investigation. I’m glad to have found it as well, as it’s really important that seeded runs have rock-solid consistency. Hopefully that’s now the case.

Comments

That's correct, and this only started to matter recently, when I changed weapons to use a deck system. I would like to do more of these deep dives, but there often isn't as lengthy an investigation, as good of a story to tell, or there's new content I'm also working on that takes priority.

Shattered Pixel

so every time you loaded a floor with a statue, it generated a weapon, then remembered it already had a weapon assigned to it and threw out the new one it was generating? that's really fascinating, i'm a huge fan of these kind of bug analyses - especially when they're so hard to isolate and solve, and there's an interesting cause behind them. also good to have it fixed now!

Lassoloc


More Creators