One hilarious thing is, the Nintendo Power Strategy Guide for Mario 3 included a diagram of all eight possible configurations. So someone noticed this flaw early on.
@@Wendy_O._Koopa To be fair, NOA nor Nintendo Power would have not known how the game was programmed, so many "bugs" were featured as tricks and tips out of ignorance of it being unintended
@@xxEzraBxxx I still have that Strategy Guide, and the wild thing is (well, _another_ wild thing) that the diagrams aren't screen shots (which back then meant physically using a camera to take a picture of the TV) they're hand drawn. Which means (I'm speculating) that they assumed there were going to be hundreds, thousands, maybe millions of combos; and were writing them down by hand (so as not to waste film). Soon they discovered that there were only eight, and they didn't have to figure out any "tips _or_ tricks," just post those few... only they didn't have pictures. Anyone can draw a Super Mushroom, right? Well, for some reason they're green... like dark green stems and light green caps, and orange and red spots. To be fair SMB3 Super Mushrooms _are_ orange and red... but not like _that._ And the 1up chests? they're just blocks that say 1up. The flowers and stars look alright, the coins for some reason are rings with either 10 or 20 written inside of them. I used to think Sega stole Sonic's rings from my bracelets, but maybe it was from Nintendo Power? _Freaky._
@@Wendy_O._Koopa I highly doubt they would start writing them down by hand or even take photos of it if they thought there would be hundreds of combos. The only way it makes sense to begin drawing them down is if you happened to notice you got duplicates first, or had some suspicion there were a manageable amount
@@ITR First of all, you realize that by "writing them down" I mean in some form of shorthand, right? Like FSEF2M-1M2EM1-SFSMFS where E=Extra Life and 1 & 2 equal 10 & 20 coins, etcetera. And, yes I guess it makes sense that they suspected they had a manageable amount; but the best way to find out how many is to just take notes as you go. I know this isn't the original drawing, because it reuses all it's assets, the Mushrooms may look strange, but it's the same strange looking Mushroom each time.
I knew it! I knew there was a random delay in that damned game. My whole life, I've tried to master that game, but there's always been something odd happening with it not slowing and stopping right. I originally thought it was just some frame lag. I feel vindicated now.
I don't think that was a mistake--it's effectively a slot machine, it's supposed to give you an illusion of control about winning (based on the first two) and then take away your agency (third one).
Ever since I was a kid, I knew about the 8 card arrangements. I also thought it was just that they had hard coded those eight boards and the only RNG was to determine which of the eight you got.
Ironically it seems they must've wanted to keep that cause every remake of SMB 3 from then on did keep the 8 configurations and given they were all written from the ground up and it seems unlikely they would deliberately keep unnecessary code with such a glaring bug, but also... the fact that you could memorize the 8 decks is challenging yet fair enough for any casual player and we all generally agreed the roulette minigame was bull, but... given the end of level cards are super easy to match and all you get are lives, it never really bothered us. Yet another case of turning a bug into a feature (hello SMB wall jump)
I wonder if the last 3 cards was actually an easter egg, or if the minigame was originally going to have one fewer column, the shuffling code was written for that, and then they forgot to change it after adding the last column (e.g. maybe when designing the graphics they realized they had more screen real estate than they initially guessed)
It would be really odd for them to have one less column, assuming the plan was always to be able to match every card. That might not be the case, of course; but hard to really make any calls on it given it's a pretty odd quirk to begin with.
I was thinking perhaps they were intending on randomizing the number of cards involved in the rotation, which could add a bit of random spice of the number of cards involved is set to something between 2 (doing some swaps) and 18 (cycling the whole set of cards)
Actually, according to the Cutting Room Floor, the game was originally going to have a 'wild card' this would make sense if it was 15 'cards' and a wild card, then adjusted to 18 by just putting 3 cards at the end
These videos are always right to the point, are laid out in an understandable manner despite their complexity, and never use obnoxious music or flashy images. Please never change.
Yes! Very easy to watch where even if you don't understand math or know how programming works, it still is fairly easy to understand and if you DO know how those work, it's a nice bonus on rewatch. These youtubers make WAY better teachers than actual professors at college.
I beg to differ, I wish he instead would create clickbait titles, put his face on the thumbnail with him looking shocked and an arrow pointing to a blurred out section of code. I think something like "The Reason You Never Beat This Minigame!" or "Why You Always Were Terrible At This Popular Game." Those are my favorite videos, this one is also missing a animation of a mouse clicking a like and subscribe button with that sweet sound effect. I'm also really disappointed there wasn't a 2 minute Nord VPN ad and a 4 minute Raid: Shadow Legends ad in the middle of it.
The illustrations are really well done too and often go the extra mile to look smooth or informative, but without drawing too much attention away from the narration. This is such a perfect channel.
I was not a obsessed kid but i liked watching NOVA with my dad later in life, so that was my first exposure to the phrase. Makes me smile. And also sad.
Fascinating! I always thought the Card Matching game just used hardcoded sets and wasn't determined by an algorithm. The weird thing is, in New Super Mario Bros. Wii, the equivalent maching game in Toad Houses actually _does_ use hardcoded sets (or rather, they're defined by the level data).
It's entirely possible that they implemented the algorithm, but decided that having true total randomness for the card layouts wasn't what they wanted, and made intentional changes to limit the possible outcomes to just eight sets. It's hard to know what really happened, but it's fascinating to learn they weren't simply hard-coded layouts!
Considering their past experience with SMB2 Japan/The Lost Levels being rejected by Nintendo of America and them having to repurpose Doki Doki Panic because the other game was just too damn hard, and how SMB3 is not exactly the easiest of games and is a big one, they may have decided that giving a couple extra easy-to-attain power-ups for your inventory was a nice way of smoothing out the experience a bit. Also, the fact that the N-card game rarely appeared for those who didn’t know exactly how to trigger it made it more difficult… As a player who never had access to Nintendo Power but who had quite a lot of hours of gameplay, I quickly realized there was a limited number of arrangements and, over time, developed my own strategy to identify which of them it was, and figured that starting from the corners was an easy one (stars usually bunch up there). I developed a sort of a “feel” for it, and kind of have a mental model of how they’re structured, so I usually clear the board in a couple of attempts.
@@Mainyehc It was more rejected because it was SMB1 but with new graphics, different levels and few new elements (aka "Mission-Pack Sequel") and not necessarily because it was too hard (though it's still a contributing factor, just not the only one). What's even further funny is that SMB2 (the international version) originally was a Mario game before it was repurposed as a promotion to Fuji Television.
I had exactly the same thought. Bug or a clever way to limit it to just a few layouts by commenting out a few lines? It appears the feature was completely implemented and changed during play testing.
@@Mainyehc N-card game appeared at regular intervals [it was just every 80,000 earned points], the white mushroom house and treasure ships were the ones with esoteric activation requirements.
I also imagine this shuffle code routine probably predates SMB3, they reused it, but didn’t need all the features and didn’t bother modifying it, instead choosing to find parameters that produces the 8 variants.
On one hand, your videos make me nostalgic for the good old days of programming in assembly and telling the CPU exactly what to do without any intermediaries. On the other hand, this video shows exactly why programming in assembly isn't so great, and modern programming paradigms with like, unit tests and stuff, results in better quality. :D
yeah as someone who struggles to get anything working in Python or Lua, I respect the effort of ASM devs but not necessarily the grind due to how stuff like this happens all the time - like at least modern languages flag syntax errors for example
While true, I think the point worth noting is that the goal of modern tools is to try to get logic errors to be present as synatx errors. Or at least more broadly to turn runtime to compile-time errors whenever possible. It's a big part of why I like functional programming.
i genuinely have no idea what he ever talks about in any of his videos i just think learning about the inner mechanations of my favorite childhood games is neat
Perhaps the most interesting facet of all is the fact there's a similar dynamic to the Mario 3 card shuffle in New Super Mario Bros Wii's "Power-Up Panels" minigame, with only a single-digit number of possible panel configurations for each Toad House. Perhaps they liked how the limited number of configurations had become compelling, satisfying "insider knowledge" among veteran players, and hoped to replicate that in the Wii title?
There may be something to that idea. Japanese gaming culture is very collaborative, and finding and telling people about secrets is a major aspect of it. Some games (like Tower of Druaga or the original Siren) are even intentionally obtuse to foster this kind of collaboration
The shuffle methods actually aren't great even as described, without the bugs. If you arrange just the first 15 cards in 5 columns by 3 rows, the two operations can be described as: triple swap: move all the cards in one column up, taking the top one and looping it back to the bottom. rotate: move all the cards in the leftmost column to the right side of the tableau, then triple swap this column. because of this, there are only 3^5 * 5 = 1215 possible layouts of cards even if done perfectly: you have five columns of fixed content, each in the same circular order but with possibly different starting points, and the list of columns is also always in the same circular order with possibly different starting points. The added three cards at the end throws this pattern a little out of obviousness because the columns in the shuffle method are no longer lined up on the screen.
Much more intuitive explanation as for why the answer is 1215 compared to the way I calculated it (using MAGMA to calculate the order of the generated permutation group, lol).
It strikes me as pointless. Either the purpose is to genuinely shuffle, and repeating a dumb random swap (or draw) does the trick. Or it is to be gameable, and it should show the shuffle or drop other hints.
yeah i noticed this, given that only 15 cards get "shuffled" and the triple swap is between every 5th card, there are 5 fixed sets of triplets that never leave their groups (columns in your description) if the triple swap was between every FOURTH card instead, then triplets would be able to mingle (e.g. cards in positions 1 5 9 could be swapped and then 5 9 13). The rotation of cards then would also create a different triplet at the end (after a single rotation the triplet that contained cards 7 11 and 15 would contain 8 12 and 1 which would not be able to mix otherwise) - it would take many shuffles but at least in theory any card could end up anywhere of course this assumes a correctly coded algorithm and sufficient repeats - i'm not certain on the maths of the combinations here with the set rotations and repeat limits etc. but i'm pretty sure it's a damn sight more possible sets than 1215 picking 3 cards to swap that are each 5 apart in a set of 15 seems like such an obvious basic maths thing that makes me think it was intentionally to limit the possible outcomes
Love your pfp! I'm right there with you in terms of understanding level, but I can follow assembly pretty well because of watching Ben Eater and from playing games like TIS-100 (iirc that's what it's called) that use a sort of pseudo-assembly.
So many TH-camrs don't understand that courtesy. I just watched a video the other day and they made the necessary text the same color as the background. It was a lot of fun trying to read.
I honestly thought the card matching game routine was even simpler than that. I thought there were just a set number of layouts and the game cycled through them. The fact every single card layout was shown in a book sent with my Nintendo Power subscription as a kid convinced me as much. Who knew that that the fact there were so few card layouts that you could print them all in a strategy guide was due to bad coding? Wow.
@mrmega Thank you That’s how an old lady had those card game answers in a notebook I use to copy She loved Mario She stayed up all night playing Mario games on the NES
I wonder if they changed the roulette logic when they ported the game over to All Stars. I feel like it was a lot easier to match the roulette than pure random chance would suggest. Or maybe I just always went for the mushroom because it felt like that was easier to get.
All stars was the only version I had growing up, I was too young for the NES era. I was positive that the roulette stopped on the icon one step to the right (for the top and bottom parts) and left (for the middle part) of whatever was in the center when you pressed the button.
@@kerbe3 I had the same impression as a kid. I remembered the roulette game being more consistent. It would definitely be interesting to see if the code is any different in All Stars, or if this is a Mandela Effect (read: faulty human memory.)
If the roulette had really been that easy, you would have been getting your chosen item pretty much every time. Timing games like this correctly is significantly easier than most people realize. For instance, arcades sometimes have this game with a circle of bulbs lighting up one at a time, like the light is racing around the circle. You have to hit a button when a certain bulb is lit up. If you disable the random delay that is inserted after pressing the button, you can quickly learn to get it right every single time. In fact, try picking any light that isn't the jackpot light and stopping on that one every time. You'll find it is remarkably easy. And those games are way faster than this roulette. So unless you were successful nearly every time, my guess is you just had a false impression of how the game worked.
@@EebstertheGreat That's the thing. I definitely remember getting it right nearly every time. But that could be a false memory; I could just be forgetting all the times I got it wrong.
Wow, I always figured there was some RNG with the timing of the regular spade game, so that part doesn't surprise me too much. However, with the N-spade's board layouts, I always assumed they were hard-coded in as well, and never even considered the possibility that they were the result of oversights in the shuffling routine. That also explains why many of the possible layouts often share certain characteristics, like how the 10-coin cards are often diagonal from each other, and the 20-coin cards are often neighboring each other. And yes, I did notice that the last three cards were always mushroom, flower, star on every layout way back then, when I read a Nintendo Power guide that showed all eight possible layouts. This made it even easier to memorize the patterns and fully clear the N-spade game consistently.
I think that the last three cards being identical on every layout makes it possible to devise a strategy that consistently full clears the card minigame without flipping a non-match for information (meaning that the single mistake the game allows can be used as a defense against misclicks).
To quote a certain coolkid: That's a hell of a mystery no one thought was a mystery and didn't even really need solving but damn if it didn't just get solved so nice work.
I was intrigued at the beginning of the video, because as a kid, I always sucked at remembering the 8 card games, but I used to nail the roulette almost every time. I had to press the button perfectly every time. It felt like a small time window, but it didn’t feel frame perfect. 3 frames makes sense. You had to time your presses exactly right from the start. But you only had one try, if you waited too long to press the button on the 2nd or 3rd segment, there was no chance of re-timing it. Or, I guess I was just some kind of superhuman.
Your videos are awesome as always, but one thing I've always enjoyed in particular is the backgrounds to each video, customized for the style of the game in question, plus the game-accurate fonts used. My favorite of all is definitely the SNES hardware videos; since they're not tied to a game at all, we get this awesome dark gray background with the very specific font used; all reminiscent of the CRT TVs themselves and the fonts they'd use for the OSD. This gives that whole series the feeling of explaining the Retro Game Mechanics of no game at all, seeing the style of the underlying hardware when there really wasn't a particular style of pure SNES hardware design. The font and color were excellent choices, and I loved the entire feeling of that. *spoilers* EDIT: I never knew the 8 layouts of the card game weren't intentional, and those programming oversights are hilarious. Generate a random number and then never actually use it.
I like to imagine that during late playtesting they found the card game to be highly frustrating and went in last minute to gimp their glorious algorithms on purpose.
Wonderful explanation - I love how the mistakes interact to so drastically reduce the number of possibilities! It seems strange that nobody noticed the error, after working that hard to get a random shuffle. And I love LFSRs - they sound like they should never work, but somehow can produce a random-looking loop of numbers
I must have recognized way back when that there were clear differences in timing to get a specific outcome on the roulette but I didn't realize just how bad the variance is. Wow.
I can't get over how great your content is. Not just the great examination of the code, and the outstandingly clear explanation at you go, but the visuals that really bring it all together. I love it!
I didn't know the card shuffle game was supposed to be pure random. I wrote them down out of curiousity, and I had a hunch they were a set, and I did get a set, but I only found out now they did some extra work with the card shuffle game. It's really fascinating how games and applications were programmed back in the day, nowadays we high level programming languages, but watching videos of how the old program code works, it's like you're thinking how the machine would see the numbers, instead of just translating your concept into text that can be translated into compiled code.
Any day RGME uploads is a great day! The moment I saw the JSR followed by AND I KNEW that was gonna be the problem, I've done that while making homebrew way too many times lol
To be fair this is a mistake easy to make when you write code to return a value in the accumulator, it's not unlikely they had this in mind and legitimately forgot to also load the value after returning from the subroutine. I know I have made this mistake for that exact reason, haha!
Even if the shuffling routine was made perfectly, it would not be very random. Consider the 1st, 6th, and 11th card. If there is a triple swap with any of them, it includes them all. This means that those three cards will always be separated by 4 cards. This is the same for all the 5 triples. Then we get only 3⁵×5 = 1215 unique positions (choose which triple has the first card, and the rotation of each of the five triples). This does not overcount.
man i love these kinds of videos, especially when they contain some kind of fixable programming oversight/mistake. wonder what other NES/Gameboy/etc games have stuff like that
These discussions are so informative. I wonder if you could show us in any NES baseball game how the game decides where the ball ends up when you’re batting :)
a programmer for super mario bros. 3 sees this video on their recommended. they open it and turn on japanese subtitles, hoping to see someone appreciating their clever programming tricks from all those years ago. a groan rings out across their apartment as they see a mistake that they are several decades too late to fix. a like is added to the video.
10:24 I was learning how shuffling algorithms work a while ago, and came across the Fisher-Yates shuffle. The problem is that it cannot generate EVERY possible permutation using pseudo-random number generator if the number of possible RNG seed states (2^n, where n is the number of bits) is less than NumberOfItems factorial. This means, for example, if you use a 16-bit RNG, you cannot have more than 65536 possible arrangements.
Another problem is that even if you have more RNG states than the number of arrangements, it actually has to exceed the number of arrangement by "at least several orders of magnitude" else certain permutations happens at a higher probability than others. This is according to Wikipedia on Fisher-Yates shuffle on Pseudorandom generators. I can't link it here because youtube's anti-spam/scam is false-positive prone and will delete my comments.
@@ghb323 I'd mention that factorial doesn't just grow "exponentially fast" but in reality, it grows even faster than that because at some point, the numbers added to the factorial are larger than the base. That being said, I doubt shuffling a number of items requires a lot of memory or at least any more than double the size of the list.
@@MarioFanGamer659 You could use hardware RNG, but be careful that this relies on physical phenomenon and is subject to degradation and could eventually be in a state it outputs uneven distribution of random numbers(some values occurring more often than others). On emulators, they may falter since they themselves might use PRNG to emulate the hardware RNG or use the computer’s rng.
@@emptiester Not always. Case in point: if your algorithm is bugged and produces fewer configurations than you were planning to generate, so hardcoding eight arrangements would take less data.
@@emptiester "computationally cheaper" doesn't usually mean "less memory", which is almost always the only benefit of using an algorithm instead of hard-coding.
True but honestly i suspect that they made it properly, but ended up changing their minds and tweaking it to allow a manageable set. This just strikes me as intentional.
Back in the day, I didn't think the roulette game was all that hard. I almost always could get the star (and it's 5ups). You just had to know exactly when to stop the wheels. (On a CRT, that was easy being there's no video lag.) In spite of the few patterns that existed, I never was that good at the card matching game.
omg so glad I found this channel. I did a little 8 bit programming in the 80s and I'm still fascinated by it. Love your illustrations in real time, with the numbers swinging through their places as the processor moves through the code.
So, the first slot you can get correct all the time, easy. The second slot is 19/32 = 59% if you time it right in the middle of the possibility space. The third slot is 16/64 = 25% chance to win, if you're going for the star, with every position being equally likely and no strategy can improve it. So *14.8% chance total*, with perfect timing! It's actually amazing how many people in the comments say they could "get the star every time" as a kid, it really shows that memories get seriously inaccurate if you let them sit for too long 😄 (And this is one reason why gambling is dangerous, you always think you've "figured it out" even when it's purely random...)
Even if the order of triple swaps and rotations was completely arbitrary, the algorithm could still only generate 1215 permutations. To see this, let us examine the possible moves: Rotate (ROT) Triple swap from position 1 (TS1) Triple swap from position 2 (TS2) Triple swap from position 3 (TS3) Triple swap from position 4 (TS4) Triple swap from position 5 (TS5) Let us notice that in the following table, any sequence on the left side of an arrow produces the exact same permutation as the one right of it: ROT-TS1 -> TS2-ROT ROT-TS2 -> TS3-ROT ROT-TS3 -> TS4-ROT ROT-TS4 -> TS5-ROT ROT-TS5 -> TS1-ROT ROT-ROT-ROT-ROT-ROT -> TS1-TS2-TS3-TS4-TS5 Let us take an arbitrary sequence of moves. If we find a subsequence that is in the left column of our table, we will replace it with the corresponding sequence in the right column. For example, the sequence TS1-TS3-ROT-ROT-TS1-ROT will become TS1-TS3-ROT-TS2-ROT-ROT after we apply the rule ROT-TS1 -> TS2-ROT. Let us note that no matter what rule we apply, the number of ROT moves will either decrease, or a ROT move will move right in our sequence. As such, if we apply the rules recursively, we will eventually be left with a sequence where no rule can be applied anymore. This sequence will still produce the same permutation as the original. What will our sequence look like after we can no longer apply any rules? It will consist of a number of triple swaps followed by at most 4 ROT moves. This is because if there was a ROT move before a triple swap or if there were more than 4 ROT moves at the end, a rule could be applied. We will finish by realising that the order in which we perform triple swaps doesn't actually matter. TS1-TS2 will produce the same effect as TS2-TS1, for example. As such, the only thing that matters is how many times we have performed each type of triple swap. Furthermore, performing the same triple swap three times does nothing. As such, any arbitrary sequence of moves may be reduced to the following, in this exact order: No more than 2 TS1 moves. No more than 2 TS2 moves. No more than 2 TS3 moves. No more than 2 TS4 moves. No more than 2 TS5 moves. No more than 4 ROT moves. There are a total of 3^5 * 5 sequences of this form, or a total of 1215. You may take some time trying to convince yourself that they do not contain duplicates. I believe this can most easily be seen by examining where the first 5 cards end up after any arbitrary shuffle. As such, the video from around 12:20 is wrong. One shuffle can only produce 1215 outcomes. Furthermore, a single shuffle will actually produce every possible outcome with an equal probability. The subsequent shuffles are completely pointless. But the video is right in saying that there are a lot of duplicates.
Makes sense for the roulette. I used to get the first two rather routinely, the third was random. I just timed for when the item I wanted (the star) was in the middle. Looking at this, it actually makes sense. The first one is entirely skill based. The second, you'll get it about 59.357% (19 / 32) of the time assuming your timing is anywhere near decent. And the last one is 25% no matter what. So the odds of getting the best item, the star are about 100% * 59.375% * 25% = 15%. So you'll average about .742 lives every time you play the game if you go for the star since it's worth five lives. But if you go for the mushroom, the odds are 100% * 59.375% * 50% = 29.7% since the mushroom makes up half of the slots. However, you only win 2 lives, so the lives per game fall back down to .594. Still best to go for the star.
Fascinating to know the code behind both mini-games. For the roulette wheel, I always thought that it would determine your chances of a win based on the top wheel -- so if you got a mushroom, the chances were much higher compared to if you got a star, and that the game would just "give" you the prize if you rolled a win no matter when you pressed the button as opposed to the delay and such involved. And likewise, I thought there really were just eight arrays of cards that were chosen at random instead of broken code that made a true shuffle fail to operate properly.
Props to you already using the new patreon logo! Regardless of how people feel about it (I’m personally not the biggest fan of the blob) that is the kind of attention to detail I’ve come to expect from this channel
To this day I remember that the third card to the right on the top row and the second card from the right on the last row are both usually fire flowers. I saw that pattern when I was 5 and it somehow stuck with me for the rest of my life. It's wild to me now that it's only a 62.5% chance it felt like it happened almost all the time, but that's memories for you.
man i just love these videos. they remind me why i got into coding, it's such an interesting way of problem-solving and i love imagining the thought process of the people writing these games.
Learning so much about the OG SMB3. Nice to know the mechanics of the card-match and roulette games haha Do you know if the code is any different for the SM: All-Stars or SMA4 variants? An explanation or mini-follow up video would be awesome ^^
All-Stars code is nearly identical to the NES version, the games in All-Stars are essentially direct ports with some tweaks and of course new sprites and sound. No idea about Mario Advance 4, though I'd assume it's a port of the All-Stars version but I don't know that. Edit: Just checked TCCF, Advance 4 is a direct port of All-Stars, so it should still be the same unless Nintendo specifically decided to change it.
I find this interesting in the fact as a kid, I could pretty much time the roulette to give me a Star almost every time. I was never able to figure out the N-Spade patterns though. 🤔
There was a time when I was young when I had all the card layouts mesmerized and I was pretty good at the match game too. We had an official SMB3 Strategy guide that had them all too, wish I still had that.
What??? I've been able to hit the roulette game nearly every time because I know when to press the button. I'm gonna have to go back and play a few times because my brain is telling me I was incredibly good at this game.
I love these old school video game breakdowns. When I was a kid I'd spam the A button on these card games and I'd get 2-up the vast majority of the time. When I tried to do it again last year when I was humoring speedrunning it and practicing/needing lives I just could rarely re-create my childhood experience.
What's funny about this is that I never learned the matching game layouts as a kid, so never cared for that game, but I could fairly consistently win the slot game. Regardless of how the code should make it unpredictable, it usually is a fairly simple timing minigame. Stop the first real when the picture you want is in the center. Stop the second just before the picture you want is fully centered. Stop the third just as the picture you want is leaving the screen. The RNG does beat it sometimes, but this method served me very well as a child.
The roulette game may have been more random than what it seems, but if you have good timing you can consistently win. I remember as a kid hitting A immediately when the game starts and then hit A just slightly before the previous image stops. It lines up 3 mushrooms, but hey it's better than not winning. I'm sure theres a way to time the star but I never cared to figure it out.
0:20 With the 3 part roulette, I found the first to be random. But in actuality, I always managed to match the second if I hit one early...press the button on star and i would get the mushroom every time. For the final slide, there was a pixel error where the two slides met...6 pixels would flash in succession. Press the button when the pixel lined up and it worked every time. You can actually see it on screen. So yes there was randomness, but defects in the game made it easier.
(8:05) I assume that is to add the human element. The game will continue to randomise until the player continues. So you have the pressing the button to the map and dialogue adding randomisation. Having the second and third wheel not affected by the timing you press the button does have an affect on using save states, and that's kinda interesting.
I remember the card game having only two layouts that I memorized and could always nail the first time. I also somehow "mastered" the roulette wheel. Amazing what my brain could do thirty years ago.
Do you know if the All-Stars version of the roulette is any different? Anecdotally, it always felt easier to me, but I don't know if that's just confirmation bias.
Just discovered this channel. I too always wondered why I could never master the timing of that roulette game. But it all makes sense now. Yes, the delay of the last row was noticeably longer. Mind blown by the "not so random" card matching game. Like others, I feel it was on purpose though.
So wait, if the second and third bars' slip amounts are frozen while playing, is there any correlation that would allow you to predict how much the third bar will slip from how far the second bar slipped?
not really, because the info that is now in the second rng slot(second bar) is generated from the info that is now in the third slot (third bard) and the fourth slot, and even then the second bar only use 5 bits of the second slot rng value. Even if you knew the 5 bits, you can't use this info without the fourth slot values to try to get the third slot values
i played SMB3 once on the NSO emulators and checked out mentally right after failing the spinny minigame. It was so far off of a match I actually couldn't believe I did so poorly. Feels good knowing this specific instance isn't just me being bad at video games for old people!
If the 3rd wheel is effectively random, then you will win 1/3rd of the time at least if you consistently get the first 2 wheels. It's probably confirmation bias.
I think the cards thing was deliberate to make it simpler for players, or it could have been deemed not needed due to the limited amount of times you can see the cards in a play through anyway. It also really subscribes to Nintendo's philosophy of playing games together that they had in the 80s. If it was so random that no 2 players would ever get the same board there would be nothing to talk about, no rumors.
I have positively zero reason to doubt this because you've looked at the actual code, but I always thought the roulette was all down to timing! I had a rhythm down that would win it what I thought was far more often than not, but that could have been just confirmation bias. Seeing the bare bones of it here, it doesn't seem like there's any way my timing was that good, nor would the timing I had correlate to one specific result!
Okay so I used to watch PBS Kids a LOT when I was little, and ooooohh my god the “Viewers like you, Thank you!” I swear is ripped directly from those childhood memories
Just having this for my own purposes, at 3:49, "Roulette_Run" is Roulette_Run in program 22, at 8:18, "Randomize_Roulette" is right after JSR Read_Joypads and before PRG022_CF7C, at 13:07, "Card_Shuffle" is Card_Shuffle in program 22, and at 15:50, "Randomize" is Randomize in program 30.
Fun fact: even if (just) the first fix was applied to the shuffle logic as explained at 18:09 , there would not be 15^3 = 3375 possible outcomes as a result, but only 225. The second change at 18:21 would increase this to a mere 1050 instead of 216000. That's because the triple-swap is symmetric to rotations of multiples of 5, i.e. triple-swap + rotate 5 has the exact same outcome as rotate 5 + triple-swap. So the first case effectively ends up with 15 cases of rotation plus 2 triple-swaps at arbitrary offsets with 5 cases each (order does not matter, thus cases total and not 25) (plus the third triple-swap at fixed offset of 0), thus 225 total. The second case is a bit more complicated but similar. Only the last suggestion would increase the number of cases as intended - to 88990.
Sixty percent. That's the expected percentage of duplicates. I've played cards long enough to know that shuffling has a one in sixty-six thousand chance of not doing effectively a damn thing. This has historically led to people being called 'cheaters' when it was the deck just being shuffled enough that the outcome was returned to the previous. Yep, people were killed over this. (1/66,534)
Thank you, very interesting video. I also want to say that I can see that you are not using clickbaity titles and thumbnails and the videos are very to the point without stupid jokes and trying to mix-in the ad with the video content. This is very much appreciated even though it puts you at a disadvantage in the toxic world of youtube algorithm. Thanks for staying true to quality.
The roulette game is easily hacked. I could always score stars on it. Simply watch closely and as soon as your desired item passes the centerline of the screen, hit the button. The row will then "slow down" one full rotation, landing on the item you selected. Repeat this for the other two rows. I scored 5-ups on the regular.
so vindicating. also knowing the card-matching used only certain patterns helps understand how, after a while, I somehow gained the ability to predict where cards were reliably.
That's fascinating. Now I want to see the same thing for the SMB2 slot machine game. I mastered that one to where I could nearly always get 5UP, nothing, 5UP, nothing etc., and it's such an odd pattern I always wondered why it worked out that way.
One hilarious thing is, the Nintendo Power Strategy Guide for Mario 3 included a diagram of all eight possible configurations. So someone noticed this flaw early on.
They decided to market it as a feature, not a bug.
@@Wendy_O._Koopa To be fair, NOA nor Nintendo Power would have not known how the game was programmed, so many "bugs" were featured as tricks and tips out of ignorance of it being unintended
@@xxEzraBxxx I still have that Strategy Guide, and the wild thing is (well, _another_ wild thing) that the diagrams aren't screen shots (which back then meant physically using a camera to take a picture of the TV) they're hand drawn. Which means (I'm speculating) that they assumed there were going to be hundreds, thousands, maybe millions of combos; and were writing them down by hand (so as not to waste film). Soon they discovered that there were only eight, and they didn't have to figure out any "tips _or_ tricks," just post those few... only they didn't have pictures.
Anyone can draw a Super Mushroom, right? Well, for some reason they're green... like dark green stems and light green caps, and orange and red spots. To be fair SMB3 Super Mushrooms _are_ orange and red... but not like _that._ And the 1up chests? they're just blocks that say 1up. The flowers and stars look alright, the coins for some reason are rings with either 10 or 20 written inside of them. I used to think Sega stole Sonic's rings from my bracelets, but maybe it was from Nintendo Power? _Freaky._
@@Wendy_O._Koopa I highly doubt they would start writing them down by hand or even take photos of it if they thought there would be hundreds of combos. The only way it makes sense to begin drawing them down is if you happened to notice you got duplicates first, or had some suspicion there were a manageable amount
@@ITR First of all, you realize that by "writing them down" I mean in some form of shorthand, right? Like FSEF2M-1M2EM1-SFSMFS where E=Extra Life and 1 & 2 equal 10 & 20 coins, etcetera. And, yes I guess it makes sense that they suspected they had a manageable amount; but the best way to find out how many is to just take notes as you go. I know this isn't the original drawing, because it reuses all it's assets, the Mushrooms may look strange, but it's the same strange looking Mushroom each time.
I knew it! I knew there was a random delay in that damned game. My whole life, I've tried to master that game, but there's always been something odd happening with it not slowing and stopping right. I originally thought it was just some frame lag. I feel vindicated now.
And now that's in virtually every free android match 3 game. Lolz
Last one always felt like chance
I don't think that was a mistake--it's effectively a slot machine, it's supposed to give you an illusion of control about winning (based on the first two) and then take away your agency (third one).
So if i account for that, i can pretty much win every time
You can guarantee the first, get the second about 50% of the time, and you can't do anything about the third.
Ever since I was a kid, I knew about the 8 card arrangements. I also thought it was just that they had hard coded those eight boards and the only RNG was to determine which of the eight you got.
I only ever encountered seven boards. And I had them figured out by myself.
Yup. Noticed and noted them all myself.
Maaaybe I spent too much time on that game.
Ironically it seems they must've wanted to keep that cause every remake of SMB 3 from then on did keep the 8 configurations and given they were all written from the ground up and it seems unlikely they would deliberately keep unnecessary code with such a glaring bug, but also... the fact that you could memorize the 8 decks is challenging yet fair enough for any casual player and we all generally agreed the roulette minigame was bull, but... given the end of level cards are super easy to match and all you get are lives, it never really bothered us. Yet another case of turning a bug into a feature (hello SMB wall jump)
The boards were published. Probably nintendo power.
@@emptiesterI had the published boards on Nintendo power
I wonder if the last 3 cards was actually an easter egg, or if the minigame was originally going to have one fewer column, the shuffling code was written for that, and then they forgot to change it after adding the last column (e.g. maybe when designing the graphics they realized they had more screen real estate than they initially guessed)
It would be really odd for them to have one less column, assuming the plan was always to be able to match every card. That might not be the case, of course; but hard to really make any calls on it given it's a pretty odd quirk to begin with.
I was thinking perhaps they were intending on randomizing the number of cards involved in the rotation, which could add a bit of random spice of the number of cards involved is set to something between 2 (doing some swaps) and 18 (cycling the whole set of cards)
its a pairs matching game so having 3 less cards wouldn't really work since thatd give us an odd number of cards.
@@feronanthus9756 @hokostudios Yeah that's a good point lmao
Actually, according to the Cutting Room Floor, the game was originally going to have a 'wild card' this would make sense if it was 15 'cards' and a wild card, then adjusted to 18 by just putting 3 cards at the end
These videos are always right to the point, are laid out in an understandable manner despite their complexity, and never use obnoxious music or flashy images. Please never change.
Agreed 💯
Yes! Very easy to watch where even if you don't understand math or know how programming works, it still is fairly easy to understand and if you DO know how those work, it's a nice bonus on rewatch. These youtubers make WAY better teachers than actual professors at college.
I beg to differ, I wish he instead would create clickbait titles, put his face on the thumbnail with him looking shocked and an arrow pointing to a blurred out section of code. I think something like "The Reason You Never Beat This Minigame!" or "Why You Always Were Terrible At This Popular Game." Those are my favorite videos, this one is also missing a animation of a mouse clicking a like and subscribe button with that sweet sound effect. I'm also really disappointed there wasn't a 2 minute Nord VPN ad and a 4 minute Raid: Shadow Legends ad in the middle of it.
The illustrations are really well done too and often go the extra mile to look smooth or informative, but without drawing too much attention away from the narration. This is such a perfect channel.
I immediately went to the author's patreon page and contributed some. Please stay like this!!!
As a PBS kid, that opening thank you message put a smile on my face.
I was not a obsessed kid but i liked watching NOVA with my dad later in life, so that was my first exposure to the phrase. Makes me smile. And also sad.
The opening “Brought to you by … viewers like you. Thank you” (0:40) reminds me of PBS Kids, which I used to watch all the time when I was young
Fascinating! I always thought the Card Matching game just used hardcoded sets and wasn't determined by an algorithm.
The weird thing is, in New Super Mario Bros. Wii, the equivalent maching game in Toad Houses actually _does_ use hardcoded sets (or rather, they're defined by the level data).
Interesting
You are both right, its random but that randomness only allows 8 possible sets,
@@MarioMasta64...this video literally explains that it doesn't.
@@Skawoonly 8 sets are actually created. i even made a tool that helps you win the game with a max of 1 wrong answer so that you can get every item
@@MarioMasta64...but they are not hardcoded. An algorithm creates them. That's the whole point.
It's entirely possible that they implemented the algorithm, but decided that having true total randomness for the card layouts wasn't what they wanted, and made intentional changes to limit the possible outcomes to just eight sets. It's hard to know what really happened, but it's fascinating to learn they weren't simply hard-coded layouts!
Considering their past experience with SMB2 Japan/The Lost Levels being rejected by Nintendo of America and them having to repurpose Doki Doki Panic because the other game was just too damn hard, and how SMB3 is not exactly the easiest of games and is a big one, they may have decided that giving a couple extra easy-to-attain power-ups for your inventory was a nice way of smoothing out the experience a bit. Also, the fact that the N-card game rarely appeared for those who didn’t know exactly how to trigger it made it more difficult…
As a player who never had access to Nintendo Power but who had quite a lot of hours of gameplay, I quickly realized there was a limited number of arrangements and, over time, developed my own strategy to identify which of them it was, and figured that starting from the corners was an easy one (stars usually bunch up there). I developed a sort of a “feel” for it, and kind of have a mental model of how they’re structured, so I usually clear the board in a couple of attempts.
@@Mainyehc It was more rejected because it was SMB1 but with new graphics, different levels and few new elements (aka "Mission-Pack Sequel") and not necessarily because it was too hard (though it's still a contributing factor, just not the only one). What's even further funny is that SMB2 (the international version) originally was a Mario game before it was repurposed as a promotion to Fuji Television.
I had exactly the same thought. Bug or a clever way to limit it to just a few layouts by commenting out a few lines? It appears the feature was completely implemented and changed during play testing.
@@Mainyehc N-card game appeared at regular intervals [it was just every 80,000 earned points], the white mushroom house and treasure ships were the ones with esoteric activation requirements.
I also imagine this shuffle code routine probably predates SMB3, they reused it, but didn’t need all the features and didn’t bother modifying it, instead choosing to find parameters that produces the 8 variants.
On one hand, your videos make me nostalgic for the good old days of programming in assembly and telling the CPU exactly what to do without any intermediaries. On the other hand, this video shows exactly why programming in assembly isn't so great, and modern programming paradigms with like, unit tests and stuff, results in better quality. :D
yeah as someone who struggles to get anything working in Python or Lua, I respect the effort of ASM devs but not necessarily the grind due to how stuff like this happens all the time - like at least modern languages flag syntax errors for example
@@SnoFitzroy Assemblers flag syntax errors too.
While true, I think the point worth noting is that the goal of modern tools is to try to get logic errors to be present as synatx errors. Or at least more broadly to turn runtime to compile-time errors whenever possible. It's a big part of why I like functional programming.
Yeah modern programming is good and all, but has your code even only worked when your cpu is cold enough?
Unit testing has always very much been done.
i genuinely have no idea what he ever talks about in any of his videos
i just think learning about the inner mechanations of my favorite childhood games is neat
Jun, 6th, 2015.
You get a like for being a rare breed of person who didn't feel the need to say, "literally."
Perhaps the most interesting facet of all is the fact there's a similar dynamic to the Mario 3 card shuffle in New Super Mario Bros Wii's "Power-Up Panels" minigame, with only a single-digit number of possible panel configurations for each Toad House. Perhaps they liked how the limited number of configurations had become compelling, satisfying "insider knowledge" among veteran players, and hoped to replicate that in the Wii title?
There may be something to that idea. Japanese gaming culture is very collaborative, and finding and telling people about secrets is a major aspect of it. Some games (like Tower of Druaga or the original Siren) are even intentionally obtuse to foster this kind of collaboration
I feel that the LFSR should be used to determine the number of videos it takes before the LFSR is mentioned again. Just for the sake of consistency.
Good call.
Lol glad I'm not the only one who had this kind of meta thought about if when he posed the question 😅
The shuffle methods actually aren't great even as described, without the bugs. If you arrange just the first 15 cards in 5 columns by 3 rows, the two operations can be described as:
triple swap: move all the cards in one column up, taking the top one and looping it back to the bottom.
rotate: move all the cards in the leftmost column to the right side of the tableau, then triple swap this column.
because of this, there are only 3^5 * 5 = 1215 possible layouts of cards even if done perfectly: you have five columns of fixed content, each in the same circular order but with possibly different starting points, and the list of columns is also always in the same circular order with possibly different starting points.
The added three cards at the end throws this pattern a little out of obviousness because the columns in the shuffle method are no longer lined up on the screen.
Much more intuitive explanation as for why the answer is 1215 compared to the way I calculated it (using MAGMA to calculate the order of the generated permutation group, lol).
It strikes me as pointless.
Either the purpose is to genuinely shuffle, and repeating a dumb random swap (or draw) does the trick.
Or it is to be gameable, and it should show the shuffle or drop other hints.
Thanks for explaining that. Good video, but I thought the maths on the permutations was off.
yeah i noticed this, given that only 15 cards get "shuffled" and the triple swap is between every 5th card, there are 5 fixed sets of triplets that never leave their groups (columns in your description)
if the triple swap was between every FOURTH card instead, then triplets would be able to mingle (e.g. cards in positions 1 5 9 could be swapped and then 5 9 13). The rotation of cards then would also create a different triplet at the end (after a single rotation the triplet that contained cards 7 11 and 15 would contain 8 12 and 1 which would not be able to mix otherwise) - it would take many shuffles but at least in theory any card could end up anywhere
of course this assumes a correctly coded algorithm and sufficient repeats - i'm not certain on the maths of the combinations here with the set rotations and repeat limits etc. but i'm pretty sure it's a damn sight more possible sets than 1215
picking 3 cards to swap that are each 5 apart in a set of 15 seems like such an obvious basic maths thing that makes me think it was intentionally to limit the possible outcomes
@@kackers The word you're looking for is coprime.
This channel is right at the edge of my ability to understand, and I love it.
It's 25% something I understand, I work with codes so it's a bit easier to understand, the nes is the basic regarding understanding code
Love your pfp!
I'm right there with you in terms of understanding level, but I can follow assembly pretty well because of watching Ben Eater and from playing games like TIS-100 (iirc that's what it's called) that use a sort of pseudo-assembly.
I love how you put the subtitles to the side when there's something to see that would normally be under it.
So many TH-camrs don't understand that courtesy. I just watched a video the other day and they made the necessary text the same color as the background. It was a lot of fun trying to read.
I love what you're doing for people who are interested in programming. I'm not one of them so I don't understand much, but I think it's really cool
Excellent analysis! Fascinating how this kind of overslight regarding the card game slipped into production.
I honestly thought the card matching game routine was even simpler than that. I thought there were just a set number of layouts and the game cycled through them. The fact every single card layout was shown in a book sent with my Nintendo Power subscription as a kid convinced me as much. Who knew that that the fact there were so few card layouts that you could print them all in a strategy guide was due to bad coding? Wow.
@mrmega
Thank you
That’s how an old lady had those card game answers in a notebook
I use to copy
She loved Mario
She stayed up all night playing Mario games on the
NES
Awesome video. It's always pretty funny to see games misbehaving like this because of oversights from the developers!
I wonder if they changed the roulette logic when they ported the game over to All Stars. I feel like it was a lot easier to match the roulette than pure random chance would suggest.
Or maybe I just always went for the mushroom because it felt like that was easier to get.
All stars was the only version I had growing up, I was too young for the NES era. I was positive that the roulette stopped on the icon one step to the right (for the top and bottom parts) and left (for the middle part) of whatever was in the center when you pressed the button.
@@kerbe3 I had the same impression as a kid. I remembered the roulette game being more consistent. It would definitely be interesting to see if the code is any different in All Stars, or if this is a Mandela Effect (read: faulty human memory.)
all-stars code is nearly 1:1 to the original nes version, apart from the hardware/16bit stuff and other things they added like saving.
If the roulette had really been that easy, you would have been getting your chosen item pretty much every time. Timing games like this correctly is significantly easier than most people realize. For instance, arcades sometimes have this game with a circle of bulbs lighting up one at a time, like the light is racing around the circle. You have to hit a button when a certain bulb is lit up. If you disable the random delay that is inserted after pressing the button, you can quickly learn to get it right every single time. In fact, try picking any light that isn't the jackpot light and stopping on that one every time. You'll find it is remarkably easy. And those games are way faster than this roulette.
So unless you were successful nearly every time, my guess is you just had a false impression of how the game worked.
@@EebstertheGreat That's the thing. I definitely remember getting it right nearly every time. But that could be a false memory; I could just be forgetting all the times I got it wrong.
Wow, I always figured there was some RNG with the timing of the regular spade game, so that part doesn't surprise me too much.
However, with the N-spade's board layouts, I always assumed they were hard-coded in as well, and never even considered the possibility that they were the result of oversights in the shuffling routine. That also explains why many of the possible layouts often share certain characteristics, like how the 10-coin cards are often diagonal from each other, and the 20-coin cards are often neighboring each other.
And yes, I did notice that the last three cards were always mushroom, flower, star on every layout way back then, when I read a Nintendo Power guide that showed all eight possible layouts. This made it even easier to memorize the patterns and fully clear the N-spade game consistently.
I think that the last three cards being identical on every layout makes it possible to devise a strategy that consistently full clears the card minigame without flipping a non-match for information (meaning that the single mistake the game allows can be used as a defense against misclicks).
The different card rotating and swapping steps makes me think they had some kind of animation planned but didn't get around to implementing it.
Nov, 1st, 2006.
To quote a certain coolkid: That's a hell of a mystery no one thought was a mystery and didn't even really need solving but damn if it didn't just get solved so nice work.
May, 15th, 2006.
@@cadencase5216 Please elaborate.
@@realMoistNugget Dec, 12, 2020.
I was intrigued at the beginning of the video, because as a kid, I always sucked at remembering the 8 card games, but I used to nail the roulette almost every time.
I had to press the button perfectly every time. It felt like a small time window, but it didn’t feel frame perfect. 3 frames makes sense. You had to time your presses exactly right from the start. But you only had one try, if you waited too long to press the button on the 2nd or 3rd segment, there was no chance of re-timing it.
Or, I guess I was just some kind of superhuman.
Your videos are awesome as always, but one thing I've always enjoyed in particular is the backgrounds to each video, customized for the style of the game in question, plus the game-accurate fonts used. My favorite of all is definitely the SNES hardware videos; since they're not tied to a game at all, we get this awesome dark gray background with the very specific font used; all reminiscent of the CRT TVs themselves and the fonts they'd use for the OSD. This gives that whole series the feeling of explaining the Retro Game Mechanics of no game at all, seeing the style of the underlying hardware when there really wasn't a particular style of pure SNES hardware design. The font and color were excellent choices, and I loved the entire feeling of that.
*spoilers*
EDIT: I never knew the 8 layouts of the card game weren't intentional, and those programming oversights are hilarious. Generate a random number and then never actually use it.
April, 5th, 2011.
@@cadencase5216 I'm sorry, I don't understand what that date refers to.
@@smcgamer1 It was a cheesy attempt at being cryptic. It's the date you joined TH-cam.🤷♂️😅
@@cadencase5216 True, that is the correct date.
I like to imagine that during late playtesting they found the card game to be highly frustrating and went in last minute to gimp their glorious algorithms on purpose.
The triple swaps made me wonder about that... but there's no way that the rotate failing to use the result of the randomizer was on purpose.
I'm a software engineer myself. You'd be surprised what we do when the business changes their mind last second.
Highly frustrating? Not sure this makes sense. Matching cards is just matching cards
Then just allow more misses, or reduce the number of different cards. Get rid of the coins, say.
@@drachefly abysmal "solutions"
Wonderful explanation - I love how the mistakes interact to so drastically reduce the number of possibilities! It seems strange that nobody noticed the error, after working that hard to get a random shuffle. And I love LFSRs - they sound like they should never work, but somehow can produce a random-looking loop of numbers
I must have recognized way back when that there were clear differences in timing to get a specific outcome on the roulette but I didn't realize just how bad the variance is. Wow.
I can't get over how great your content is. Not just the great examination of the code, and the outstandingly clear explanation at you go, but the visuals that really bring it all together. I love it!
0:45 I love that sweet reference to PBS's "Thank you" message!
You're very welcome!
I didn't know the card shuffle game was supposed to be pure random. I wrote them down out of curiousity, and I had a hunch they were a set, and I did get a set, but I only found out now they did some extra work with the card shuffle game. It's really fascinating how games and applications were programmed back in the day, nowadays we high level programming languages, but watching videos of how the old program code works, it's like you're thinking how the machine would see the numbers, instead of just translating your concept into text that can be translated into compiled code.
Any day RGME uploads is a great day!
The moment I saw the JSR followed by AND I KNEW that was gonna be the problem, I've done that while making homebrew way too many times lol
To be fair this is a mistake easy to make when you write code to return a value in the accumulator, it's not unlikely they had this in mind and legitimately forgot to also load the value after returning from the subroutine.
I know I have made this mistake for that exact reason, haha!
Even if the shuffling routine was made perfectly, it would not be very random. Consider the 1st, 6th, and 11th card. If there is a triple swap with any of them, it includes them all. This means that those three cards will always be separated by 4 cards. This is the same for all the 5 triples. Then we get only 3⁵×5 = 1215 unique positions (choose which triple has the first card, and the rotation of each of the five triples). This does not overcount.
man i love these kinds of videos, especially when they contain some kind of fixable programming oversight/mistake.
wonder what other NES/Gameboy/etc games have stuff like that
These discussions are so informative. I wonder if you could show us in any NES baseball game how the game decides where the ball ends up when you’re batting :)
That explains a lot, because I can get the first two panels to match if they're in the middle, but that was never the case for the last one.
a programmer for super mario bros. 3 sees this video on their recommended. they open it and turn on japanese subtitles, hoping to see someone appreciating their clever programming tricks from all those years ago.
a groan rings out across their apartment as they see a mistake that they are several decades too late to fix.
a like is added to the video.
10:24 I was learning how shuffling algorithms work a while ago, and came across the Fisher-Yates shuffle. The problem is that it cannot generate EVERY possible permutation using pseudo-random number generator if the number of possible RNG seed states (2^n, where n is the number of bits) is less than NumberOfItems factorial. This means, for example, if you use a 16-bit RNG, you cannot have more than 65536 possible arrangements.
Another problem is that even if you have more RNG states than the number of arrangements, it actually has to exceed the number of arrangement by "at least several orders of magnitude" else certain permutations happens at a higher probability than others. This is according to Wikipedia on Fisher-Yates shuffle on Pseudorandom generators. I can't link it here because youtube's anti-spam/scam is false-positive prone and will delete my comments.
When doing n factorial and you increase n, it grows "exponentially fast", thus you need a massive memory if you are shuffling a large number of items.
@@ghb323 I'd mention that factorial doesn't just grow "exponentially fast" but in reality, it grows even faster than that because at some point, the numbers added to the factorial are larger than the base. That being said, I doubt shuffling a number of items requires a lot of memory or at least any more than double the size of the list.
@@MarioFanGamer659 Yeah, that’s why I wrapped it in quotes. Wikipedia stated it grows faster than exponentiation.
@@MarioFanGamer659 You could use hardware RNG, but be careful that this relies on physical phenomenon and is subject to degradation and could eventually be in a state it outputs uneven distribution of random numbers(some values occurring more often than others). On emulators, they may falter since they themselves might use PRNG to emulate the hardware RNG or use the computer’s rng.
I had always assumed that the 8 arrangements were hard coded! I guess you learn something new every day.
I can't believe the 8 arrangements weren't hard-coded, wow. Mind blown.
Algorithms are computationally cheaper than hard coding.
@@emptiester Not always. Case in point: if your algorithm is bugged and produces fewer configurations than you were planning to generate, so hardcoding eight arrangements would take less data.
@@emptiester "computationally cheaper" doesn't usually mean "less memory", which is almost always the only benefit of using an algorithm instead of hard-coding.
True but honestly i suspect that they made it properly, but ended up changing their minds and tweaking it to allow a manageable set. This just strikes me as intentional.
I think it's a crime that this channel only has 196k subs. I find all these videos really interesting despite not really knowing how to code.
Back in the day, I didn't think the roulette game was all that hard. I almost always could get the star (and it's 5ups). You just had to know exactly when to stop the wheels. (On a CRT, that was easy being there's no video lag.) In spite of the few patterns that existed, I never was that good at the card matching game.
omg so glad I found this channel. I did a little 8 bit programming in the 80s and I'm still fascinated by it. Love your illustrations in real time, with the numbers swinging through their places as the processor moves through the code.
So, the first slot you can get correct all the time, easy. The second slot is 19/32 = 59% if you time it right in the middle of the possibility space. The third slot is 16/64 = 25% chance to win, if you're going for the star, with every position being equally likely and no strategy can improve it. So *14.8% chance total*, with perfect timing! It's actually amazing how many people in the comments say they could "get the star every time" as a kid, it really shows that memories get seriously inaccurate if you let them sit for too long 😄
(And this is one reason why gambling is dangerous, you always think you've "figured it out" even when it's purely random...)
They must be confusing the roulette game, with the end-of-level cards. Ironically stars are the easiest to get in the end-of-level cards.
Even if the order of triple swaps and rotations was completely arbitrary, the algorithm could still only generate 1215 permutations.
To see this, let us examine the possible moves:
Rotate (ROT)
Triple swap from position 1 (TS1)
Triple swap from position 2 (TS2)
Triple swap from position 3 (TS3)
Triple swap from position 4 (TS4)
Triple swap from position 5 (TS5)
Let us notice that in the following table, any sequence on the left side of an arrow produces the exact same permutation as the one right of it:
ROT-TS1 -> TS2-ROT
ROT-TS2 -> TS3-ROT
ROT-TS3 -> TS4-ROT
ROT-TS4 -> TS5-ROT
ROT-TS5 -> TS1-ROT
ROT-ROT-ROT-ROT-ROT -> TS1-TS2-TS3-TS4-TS5
Let us take an arbitrary sequence of moves. If we find a subsequence that is in the left column of our table, we will replace it with the corresponding sequence in the right column.
For example, the sequence TS1-TS3-ROT-ROT-TS1-ROT will become TS1-TS3-ROT-TS2-ROT-ROT after we apply the rule ROT-TS1 -> TS2-ROT.
Let us note that no matter what rule we apply, the number of ROT moves will either decrease, or a ROT move will move right in our sequence. As such, if we apply the rules recursively, we will eventually be left with a sequence where no rule can be applied anymore. This sequence will still produce the same permutation as the original.
What will our sequence look like after we can no longer apply any rules? It will consist of a number of triple swaps followed by at most 4 ROT moves. This is because if there was a ROT move before a triple swap or if there were more than 4 ROT moves at the end, a rule could be applied.
We will finish by realising that the order in which we perform triple swaps doesn't actually matter. TS1-TS2 will produce the same effect as TS2-TS1, for example. As such, the only thing that matters is how many times we have performed each type of triple swap.
Furthermore, performing the same triple swap three times does nothing. As such, any arbitrary sequence of moves may be reduced to the following, in this exact order:
No more than 2 TS1 moves.
No more than 2 TS2 moves.
No more than 2 TS3 moves.
No more than 2 TS4 moves.
No more than 2 TS5 moves.
No more than 4 ROT moves.
There are a total of 3^5 * 5 sequences of this form, or a total of 1215. You may take some time trying to convince yourself that they do not contain duplicates. I believe this can most easily be seen by examining where the first 5 cards end up after any arbitrary shuffle.
As such, the video from around 12:20 is wrong. One shuffle can only produce 1215 outcomes. Furthermore, a single shuffle will actually produce every possible outcome with an equal probability. The subsequent shuffles are completely pointless. But the video is right in saying that there are a lot of duplicates.
Makes sense for the roulette. I used to get the first two rather routinely, the third was random. I just timed for when the item I wanted (the star) was in the middle. Looking at this, it actually makes sense. The first one is entirely skill based. The second, you'll get it about 59.357% (19 / 32) of the time assuming your timing is anywhere near decent. And the last one is 25% no matter what.
So the odds of getting the best item, the star are about 100% * 59.375% * 25% = 15%. So you'll average about .742 lives every time you play the game if you go for the star since it's worth five lives. But if you go for the mushroom, the odds are 100% * 59.375% * 50% = 29.7% since the mushroom makes up half of the slots. However, you only win 2 lives, so the lives per game fall back down to .594.
Still best to go for the star.
Nov, 15th, 2016.
"Retro Game Mechanics Explained is brought to you by [...] viewers like you. Thank you!" *warm flashbacks*
Great presentation, interesting and infuriating at the same time - I always blamed myself when I failed on the roulette stage.
Fascinating to know the code behind both mini-games. For the roulette wheel, I always thought that it would determine your chances of a win based on the top wheel -- so if you got a mushroom, the chances were much higher compared to if you got a star, and that the game would just "give" you the prize if you rolled a win no matter when you pressed the button as opposed to the delay and such involved. And likewise, I thought there really were just eight arrays of cards that were chosen at random instead of broken code that made a true shuffle fail to operate properly.
Props to you already using the new patreon logo! Regardless of how people feel about it (I’m personally not the biggest fan of the blob) that is the kind of attention to detail I’ve come to expect from this channel
Time flies, already another one? Last change was in 2020
To this day I remember that the third card to the right on the top row and the second card from the right on the last row are both usually fire flowers. I saw that pattern when I was 5 and it somehow stuck with me for the rest of my life. It's wild to me now that it's only a 62.5% chance it felt like it happened almost all the time, but that's memories for you.
"No one-a cheats-a Super Mario!" -Dorkly Mario, "Toad House is Rigged"
man i just love these videos. they remind me why i got into coding, it's such an interesting way of problem-solving and i love imagining the thought process of the people writing these games.
Learning so much about the OG SMB3. Nice to know the mechanics of the card-match and roulette games haha
Do you know if the code is any different for the SM: All-Stars or SMA4 variants? An explanation or mini-follow up video would be awesome ^^
All-Stars code is nearly identical to the NES version, the games in All-Stars are essentially direct ports with some tweaks and of course new sprites and sound. No idea about Mario Advance 4, though I'd assume it's a port of the All-Stars version but I don't know that.
Edit: Just checked TCCF, Advance 4 is a direct port of All-Stars, so it should still be the same unless Nintendo specifically decided to change it.
I reject your hypothesis and I submit my childhood confirmation bias for the court record! **blows cartridge**
I find this interesting in the fact as a kid, I could pretty much time the roulette to give me a Star almost every time. I was never able to figure out the N-Spade patterns though. 🤔
There was a time when I was young when I had all the card layouts mesmerized and I was pretty good at the match game too. We had an official SMB3 Strategy guide that had them all too, wish I still had that.
What??? I've been able to hit the roulette game nearly every time because I know when to press the button. I'm gonna have to go back and play a few times because my brain is telling me I was incredibly good at this game.
How did it go
I love these old school video game breakdowns. When I was a kid I'd spam the A button on these card games and I'd get 2-up the vast majority of the time. When I tried to do it again last year when I was humoring speedrunning it and practicing/needing lives I just could rarely re-create my childhood experience.
What's funny about this is that I never learned the matching game layouts as a kid, so never cared for that game, but I could fairly consistently win the slot game. Regardless of how the code should make it unpredictable, it usually is a fairly simple timing minigame.
Stop the first real when the picture you want is in the center. Stop the second just before the picture you want is fully centered. Stop the third just as the picture you want is leaving the screen.
The RNG does beat it sometimes, but this method served me very well as a child.
That card shuffle/folding animation was oh so good. Chef's kiss
The roulette game may have been more random than what it seems, but if you have good timing you can consistently win. I remember as a kid hitting A immediately when the game starts and then hit A just slightly before the previous image stops. It lines up 3 mushrooms, but hey it's better than not winning. I'm sure theres a way to time the star but I never cared to figure it out.
17:00 absolutely brilliant display of what you just explained. Amazingly well done.
0:20 With the 3 part roulette, I found the first to be random.
But in actuality, I always managed to match the second if I hit one early...press the button on star and i would get the mushroom every time.
For the final slide, there was a pixel error where the two slides met...6 pixels would flash in succession. Press the button when the pixel lined up and it worked every time.
You can actually see it on screen.
So yes there was randomness, but defects in the game made it easier.
great video! I'm very appreciative of your excellent captions
(8:05) I assume that is to add the human element. The game will continue to randomise until the player continues. So you have the pressing the button to the map and dialogue adding randomisation.
Having the second and third wheel not affected by the timing you press the button does have an affect on using save states, and that's kinda interesting.
I remember the card game having only two layouts that I memorized and could always nail the first time. I also somehow "mastered" the roulette wheel.
Amazing what my brain could do thirty years ago.
Almost defies reality!
Do you know if the All-Stars version of the roulette is any different? Anecdotally, it always felt easier to me, but I don't know if that's just confirmation bias.
mario 3 all stars is nearly 1:1 the code of the nes version, its probably identical honestly
Just discovered this channel. I too always wondered why I could never master the timing of that roulette game. But it all makes sense now. Yes, the delay of the last row was noticeably longer. Mind blown by the "not so random" card matching game. Like others, I feel it was on purpose though.
At least its accurate to how it is irl
Nice PBS reference with the Viewers Like You bit
So wait, if the second and third bars' slip amounts are frozen while playing, is there any correlation that would allow you to predict how much the third bar will slip from how far the second bar slipped?
not really, because the info that is now in the second rng slot(second bar) is generated from the info that is now in the third slot (third bard) and the fourth slot, and even then the second bar only use 5 bits of the second slot rng value. Even if you knew the 5 bits, you can't use this info without the fourth slot values to try to get the third slot values
I can let myself off the hook for years of failing this minigame now.
i played SMB3 once on the NSO emulators and checked out mentally right after failing the spinny minigame. It was so far off of a match I actually couldn't believe I did so poorly. Feels good knowing this specific instance isn't just me being bad at video games for old people!
Really interesting and informative vid, it’s crazy how two separate mistakes combined just enough to ruin the whole rng process for card matching
That's weird, I found the roulette felt really consistent and I won it a lot.
Yeah the roulette was consistent for me too and the card matching was never a strong suit
@@AshleyTMDW”strong suit” I see what you did there
If the 3rd wheel is effectively random, then you will win 1/3rd of the time at least if you consistently get the first 2 wheels. It's probably confirmation bias.
@@QuasarEE Perhaps, but it just didn't feel as unwinnable as the video claims it is.
I think the cards thing was deliberate to make it simpler for players, or it could have been deemed not needed due to the limited amount of times you can see the cards in a play through anyway. It also really subscribes to Nintendo's philosophy of playing games together that they had in the 80s. If it was so random that no 2 players would ever get the same board there would be nothing to talk about, no rumors.
3:18 🏳️⚧️
I have positively zero reason to doubt this because you've looked at the actual code, but I always thought the roulette was all down to timing! I had a rhythm down that would win it what I thought was far more often than not, but that could have been just confirmation bias. Seeing the bare bones of it here, it doesn't seem like there's any way my timing was that good, nor would the timing I had correlate to one specific result!
Okay so I used to watch PBS Kids a LOT when I was little, and ooooohh my god the “Viewers like you, Thank you!” I swear is ripped directly from those childhood memories
I absolutely love exploration of old video game code like this, especially to this level of detail. Super interesting stuff!
Just having this for my own purposes, at 3:49, "Roulette_Run" is Roulette_Run in program 22, at 8:18, "Randomize_Roulette" is right after JSR Read_Joypads and before PRG022_CF7C, at 13:07, "Card_Shuffle" is Card_Shuffle in program 22, and at 15:50, "Randomize" is Randomize in program 30.
Absolutely fantastic breakdown! Insane how much work was lost because of that error!
My world is shattered.
I'm really good at the roulette game.
I thought I was skilled... Turns out I'm just lucky.
That card-shuffling animation you made was _very_ smooth.
Great video, hope you show more related with SMB3, i love this game, and I am learning ASM
" nearly impossible " I used to fucking crush the roulette mini game as a kid.
I love the LFSR videos. Its fun to see how different each implementation is
Fun fact: even if (just) the first fix was applied to the shuffle logic as explained at 18:09 , there would not be 15^3 = 3375 possible outcomes as a result, but only 225. The second change at 18:21 would increase this to a mere 1050 instead of 216000. That's because the triple-swap is symmetric to rotations of multiples of 5, i.e. triple-swap + rotate 5 has the exact same outcome as rotate 5 + triple-swap. So the first case effectively ends up with 15 cases of rotation plus 2 triple-swaps at arbitrary offsets with 5 cases each (order does not matter, thus cases total and not 25) (plus the third triple-swap at fixed offset of 0), thus 225 total. The second case is a bit more complicated but similar. Only the last suggestion would increase the number of cases as intended - to 88990.
Fun fact: tRump lost the election
thank you for making the subtitles not clash with the any of the actual text
Sixty percent. That's the expected percentage of duplicates. I've played cards long enough to know that shuffling has a one in sixty-six thousand chance of not doing effectively a damn thing. This has historically led to people being called 'cheaters' when it was the deck just being shuffled enough that the outcome was returned to the previous. Yep, people were killed over this.
(1/66,534)
Thank you, very interesting video. I also want to say that I can see that you are not using clickbaity titles and thumbnails and the videos are very to the point without stupid jokes and trying to mix-in the ad with the video content. This is very much appreciated even though it puts you at a disadvantage in the toxic world of youtube algorithm. Thanks for staying true to quality.
The memory game. I start with the top left corner. If it's a plant I move 3 to the right. That's my preferred start.
Damn I also thought the 8 card layouts was on purpose. Very fascinating to see what the breakdown in the randomization there was
The roulette game is easily hacked. I could always score stars on it.
Simply watch closely and as soon as your desired item passes the centerline of the screen, hit the button. The row will then "slow down" one full rotation, landing on the item you selected. Repeat this for the other two rows. I scored 5-ups on the regular.
so vindicating. also knowing the card-matching used only certain patterns helps understand how, after a while, I somehow gained the ability to predict where cards were reliably.
omg...I thought I was so good at this minigame as a kid, but got worse when I got older.
So I was either really lucky, or I had lower standards! lol
Never had an issue consistently winning the roulette game. With practice, you can consistently match 3 about 9/10 times.
That's fascinating. Now I want to see the same thing for the SMB2 slot machine game. I mastered that one to where I could nearly always get 5UP, nothing, 5UP, nothing etc., and it's such an odd pattern I always wondered why it worked out that way.