How Frightened Ghosts Decide Where to Go

  Рет қаралды 261,359

Retro Game Mechanics Explained

Retro Game Mechanics Explained

Күн бұрын

How do the frightened ghosts in Pac-Man decide where to move? It's all explained right here.
LINKS
Support the channel on Patreon: / rgmechex
Support the channel on SubscribeStar: www.subscribes...
Join the RGMechEx Discord Server: discord.rgmeche...
Follow RGMechEx on Twitter: / retrogamemechex
Follow RGMechEx on Cohost: cohost.org/RGM...

Пікірлер: 564
@stanleydodds9
@stanleydodds9 Жыл бұрын
Markov chains are great. I was going to point out that this is a perfect example of a discrete time markov chain problem, but then it showed up in the video. Since you already covered that, I guess I'll add that a different way to solve this is to view it as an eigenvector - eigenvalue decomposition of the transition matrix, which is usually the way that I think about discrete markov chains. The benefit that comes with looking at the various eigenspaces instead of just simulating it, is that the additional information of having all of the eigenvectors and values is able to encapsulate all of the slightly tricky situations that you can encounter. For example, you mention that you needed to start it on 2 adjacent squares, and this is because of the checkerboard nature of adjacent cells on a square grid. There is a parity, and ghosts can only move from one parity to the other at each time step. So if you only started on one square, at every time step only half of the squares would have any non-zero probability on them. By getting the jordan normal form, you can easily see what would happen in the limit for starting on 2 adjacent squares, starting on just 1 square, or anything else.
@RGMechEx
@RGMechEx Жыл бұрын
Bingo! I had originally planned to show off this checkerboarding pattern, but for the sake of visuals I split it up the way I did. This means technically that the chain in the video is actually *not* ergodic but rather 2-periodic. Splitting it up 50/50 does make it settle on a single steady state though (and looks better on video)!
@oldvlognewtricks
@oldvlognewtricks Жыл бұрын
I like your funny words, magic men 😅
@sippingthe
@sippingthe Жыл бұрын
what words did i just read
@Chubby_Bub
@Chubby_Bub Жыл бұрын
Having learned just enough linear algebra to only half-understand this gives probably a worse feeling than not understanding it at all
@wirelyre
@wirelyre Жыл бұрын
@@Chubby_Bub Go to the numeric simulation and pause. There are a bunch of numbers on screen that represent the probability a ghost is at that position. Shove em all in a vector. In this case it's like a 500-dimensional vector but you can visualize it in 3D as long as you don't try to do something insane like take a cross product. So you've got a vector for the state. Better yet, you've got a space that represents every possible probability-state. (Exercise: What is the natural basis for this space? Is it orthonormal? What do those basis vectors represent?) Now, you'll have to hold both the visualization and the simulated interpretation in mind at the same time for this next bit. Take a single simulation step. _Click…_ The vector changes. _Click… Click… Click…_ Every step makes the vector jump a little bit. (Exercise: What property does every state vector have?) In fact the step function is a linear transformation. You can write it as a square matrix. If the simulation converges, that means that repeatedly applying the linear transformation to the initial vector converges to some other vector. And if you find a vector which is invariant under the transformation, you've found a steady state of probabilities. That's the definition of an eigenvector. By representing the state transition as a matrix you can just do linear algebra to figure out its steady state, if it has one. But wait - there's more. Ghost walks in the maze have period 2: If a ghost starts on a tile and continues walking, at every point in time only half of the board is accessible. The probability of half of the tiles is zero. Those two smart people above are saying you can see this from the Jordan canonical form but I can't picture that because I took my linear algebra class like 150 years ago. Anyway, linear algebra is easy. All you have to do is imagine 500 dimensions and you're good to go.
@fluffberrieh2335
@fluffberrieh2335 Жыл бұрын
Thinking quickly, Dave crafted a random number generator out of an index, a KiB of data, and a random number generator
@lavenderinthedark
@lavenderinthedark Жыл бұрын
when i saw that the output of the rng was literally determined by the first bit of the game rom it put a huge smile on my face, its so crazy what early programmers managed to accomplish with so little room to spare
@torgematthies2172
@torgematthies2172 Жыл бұрын
​@@lavenderinthedark But they just made it worse by turning a perfectly evenly distributed RNG into a heavily biased RNG. EDIT: Actually the original RNG was bad too so indexing into the rom might be better...
@Vextrove
@Vextrove Жыл бұрын
​@@torgematthies2172 why was it bad? Too predictable?
@Damian_1989
@Damian_1989 Жыл бұрын
Excellent Dave the Barbarian reference, btw.
@CptJistuce
@CptJistuce Жыл бұрын
​@@Vextrove Because it's sequential. It grows until it hits 8192, then drops and grows again. Indexing into ROM is an attempt to make it non-sequential. And is... mostly-successful.
@ozziegerff
@ozziegerff Жыл бұрын
Imagine making a good rng function and being like this needs to then read off memory values, ruining its perfect odds. Now the ghosts have a crying corner for when they get scared.
@AiOinc1
@AiOinc1 Жыл бұрын
Actually, this is much more common than you might think. Consider as well that adding a table of sufficient size for this would add a significant total to the game's final size, further increasing it's production cost.
@klafbang
@klafbang Жыл бұрын
Uniformity is not the only desirable feature of a rng. n -> n + 1 achieves this but isn’t very random. n - 5n + 1 isn’t much better; since we only use the last 2 bits all the modulo junk disappears, and the rng literally becomes 01 -> 10 -> 11 -> 00 -> 01, which, while uniform, is very predictable. Even more since we have 4 ghosts, each pulling exactly one random number per turn.
@lilium724
@lilium724 Жыл бұрын
tbh it is a hilarious idea
@cadekachelmeier7251
@cadekachelmeier7251 Жыл бұрын
That's where Clyde likes to hang out anyway.
@snailymitch
@snailymitch Жыл бұрын
​@@klafbang Predictability doesnt matter because the position of the ghosts when they get scared isn't going to be consistent in the first place. Regardless, pulling a byte from the game's memory doesn't really solve this issue in the slightest, it doesn't make the function more random it just adds an extra step.
@einootspork
@einootspork Жыл бұрын
I like how you admit at the end that none of this really matters in actual gameplay, it's just fun to think about.
@Hubip
@Hubip Жыл бұрын
Sounds just like all my rng research for speedrunners! 😂 It's really interesting though!! Haha
@jimmyhirr5773
@jimmyhirr5773 Жыл бұрын
It's useful if you are trying to get the high score. Knowing which way ghosts are most likely to go at intersections while frightened makes it easier to eat them. Up to 12,000 bonus points can be gained per level from eating frightened ghosts. To put this in perspective, only 2600 points can be gained from eating all of the pellets in a level.
@AzureLazuline
@AzureLazuline Жыл бұрын
@@jimmyhirr5773 if you're going for maximum score, only 17 out of the 256 levels actually let you eat the ghosts. It's still a little useful to know they're more likely to turn left, but it only matters right at the beginning.
@ItsMisterMarbles
@ItsMisterMarbles Жыл бұрын
The issues with the clockwise-turn behavior making bad distributions is very similar to an issue with mazes in Roller Coaster Tycoon. Marcel Vos did a video about it on his channel about how you could abuse this to make a short maze that is practically impossible for guests to get through.
@williamdrum9899
@williamdrum9899 Жыл бұрын
Easily his best video imo.
@RGMechEx
@RGMechEx Жыл бұрын
Maybe Pac-Man ghosts are the reanimated souls of the RCT guests that "mysteriously" drowned in the park's pond.
@j.hawkins8779
@j.hawkins8779 Жыл бұрын
@@RGMechEx BWAHAHAHAHA!! *beautiful*
@ohnoitschris
@ohnoitschris Жыл бұрын
Marcel Vos is one of my favorite channels
@kevinr.9733
@kevinr.9733 Жыл бұрын
You beat me to it. Oh, well. Having another comment that says roughly the same thing (albeit wordierly) on the same video won't hurt anyone.
@WishMakers
@WishMakers Жыл бұрын
The idea of grabbing a *byte from the game's code* as an RNG output has got to be one of the funniest things I've heard of all day
@nstbayless
@nstbayless Жыл бұрын
The Atari 2600 game "Yar's Revenge" did the same thing. It's a fun trick. I'm sure yet others did this, too.
@cheaterman49
@cheaterman49 Жыл бұрын
@@nstbayless It could actually work a whole lot better if they happened to have any compressed data in ROM, since it's highly entropic one could expect the distribution to be a bit more balanced ; I now wonder if Pokémon used the sprite data for the RNG
@thesquirrelisking
@thesquirrelisking Жыл бұрын
​@@cheaterman49 og pokemon was written by people with a passing understanding of the concept of programming, the way they stored and retrieved some information is responsible for the famous missingno glitch. I forget the specifics but it's wild, so many things in those games just don't work as intended because of the way they're programmed
@cheaterman49
@cheaterman49 Жыл бұрын
@@thesquirrelisking I tend to cut them some slack, they were working on a system where doing things properly would have been too slow, they were literally chasing cycles haha
@spiralofants1236
@spiralofants1236 Жыл бұрын
​@@thesquirrelisking hey, no offense, but if you think those Gameboy games were coded by people who had very little understanding of programming, I don't think you could hello world yourself out of BASIC. Anyone who's coded in html even once could tell you the amount of work that goes into a fullscale game like that, especially on proprietary hardware.
@minerharry
@minerharry Жыл бұрын
I shudder at how much work laying out those Markov chain arrows must have been…
@nickwallette6201
@nickwallette6201 Жыл бұрын
As someone who occasionally designs PCBs, I felt that. :-)
@durdleduc8520
@durdleduc8520 7 ай бұрын
i can only imagine they wrote an algorithm to calculate all of the vectors for them. right? right??
@mochafennec
@mochafennec 7 ай бұрын
@@durdleduc8520 I wouldn't be so sure. RGME has calculated Pokemon sprite decompression and drawn it out by hand before.
@kaidurbin
@kaidurbin Жыл бұрын
For anybody wondering why they didn't just use the bottom two bits of the index, I just wrote a program to test the results of what would happen if you just used the bottom two bits for the direction, and the results showed that it would output RIGHT, DOWN, LEFT, UP in sequence over and over again, which is *definitely* not ideal. And if you were to try to get tricky and use a different pair of adjacent bits in the number, while the end result would be better, it still wouldn't be ideal as the values would tend to clump together. (eg. six RIGHTS appearing in a row followed by a long stretch without any RIGHTS.)
@kellamyoshikage286
@kellamyoshikage286 Жыл бұрын
you can see this just from the function used, a_(n+1) = 5 a_n + 1. Looking at the bottom 2 bits here is equivalent to looking at each term mod 4. a_(n+1) mod 4 ~= (5 a_n + 1) mod 4 ~= (a_n + 1 + 4 a_n) mod 4 ~= (a_n + 1) mod 4. I'm using ~= to indicate congruence here, can't remember if I'm supposed to use the 3 line equals or not. This result indicates that when looking at the bottom 2 bits, the recurrence actually just always adds 1, never anything more interesting.
@cononsberg6919
@cononsberg6919 7 ай бұрын
Now I actually kind of want to see how using this kind of RNG would impact the ghosts' movement.
@kevinr.9733
@kevinr.9733 Жыл бұрын
Fun fact: RollerCoaster Tycoon 2 (and probably the first game, but I can't say for sure) has the same clockwise bias issue with the "pathfinding" algorithm for the hedge maze attraction. This means that it is possible to create a maze that takes significantly longer on average for guests to complete if the entrance is on one side than if the entrance is on the other. I'm pretty sure the RNG function itself is reasonably non-biased, though. (Or at least less biased than Pac-Man's.) When Marcel Vos made a video pointing this out, OpenRCT2 _immediately_ changed the pathfinding algorithm to be less biased.
@cxreykx6114
@cxreykx6114 Жыл бұрын
The fact that randomness is arguably impossible makes sense, you could argue a coin flip isn't random, it's based on height of the flip, speed, how fast it's spinning, which I guess - in theory - one could be precise about
@terdragontra8900
@terdragontra8900 Жыл бұрын
since in many systems small changes explode exponentially, and (as far as we know) quantum mechanics isnt deterministic, this actually isn't true! for a coin flip quantum uncertainty probably isnt relevant, but for say, what the weather will be like in exactly one year? *literally* random
@cxreykx6114
@cxreykx6114 Жыл бұрын
@@terdragontra8900 Interesting! I want to learn more about that, outside of the video games it's definitely not a concept Im familiar with
@bluegum6438
@bluegum6438 Жыл бұрын
@@terdragontra8900 As far as I understand it, everything is deterministic, it's just often so astronomically complex there is no way a human could ever grasp it. i.e. randomness does not actually exist, it's just our way of describing events where the cause-and-effect chain is unclear to us. Quantum mechanics includes uncertainties for states but this is just a mathematical structure to describe the behaviour of systems, since there is no way to directly observe interactions. The actual interactions play out in a deterministic fashion.
@terdragontra8900
@terdragontra8900 Жыл бұрын
@@bluegum6438 Read up on "hidden variables" and have your mind blown. We've proven experimentally that entangled particles *do not* decide how they will be measured in the future when they are created.
@GarryDumblowski
@GarryDumblowski Жыл бұрын
For a more concrete example of true randomness in nature, IIRC it's been observed that it's completely random how far an electron will be from the nucleus of its atom when measured (though the distribution isn't uniform, they tend to hover around predictable distances, but they're still not guaranteed whether or not they'll appear at that distance at all). Another example is how it's random when a radioactive particle will decay, which means that theoretically a lump of radioactive material could at any point just decide not to be radioactive for a full minute or so.
@EebstertheGreat
@EebstertheGreat Жыл бұрын
This description of Markov chains is actually quite intuitive, and I think that's a very important lesson. Markov chains come up all the time when analyzing video games, and also just in general, so they are a good tool to have.
@SSJ3Tim
@SSJ3Tim Жыл бұрын
Wasn't expecting the seamless transition into a 3Blue1Brown style explanation of Markov Chains, but I love it
@ryanlutes9833
@ryanlutes9833 Жыл бұрын
I recently coded a turn-based Pac-Man clone in C# as part of a larger project, and one of the major sources I used for information on the ghost behaviors was a RGME video, so, just wanted to say thank you for all the wonderful documentation you do. It's not just informative, but entertaining too. 👍
@SuperSpy00bob
@SuperSpy00bob Жыл бұрын
"How Frightened Ghosts Decide Where to Go" 29 minutes long. I love this channel.
@DoritoChipProductions
@DoritoChipProductions 8 ай бұрын
Me too
@MarioDSLife
@MarioDSLife Жыл бұрын
I was supposed to do a course involving Markov Chains but given how boring lectures are, I barely learnt anything. However when the same concept (which I’m new to) is applied into one of my favorite video games, I understand it well. I wish more lecturers would provide applications to the theories we learn, I think we’d all learn better that way. Thank you for the video.
@MidnyteSketch
@MidnyteSketch Жыл бұрын
A nice coincidence that most of the pie charts for the 3-way intersections end up with you drawing Pac Man eating the lesser option.
@jonatanmonsalve11
@jonatanmonsalve11 Жыл бұрын
The incredibly INSANE amount of work put into calculating, illustrating, and *especially* animating information that would be of virtually no use to us whatsoever other than maybe to appreciate how programmers of the past used to solve problems... is just beautiful. This is art. When I saw the title and the duration of the video I was like "How can you spend 30 minutes explaining something like this!?", but after watching it, I feel way more satisfied with the whole markov and path deduction explanation than I would have been if you have stopped after the RNG and path choosing percentage explanation. Great video.
@mrshurukan
@mrshurukan Жыл бұрын
This markov chain you tought me in this video came in clutch for my programming olympiad. Thank you so much!!! I had a task where I had to simulate a castle guard moving from starting position in the middle of the castle to one of two gates (picked by chance), but along the way to the chosen gate he might decide he forgot something and come back (also decided by given chance). Once he's back he can pick either gate again. However if he reaches one of the two gates he doesn't come back as he's out of the castle. The task is to compute probabilities of him reaching gate 1 and gate 2 I immediately though of this video!! I progeammed the solution in about 10 minutes and was the first to score 100 in that particular task. You are the GOAT, man
@TrianguloY
@TrianguloY Жыл бұрын
I wonder what the resulting odds would be if: 1) the random function index is used directly instead (don't index the rom) 2) If an invalid option is chosen, the ghost tries the counterclockwise direction (instead of the clockwise)
@klafbang
@klafbang Жыл бұрын
1 much, much worse. You’d have a function with period 4, from which you’d pick 4 random numbers per cycle. Each ghost would be 100% predictable.
@TrianguloY
@TrianguloY Жыл бұрын
@@klafbang Are you sure? I'm not referring to just 1,2,3,4,5... but the 1,6,31... (the index as explained in 3:26). The current rng is also period 4. I guess it would be more similar (if not the same) as the 25% test
@klafbang
@klafbang Жыл бұрын
@@TrianguloY the current rng is period 8192; the modulo matters when looking up in the rom. It might be 00 -> 01 -> 00 -> 11 (or whatever). The index you’re using as input is not directly linked to what you output, sou can have a longer period.
@klafbang
@klafbang Жыл бұрын
It works out like that because of modular artithmetics. Basically, you can move the mods around wherever. ((5n + 1) mod 8192) mod 4) = (5n + 1) mod 4 (as 4 divides 8192) = (5(n mod 4) + 1) mod 4, so the computation without going via rom becomes a simple operation on only the two bits of output, giving it at most 4 possible values.
@TrianguloY
@TrianguloY Жыл бұрын
Oh! I see it now. Since 8192 is divisible by 4 the output is 5n+1 (mod 4) and with modulo operations you can simplify it to (5 mod 4)n + (1 mod 4) which is n+1! So the sequence is 0,1,2,3,0,1,2,3... *alternatively 4n + n + 1 (mod 4) so 0+n+1
@eizneckam4936
@eizneckam4936 Жыл бұрын
"This will give us a heat map of where frightened ghosts like to hang out in the maze" is my favorite no-context sentence from these videos now. Amazing video as always! Edit: I'm guessing the 50 ghosts each is because the RNG is called to determine which tile the ghosts come out of the house on initially?
@theecube1
@theecube1 Жыл бұрын
i love that, in addition to being an excellent video on probability states (and more!), it's also an object less in game design (specicially, in how to actually finish a game and not get stuck in the weeds) "yes, it's not mathematically perfect, but given how it will *actually* be used it'll be good enough"
@jeremyn2626
@jeremyn2626 Жыл бұрын
I didn't even know ghosts didn't become frightened in more advanced levels. This game was very slightly before my time and I never got into it.
@andrewphilos
@andrewphilos Жыл бұрын
They spend several seconds frightened in the first level, and then the length of time gets shorter and shorter each level.
@brandonfrancey5592
@brandonfrancey5592 Жыл бұрын
The exact same behavior occurs when eating a power pellet, just the length of time they are frightened gets shorter and shorter until they flash, turn around and instantly are not frightened.
@danielbriggs991
@danielbriggs991 Жыл бұрын
In Ms. Pac-Man, the duration gets shorter and shorter by level until it's only a frame or something, but then it gets longer again and then it gets shorter faster. At least, with the factory settings of the tables I've played.
@Jeremo-FD
@Jeremo-FD Жыл бұрын
I don't know if you used Markov chains to teach me about Pac-Man, or if you used my love of retro game mechanics to teach me about Markov chains. Either way, it was a fascinating endeavor. Thank you for sharing it.
@bauske
@bauske Жыл бұрын
This was fascinating to watch. I knew it was complicated, but didn't expect how deep you'd go into it. Really great work!
@corellioncrusaderproductio4679
@corellioncrusaderproductio4679 Жыл бұрын
I would have to agree!
@packmanias3389
@packmanias3389 Жыл бұрын
YES A NEW VIDEO ABOUT HOW GAMES WORK I'm a student game developper and I just adore watching those video breaking down how the gameplay actually work It would be really cool if you could show us how ai and action and stuff work in some other games, like how do they spawn so much ship in galaga or looking at centiped
@diligentcircle
@diligentcircle Жыл бұрын
Pac-Man is quite representative of how "AI" usually works in games: either a deterministic set of instructions, or pseudo-randomness, or some combination of the two.
@williamdrum9899
@williamdrum9899 Жыл бұрын
I imagine how it works (at least for Galaga) is that while the ships are flying in a line, they're treated as one entity for movement purposes, kind of like the swarms of bats in Breath of the Wild. At least, that's what I'd do. Couldn't tell you for a fact.
@snoozbuster
@snoozbuster Жыл бұрын
This was a really cool video. I have an rgb keyboard with a programmable microprocessor on it and one of the things I've been interested in doing for a while was building a rgb function that uses a markov chain to render a heatmap with the rgbs that predicts the most likely key to be pressed next given any keypress. Seeing you do something very similar here gave me a pretty solid understanding of how that would work! (Also, helped me realize that such a chain needs to include not just single keypresses but combination states where multiple keys are pressed - which makes me think such a chain might exceed the RAM capacity of my poor keyboard!)
@AzureLazuline
@AzureLazuline Жыл бұрын
indexing into the rom is so whimsical! I'm not sure if it made the generator better or worse, and ultimately it doesn't matter, but they must've been so happy to be able to write that one instruction. It just feels so cute 😄
@nikkiofthevalley
@nikkiofthevalley 10 ай бұрын
It made it better. If they just used the index, the ghost movement would have period 4, and the ghosts would just move around in a really obvious pattern. But since they used the entire index (as opposed to a couple bits of it), the ghost movement has period 8192, which is a lot less obvious.
@Asterra2
@Asterra2 Жыл бұрын
_Wow, this video is super-professionally handcrafted and obsessively detailed. Every time I think it's reached the peak of scrutiny, it goes one step further. But I think I've reached the end._ 27:56 *"In reality, the main factor that determines where a frightened ghost is in the maze is when Pac-Man eats the power pellet."* _Oh no._
@L4Vo5
@L4Vo5 Жыл бұрын
It's worth noting that even though accessing the game's data seems like a worse idea than just using the uniform index, IF the index was used as the random number and the direction was picked from the lower 2 bits, then the rng order would always follow the sequence (right, down, left, up), because after multiplying by 5 and adding 1, any value ending in 00 would end up with 01, 01 with 10, 10 with 11, and 11 with 00. and 8192 is divisible by 4 so the rule wouldn't break when overflowing.
@CSanykdotCom
@CSanykdotCom Жыл бұрын
This is a fantastic deep dive study into the behavior of Pac Man. Really well explained. Nice job!
@stevenschiro1838
@stevenschiro1838 Жыл бұрын
Yes! The long awaited sequel to the PacMan AI video. That's one of my favorite ones you've ever done
@cmyk8964
@cmyk8964 Жыл бұрын
“This RNG function has uniform output.” “Great! Let’s just truncate it to one byte and-” “Make it not uniform.”
@Aethelia
@Aethelia Жыл бұрын
As someone who only knew the part about them tending towards the bottom left, by making a cheat code to permanently make them frightened and then just noticing where they went, I thank you for going so much further. I never even tried to find out "why", but I have the answer now thanks to you.
@squ1dd13
@squ1dd13 Жыл бұрын
Fantastic video. Your brilliant explanation along with the clean graphical style makes it really easy to follow. I didn’t notice nearly 30 minutes had passed! Keep it up ❤
@Rationalific
@Rationalific Жыл бұрын
You're really brilliant to be able to understand and explain all of this. I wonder what the creators of Pac-Man in 1980 would think regarding this video made around 43 years later about the RNG of the frightened ghosts from their game...
@jimmyhirr5773
@jimmyhirr5773 Жыл бұрын
To put it simply, a Markov chain is a graph of states where the probability of the next state depends only on the current state. This is why RGME had to add one node for each possible entrance into a tile: the entry direction is part of the state.
@danburrykerman6826
@danburrykerman6826 Жыл бұрын
You said to guess why you placed the ghosts at the door. I can assume it's 1. because that's just where ghosts start at the beginning of the game / that's where an eaten ghost ends up at, which then it is no longer frightened, or 2. that it's the center of the map and is the best possible starting location to attempt to even out probabilities.
@Ciofey
@Ciofey Жыл бұрын
You can switch from ghost random direction to ghost random direction priority lists. Instead of choosing between u, l, d, r, you can choose between any random vector [u, l, d, r], and prioritize the vector values from left to right. This will remove bias, and reduce loops.
@sebbes333
@sebbes333 Жыл бұрын
22:58 This is like some kind of *_"quantum map"_* about the probabilities of finding a ghost at any 1 tile :D
@Glowblue1
@Glowblue1 Жыл бұрын
Ugh... it's been 15 years since my random processes class in grad school and I never thought I'd have to suffer through a Markov chain again, especially in a retro game video!
@williamdrum9899
@williamdrum9899 Жыл бұрын
CS Teachers: "Derefencing naked pointers is undefined behavior" Pac-Man Programmers: Hold my osake
@64jcl
@64jcl Жыл бұрын
Very cool that the RNG was used to index the rom. Ever since I read that in Donkey Kong in the early levels the chance whether a barrel should go down a ladder vs pass it is dependent on the direction of Jumpman/Mario, I have always thought it would be very cool for the user to affect the RNG by their actions. No doubt there should be a game in such a mechanic where a player can feel like they become "Neo controlling the Matrix" by actually affecting the RNG to control critters in a game by plain actions, would be so cool.
@InsaneFirebat
@InsaneFirebat Жыл бұрын
9:02 Thank you for answering this very important question I was wondering. It is unfortunate.
@originalfred66
@originalfred66 6 күн бұрын
I wrote a Pac-Many style game in Basic on my Atari computer when I was a kid. Basic was very slow, so I needed very simple ghost logic. I decided to pick a direction at random when the ghost reached an intersection. Then, if that direction was away from the player, it would pick a 2nd random direction. That logic actually worked very well. The ghosts would generally move toward the player but with a sufficient amount of random moves that were also away from the player.
@fourtwizzy
@fourtwizzy Жыл бұрын
The reason you placed 50 ghosts on the squares near the ghost house is due to the probability they will be coming out of the house frightened. Also you would technically need a markov chain to find out which location they are most likely to be in prior to being frightened. You would then need to determine the probability of which direction they would be going at said vertices. All to determine where you should place ghosts and what their initial trajectory is. Or you can choose the only spots to which there are two trajectories and a high probability they will originate from there. I would also guess the function to leave the house does not have any RNG, there by filtering out any “RNG affecting RNG results. Pardon any spelling errors as I’m typing this on a mobile device.
@whtiequillBj
@whtiequillBj Жыл бұрын
This is just an interesting fact: 1:12 technically dice and coins aren't random either. It just isn't predictable cause you'd need to know the state of the die or coin at all times. If this was humanly possible it would be considered deterministic. The very best source of randomness is atmospheric noise such as lightning discharges, and coronal mass ejections (from the sun). If one could reverse the mechanics of the sun and find how the coronal mass ejection happened it could be considered deterministic as well, but obviously we cannot.
@Nintendotron64
@Nintendotron64 Жыл бұрын
So for all practical purposes, dice and coins might as well be perfectly random.
@algotkristoffersson15
@algotkristoffersson15 7 ай бұрын
Except the fact that atmospheric noise is random makes dice random as the forces from the atmospheric noise affect how the dice moves.
@CarissaNomadic
@CarissaNomadic Жыл бұрын
This really shows what difference the tools we have today can make compared to the tools we used to have. It'd be next to trivial to just have a computer sample the bits distribution (or emulate the results) with some time on the side, but back then they did not have the processing power or anything else to make sure their numbers worked. Not... that it hurts the game too bad, I guess?
@williamdrum9899
@williamdrum9899 Жыл бұрын
They probably just played it and thought "This is good enough" and kept it the way it was. They weren't trying to make it cryptographically secure after all.
@williamdrum9899
@williamdrum9899 Жыл бұрын
@Neb6 Seems like it would take a ton of ROM space to store those sine tables. Let's face it, this is the Z80, you're not going to actually calculate sine waves in real time.
@joshuajordan4080
@joshuajordan4080 Жыл бұрын
The original Pac-man video was actually how I found this channel.
@AmyraCarter
@AmyraCarter Жыл бұрын
I myself have found that most of the time when playing, the frightened monsters favor the side bridging corridors. I dunno.
@ray30k
@ray30k Жыл бұрын
Love me a video that's 30 minutes of "here is exactly why this happens, and also why it doesn't matter one bit." It's an absolute delight for me~
@rerere284
@rerere284 Жыл бұрын
16:51 when you mentioned ergodic chains being the main exception, I immediately thought of the other kind of exception, which would result in it alternating between two steady states every turn, like crypt of the necrodancer if you couldn't stay still or attack. and then later on in the video you have to start it on two tiles to avoid this! feels neat to figure it out before the vid mentioned it.
@endymallorn
@endymallorn Жыл бұрын
Thank you for explaining this! It might not be incredibly useful to play Pac-Man with this knowledge, explaining Markov chains and the probability calculation in a familiar context with an application made it really helpful.
@Vuusteri
@Vuusteri Жыл бұрын
Incredibly well taught. Definitely learned a lot. I'm amazed tho' how you put more effort on one video than I did for my master's thesis.🥴
@AntneeUK
@AntneeUK Жыл бұрын
Very much appreciating the Pacman charts for the 3-way intersection probabilities
@elecboy5126
@elecboy5126 Жыл бұрын
Just when I was beginning to wonder about rendering in NES Rad Racer, you post once more to satiate my retro programming wizardry wonder.
@ZTimeGamingYT
@ZTimeGamingYT Жыл бұрын
Power is unpredictable sometimes. Great video as always!
@Chubby_Bub
@Chubby_Bub Жыл бұрын
This comment might be a bit repetitive and sappy, but I do really like how these videos are designed to be appealing to people both with and without deeper knowledge of the subject. I've been a fan of this channel since the SMB3 1UP video but now that I'm learning computer science and can understand this stuff more, I have a newfound appreciation.
@twixerclawford
@twixerclawford Жыл бұрын
I would've loved to see the state of the markov chain after a set number of steps, after setting the ghost position to be random, and the number of steps determined by how long the ghosts stay scared. That way, you could see the actual predicted position of a ghost depending on where it started. On top of this, there is almost certainly a bias on each ghost, according to it's code, (see: last video on Pac-Man) that may bias *where* it ends up as the pellet is eaten... I bet each kind of ghost has it's own unique position distribution simply because of that!
@NLogSpace
@NLogSpace 10 ай бұрын
The reason to 50 units of ghosts on 2 adjacent tiles is a parity thing: we can split up all tiles into two groups, just like the black and white squares on a chess board. So if a tile is white, all its neighbors are black and vice versa. If we started with all weight on a single tile, then in each step of the chain, there would be either all weight on black tiles or all weight on white tiles. So we choose two adjacent tiles (one black tile and one white tile), so that the resulting heat map will have non-zero weights on all tiles.
@wChris_
@wChris_ Жыл бұрын
Power pallets still turn ghosts around, even if they dont become frightened.
@jckbr1
@jckbr1 Жыл бұрын
One could argue they are frightened for exactly zero frames.
@evanbelcher
@evanbelcher Жыл бұрын
A Markov chain is the perfect tool to model this, but the size of it was psychotic lol. I really thought you were going to turn it into a transition matrix and multiply it with the starting matrix to get the next state, over and over rather than simulating stepwise. I don't want to count the number of nodes, but I really wonder if your computer would have enjoyed that giant matrix multiplication
@kennyholmes5196
@kennyholmes5196 Жыл бұрын
Huh. So Clyde's always hiding in the Fright-favored corner of the map.
@sunnysidedown404
@sunnysidedown404 Жыл бұрын
*_T H E L O R E_*
@HappyGardenOfLife
@HappyGardenOfLife Жыл бұрын
I didn't expect to find a spoiler from a 43 year old game. I never made it far enough in the game to have the ghosts stop being frightened.
@sa3270
@sa3270 Жыл бұрын
Back in the 80s I was at a motel that had some arcade games in a basement and a guy was playing pac-man and the bottom was filled up with keys.
@wearr_
@wearr_ Жыл бұрын
wooo a new RGME video!! These videos are what really got me into looking at how low level systems work
@moadot720
@moadot720 Жыл бұрын
I watched your other Pac-Man video! I can't BELIEVE that you made ANOTHER!
@furbyfubar
@furbyfubar 5 ай бұрын
I like how this is more educational about graph theory (and maybe assembly coding) than really helpful to play Pac-Man better, yet the framing of being about learning some Pac-Man trivia makes my flawed brain find this content way more interesting to watch than a video that was only about graph theory. It's not even the sort of Pac-Man trivia that one could use as "fun trivia", even in conversation with other nerds, but somehow that doesn't matter; it's still a great video! Watching the animation of the graph while listening to you complain about how stupidly big the Markov chain is, making it hard work to calculate I can't help but think "It must have been MANY times more work to draw and animate all those vertices compared to "just" doing the data entry and calculating the chain's steady state! You went above and beyond to actually show *all* those vertices on screen, *and* to not have the arrows between the nodes simply be straight lines, but to instead hve them curve around other nodes. I'm typing this to say that this effort was noticed and very much appreciated! That alone is well worth hitting the subscription button out of pure respect!
@datenegassie
@datenegassie Жыл бұрын
To what extent could this be balanced by changing those "unused" 00s in the ROM into other numbers? I'm guessing not much, as these 00s are already part of the 3rd most popular direction (right)
@brandonfrancey5592
@brandonfrancey5592 Жыл бұрын
Balancing the Rom numbers would just push the probabilities of each direction closer to 25% so all in all, very little would change.
@WhyCatsCantFly
@WhyCatsCantFly Жыл бұрын
I love all of your videos! they are so well researched, the visuals are perfect, and all of it is super informative
@Kajssbm
@Kajssbm Жыл бұрын
His voice is really calming. That's why I love this channel.
@Renato_Paganini
@Renato_Paganini Жыл бұрын
I love your videos. I've watched all of them, they all are excellent both in content and presentation. They helped me get a basis for many topics in game programming. I only have one question, what are the softwares and/or tools do you use to make the animations on your videos?
@RGMechEx
@RGMechEx Жыл бұрын
It's all mostly After Effects!
@MarioFanGamer659
@MarioFanGamer659 Жыл бұрын
22:50 My answer: This is the starting position of the ghosts who can only move either to the left or the right at this point and the propabilities being split there accordingly. This is a special case because none of the ghosts are on a tile so they need a special turn handler with a bias which happens to be 50-50 here. That you later have shown the ghosts coming from their home further supported my answer.
@epicponedge1177
@epicponedge1177 Жыл бұрын
I like the idea that, despite being code controlled by a RNG, the ghosts still have unequal biases when making chooses just like actual people.
@EmilMacko
@EmilMacko Жыл бұрын
Damn stellar job animating those graphs dude!
@LegendBegins
@LegendBegins Жыл бұрын
Excellent! Phenomenal video as always, RGME.
@kargaroc386
@kargaroc386 Жыл бұрын
oh my god its like watching alternate realities play out at the same time this is wonderful
@negative1723
@negative1723 Жыл бұрын
very well done. there are some edge cases. 1) the 3 reversals. if you eat an energizer just before a reversal, the ghost will turn in the opposite direction briefly, so that changes their behavior 2) grouping, when the ghosts are grouped together, they all act as one i think. however, most of the time, they are either coming up on an energizer when you eat them, or are very close depending on how many you have, usually 3, and sometimes all 4 together 3) eating multiple energizers causing them to reverse multiple times. other than that, great job. later || ||| | | || | ne gative1
@fluffydestroyer8336
@fluffydestroyer8336 Жыл бұрын
reminds me of the old maze pathfinding mechanics in roller coaster tycoon, you could build a maze that's just a straight line forward but every tile of the maze has a dead end to one side. because of the guests' bias in choosing that direction they almost always got stuck, even though the exit is in plain view. this has been fixed in later versions of openrct2 though
@AgentM124
@AgentM124 Жыл бұрын
I really love the probability simulation and the vs. actual measured simulation.
@HBMmaster
@HBMmaster Жыл бұрын
finally! a use for math
@andrewpinedo1883
@andrewpinedo1883 4 ай бұрын
Didn't expect to see you here.
@FlutterSprite
@FlutterSprite 9 ай бұрын
The hardest part of calculating that Markov chain is that if you lay all the vertices on the board like that, Pac-Man will start eating them before you're done figuring it out
@johnwest6690
@johnwest6690 Жыл бұрын
I wish you would explain more about the assembly code and programming, explaining what some of the things mean and what they do. I know it's not super practical, but a lot of people don't know how ASM works and it can be very confusing. I was able to understand the main point in this video thanks to the helpful illustrations, but there was a lot of terminology and concepts I didn't get. Seems like I'm the only one who doesn't have the ability to flawlessly understand everything however, since I don't see any other comments talking about this.
@The23rdGamer
@The23rdGamer Жыл бұрын
Happy to see another PacMan video from you :)
@vulcan6460
@vulcan6460 Жыл бұрын
So frightened ghosts almost act like Clyde. That makes way too much sense for a behavior that was never intended.
@AstonsVintageTechnologyWorkshp
@AstonsVintageTechnologyWorkshp Жыл бұрын
It's incredible considering the limited amount of code space Toru Iwatani had to work with in the first place, and yet came up with such a fantastic game with such intelligent programming for even such a simple thing as a frightened ghost. Imagine how optimised current modern computer games would be if such intelligence was used program them. 😀 Thank you for this very detailed explanation.
@hellishbro
@hellishbro Жыл бұрын
FINALLY the third installment in the series. remember watching these 2 years ago lol
@davidhand9721
@davidhand9721 Жыл бұрын
I love this stuff. Crawling through disassembly of my favorite old games is one of my favorite things to do. I can give you a _very_ thorough rundown of several SNES RNGs :)
@MondinoHTT
@MondinoHTT Жыл бұрын
I would have never thought a video about a retro game RNG could be so deep and interesting
@andriypredmyrskyy7791
@andriypredmyrskyy7791 Жыл бұрын
Can't wait to look up that ergodic fact :D
@MK-dr7dx
@MK-dr7dx Жыл бұрын
Even if the information has no practical application, it's fun seeing how the game works under the hood. And hey, you taught me what a Markov chain is, which is pretty neat.
@ashaweshome
@ashaweshome Жыл бұрын
this completes the pacman mechanic trilogy
@a26lolhart
@a26lolhart Жыл бұрын
I'm guessing the 50/50 thing is just to split it more evenly based on the ghosts starting inbetween 2 tiles
@andrewwebb917
@andrewwebb917 Жыл бұрын
These videos are always interesting and well made!
@meatpockets
@meatpockets Жыл бұрын
Man this must have taken a ton of quarters to figure out 😀
@henrybyrd8381
@henrybyrd8381 Жыл бұрын
I thought that when the ghosts were frightened, they ran the same algorithm they use for regular movement, then went the opposite direction.
@WereDictionary
@WereDictionary 9 күн бұрын
The root cause for the bottom left bias is that this is Clyde's corner and as we saw in the previous video, Clyde kinda just does his own thing. The Pacman isnt real to him and cant hurt him and the other, frightened ghosts seek out his guidance so they go to his corner of the map.
@Tera_GX
@Tera_GX Жыл бұрын
I love your visuals so much! You have so much skill in this!
@orbrat212
@orbrat212 Жыл бұрын
ohhhh im a little ghost and im so scared of the yellow circle man ooooh
@randy7894
@randy7894 Жыл бұрын
Incredibly fascinating. Thanks again for your polished infotainment on old school hard and software.
@YEWCHENGYINMoe
@YEWCHENGYINMoe Жыл бұрын
8:13 "genreator" nice.
@michaeljones890
@michaeljones890 Жыл бұрын
Now all you need to do is determine a heat map of the most likely locations of the ghosts at the moment Pac-Man eats a power pellet (determined from the ghosts’ behaviours and all the different ways the player can approach that power pellet), and use that as (for lack of better terminology) the weighted starting points for the frightened ghosts. Then determine the heat map for the frightened ghost locations over the duration for which they are frightened. Then do this for all the power pellets, take the average, and you’ve got the actual in-game most likely locations for the frightened ghosts!
Random Elements of Ms. Pac-Man
20:59
Retro Game Mechanics Explained
Рет қаралды 84 М.
Pac-Man Ghost AI Explained
19:34
Retro Game Mechanics Explained
Рет қаралды 1,4 МЛН
Из какого города смотришь? 😃
00:34
МЯТНАЯ ФАНТА
Рет қаралды 2,5 МЛН
МЕНЯ УКУСИЛ ПАУК #shorts
00:23
Паша Осадчий
Рет қаралды 5 МЛН
Thank you Santa
00:13
Nadir Show
Рет қаралды 29 МЛН
Data Redundancy Errors Explained
22:42
Retro Game Mechanics Explained
Рет қаралды 278 М.
MissingNo.'s Glitchy Appearance Explained
21:20
Retro Game Mechanics Explained
Рет қаралды 1 МЛН
Trying this Pac-Man game that went viral (kinda)
4:11
Athlonracer 1226
Рет қаралды 14 М.
The Arcade Game that Crashes Itself for Anti-Piracy Reasons
29:57
Retro Game Mechanics Explained
Рет қаралды 361 М.
Why Stomping Wigglers Glitches Super Mario World
20:48
Retro Game Mechanics Explained
Рет қаралды 373 М.
Exploring Glitch Level Pointers In Super Mario Bros.
15:19
Retro Game Mechanics Explained
Рет қаралды 182 М.
Why were Inky and Sue's AI not updated for Ms. Pac-Man?
15:10
Retro Game Mechanics Explained
Рет қаралды 70 М.
SMB3 Roulette & Card Matching Games Explained
20:02
Retro Game Mechanics Explained
Рет қаралды 379 М.
Fixing Glitch Pokémon Sprites
14:17
Retro Game Mechanics Explained
Рет қаралды 338 М.
I Made Pac-Man with just Redstone!
29:54
mattbatwings
Рет қаралды 550 М.