Hey guys this is how I made my clone of pacman Check out the source code at github.com/Cod... It would be awesome if you could join me on Patreon / codebullet I hope you enjoy
You are a genius and I respect you highly. Dare I ask if you could do an ai for lunar lander or centipede sometime in the future? I'd be very interested in how someone would program that and I know you can do it
Looks like you could use a parent class for the ghosts... Does Processing support inheritance? It looks very c++-like... But I haven't heard of it before (and haven't done my homework on it). This would prevent the copy/pasting of general features.
Have you seen the Berkely AI materials on pacman? They have the framework for pacman in python on their website. I used the code to make hellish AI for the ghosts. I used A* and make the two ghosts always try to get on opposite sides of Pacman, fun times.
@dzjad I've tried to set up a parent class for it in that code but either Processing or Java just has some severe limitations that make it a real headache to do it. Children appear to use the Parent's values when it runs the Parent's code, regardless of what you set the same variables in the Child to, so you have to have a bunch of Abstracts and/or external code to set these values ( external from the Parent and the Child) anyway which makes having a Parent class largely pointless unless you migrate most of the code such as the pathfinding, node finding, movement, and other things, to their own classes and run the code per Child class, but that would basically require completely recoding the entire thing and that's well beyond my skill level.
A* is a pretty light algorithm for this few of objects pathfinding, though, so I wouldn't doubt it couldn't run on the hardware of the time. To top it off, the size of the code is still under 256KBs (despite nearly reaching it) which means it could also fit in the memory of the hardware at the time as well though it would be missing sounds, music, and most of the graphics, as well as the title, the score screen, and level progression, plus you also have to have the entirety of Java with this so... If you were to include all of that it might make it a bit too big for the time (Multiple sources of memory wasn't uncommon for MAME cabinets, but it definitely made it a lot more expensive and there usually was never more than 1MB of RAM if it even got that high) As I was looking through the code, it did seem a bit over-engineered to me TBH.
A few details not covered in this video, for those who are curious: 1. At the two tunnel entrances just above the ghost house and the two entrances on either side of Pac-Man's starting location, the ghosts are unable to make upward turns (except in Frightened mode). This makes for some handy safe zones if the ghosts are concentrated below you. 2. After a certain number of dots are eaten on each level, Blinky enters a state known as "Cruise Elroy" (though where the name came from remains a mystery to this day), where two things happen: Blinky speeds up to nearly the same speed as Pac-Man, and he no longer targets his respective corner during Scatter Mode. When a second dot threshold is reached, Blinky speeds up yet again, to the point where he's visibly faster than Pac-Man. 3. Because collision in this game is tile-based instead of sprite-based, there's a rare phenomenon where Pac-Man can pass through a ghost unharmed, due to Pac-Man and the ghost changing tiles on the exact same frame. Certainly a good start, in any event!
Yeah, and also, because of the exact same tile collision philosophy, ghosts naturally make turns perfectly because they're AI where Pac-Man (the player) can't. To solve this, the devs gave Pac-Man a bigger turn window. Therefore, Pac-Man turns faster than the ghosts. Useful to make some space from Blinky.
I just stumbled on several of your videos today and you have earned the ability to send my phone notifications. Thanks for being one of the rare few deserving such.
A couple of years ago, I recreated Pac-man in C++ for my intro to computer science class. I remember researching the ghost behaviors in-depth, and it was immensely satisfying to see that you gave them (nearly) the same behaviors that I did.
scoutiano Dude, I wasn't being serious... ";-)" means "joke" Iwatani and his team are legends. The AI pathing behaviour and gameplay replicated here is such great optimisation that we're talking about it decades later and you don't get that without investing a huge amount of work. It was a bit of humour with the aim of delivering a compliment; a week is damn fast.
Pretty good, but there are some minor differences from the arcade game. These are detailed in The Pac-Man Dossier (which several people have already linked to), and I presume you used as reference (because it's awesome, and what you *have* done is pretty good): 1. There are four routes in the maze that are "one way" to the ghosts, that they can go down but can't go up. They are the two vertical routes directly above Pac-Man's start location, and directly above the monster box. In play, these are useful for escaping pursuit. 2. Ghosts slow down in the tunnels. 3. This is a big one... there's actually a significant pathfinding bug in the arcade game that affects Pinky and Inky whenever Pac-Man faces north, that tends to cause them to cause them to home in on the wrong location, one to Pac-Man's left. It's fully detailed in the Pac-Man Dossier, but one result of it and the one-way routes is the infamous "safe spot," the area just right-and-up from the starting location that the ghosts' pathfinding often breaks down when they try to reach it when Pac-Man is facing up. 4. Finally, the ghosts aren't entirely random when vulnerable, but pick routes deterministically based, among other things, on reads from random memory locations. This has the weird side-effect of making it likely impossible to fully implement Pac-Man's AI without a full copy of the game's ROMs, although it's a really minor point ultimately unless you want to perfectly recreate the arcade game.
I like how the writing is so casual. Honestly! People always think that when regarding computers and coding you have to take it seriously. It’s so refreshing to find someone that speaks my language. I don’t wanna sound pretentious, but I have a fair share of knowledge about computers myself. Not about software however, more about hardware. I really enjoy learning the inner workings of AI and seeing it evolve. That combined with another person who does this stuff for fun, it’s a dream come true! Thanks for standing out.
Oh damn it's nice to see your channel getting bigger. You deserve it. For all the work you're doing for it. I subscribed on the last video, if you're interested in hearing. It's wonderful both seeing a new channel get this fast of a start, and having one more channel doing AI stuff. And. Something in your style just seems so enjoyable.
Super cool and really impressive. Butt... Pac man does slow down while eating dots and is able to outrun the ghost if there are no dots in front of him. But otherwise thumbs up.
Pac-man also turns corners faster and we don't know if he implimented Blinky's speed increase or the looping from the sides. He also did a fixed version where it doesn't have the error where if Pac-man looks up, Pinky and Inky's target moves four tiles to the left
Im fascinated by how the ghosts present a big challenge for the player being so different and yet unnoticeable at first glance. Blinky being the perpetual hunter, Pinky the flanking stalker, Inky the jack of many trades and Clyde's only function is to fright you into misplays.
Awesome video! I spent DAYS trying to recreate Pacman in excel VBA and never figured it out. I was trying to implement dijkstra's algorithm for the ghost AI and it failed horribly, I never knew about A*. (Plus, using excel VBA to code certainly didn't make things easier). Thank you for the great information and posting the source code! Your videos provide great inspiration to learn more about coding, keep up the excellent work!!
"The red and orange ghosts are in the same position. And also since they have the same behavior (always following pacman) they will remain together forever" Well done captain obvious.
I love you so much youve no idea??? U better be single bro. Nah jk. Like srsly thank you for creating these kind of videos ive always been so interested in codes n stuffs but im noob at them. Seeing them come alive makes me day. Tytytyty
Jorge C. M. Sincere apology to you sir. When I feel extremely geniune towards someone I tend to be very informal, moreover, I would ignore the rules of expressing my message created by an old bearded man who named it "English" with a sub-category "grammar", and expresses them truly in my own way. From the bottom of my heart, I hope you spare this poor mankind you call a grammer jews.
The RU-vid algorithm picked up on it. One of his videos recently went pretty viral, so the algorithm picked it up and helped him grow. I'm guessing it was his snake video.
I like Clyde. This and his appearance in Wreck-it Ralph actually gives some context to his actions. He doesn't want to be the bad guy, but it's the role he's been given.
You basically recreated the game pacman with bots. Great job! 1 thing dough, blinky(red ghost ) is faster than the other ghost and than the player himself. Still , great job!
And.. By the way... You should try to recreate tetris and teach bots to play it , from generation to generation , until they play like the grandmasters. Just a sugestion .
No, he isn't. He moves at the same speed as the other ghosts unless in 'Cruise Elroy' mode, which occurs when the number of remaining dots is below a certain number (which, itself, is dependent on the level).
Actually, it isn't. It starts moving at the same speed as the player when 20 dots are remaining, and moves faster than the player when 10 dots are remaining. He also keep chasing the player while in scatter mode (scattering, but still chasing the player if possible). Killing him will remove that ability from him.
Like I said before, the number of dots remaining is dependent on the level. Also, Cruise Elroy speed boosts are 'normal ghost speed + 5%' for the first boost and 'normal ghost speed + 10%' for the second one. It just happens to be the case that the first speed boost makes Blinky the same speed as Pacman on the first 20 levels, but not from level 21 onwards...
Your implementation of the ghost AI is wrong. The red ghost is meant to go directly to Pacman, the blue and pink ghosts try to block your path, and the orange ghost just generates a path using the current RNG value.
Did you watch the full video? He added the specific ambush patterns present in Inky and Pinky and gave Clyde his fickle nature (which is less random than most people believe, it's a specific method he uses that gives his ghost an indecisive chasing pattern that looks rather random).
Clyde's movement is based on his "scatter mode" position and pacman's position. During scatter mode all ghosts will return to a specific corner of the map, however Clyde goes back to this as soon as he is within 8 tiles of pacman and goes towards pacman like blinky when 8 or more blocks away.
No, don't use A*. The ghosts have a very specific algorithm for greedily minimising distance out of a maximum of three directions to turn. Also, pinky won't target four tiles in front of pacman when he's looking upwards, there's an error with vector addition which makes her target four tiles up and to the side
Don't know if this has been mentioned already, but due to a number overflow, Pinky actually targets the square four spaces up AND four spaces to the left whenever Pac-Man is facing up. When facing the other three directions, Pinky targets as indicated in this video.
Really fantastic video, I would just like to add in that you forgot the level creation system. Pac-Man has a color palette and a sprite/audio sheet where it gets text, walls, ghosts, etc... The sprite sheet is why the glitched level exists because of the maximum number the machine can handle. Also the short cut scenes in between levels are missing, would like to see a complete version of the game.
originally all of these ghosts had diffrent AIs for example the Orange one alway turns if he is able to catch pacman and I am not sure who but one of them can only turn left. But I still think this is a nice work and interesting video!! I am exiced for the next part ;")
There’s also a thing where ghosts can’t turn in the spaces where pac man spawns or in front of the ghost house. Also pinky’s target is up 4 and left 4 when pac man faces up. And the targeting systems are mostly the same as the original, except for a small detail that in the og, the ghosts move to the adjacent space closest tot he target, not along the shortest path. Even though it isn’t an exact copy of the og, it works pretty similarly and it’s really good.