17 ms·
Accurate remake of Pac-Man in JavaScript
- gpcz 14y agoThe remakes look really good -- good job! Does the original Pac-Man remake use the same AI behavior as the original arcade version? I ask because I tried using the "safe spot" trick (src: http://strategywiki.org/wiki/Pac-Man/Tips#The_safe_spot http://strategywiki.org/wiki/Pac-Man/Tips#The_safe_spot ) and the red ghost caught me every time.
- bjornsteffanson 14y agoIt looks like there was an attempt to copy at least some of the original AI behavior. If you click on the "Learn" tab, you can choose which ghost to play and visually see their AI objectives via a little node that travels infront of the ghost's body. As you probably know, each ghost had their own AI objective and behavior in the original arcade Pac-Man. While their movement's appeared random, they were actually not, and you could exploit each ghost's "weakness" to win.
- ChrisNorstrom 14y agoI could of swore in the original Pacman the blue ghost will flee when confronted and there's a path for him to escape into.. Which would explain "Bashful"s name (and Japanese name which translates to Fickle).
- akldfgj 14y agoOnly if red Shadow is behind pac-man. Bashful targets the location (pacman + (pacman - shadow))
- jrockway 14y agoIt didn't seem to work. I'm not a Pac-Man expert, but the ghost behavior didn't feel the same to me here as it does on an emulated version of the original. (I liked the speed though, Pac-Man is too slow.)
- sixothree 14y agoThe hiding spot doesn't work, so there is definitely something amiss with the behavior. Still very fun.
- mmahemoff 14y agoThe AI's out there apparently. I've heard Marcin Wichary, explain that he reproduced the AI in JavaScript when he built the Google doodle. I think it's in this video: http://www.youtube.com/watch?v=ttavBa4giPc http://www.youtube.com/watch?v=ttavBa4giPc
- codehotter 14y agoThe safe spot works for me. The safe spot exploits the fact that ghosts are not allowed to turn upwards in the corridor immediately below the safe spot [1]. That behavior was accurately emulated in this version. Make sure the red ghost passes below your safe spot from right to left. It wants to turn upwards, but it is not allowed to, so it has to keep going. It then circles around back in a T shape. Make sure you are facing upwards, so that the blue ghost circles the center of the maze. Finally, be mindful of the scatter phases [2]. A scatter phase will bring the red ghost out of his loop, so you need to lure him back into it. After the final scatter phase you can stay in the safe spot indefinitely. [1] http://home.comcast.net/~jpittman2/pacman/pacmandossier.html#CH2_Areas_To_Exploit http://home.comcast.net/~jpittman2/pacman/pacmandossier.html... [2] http://home.comcast.net/~jpittman2/pacman/pacmandossier.html#CH2_Scatter_Chase_Repeat http://home.comcast.net/~jpittman2/pacman/pacmandossier.html...
- undershirt 14y agoI've been receiving complaints about this from multiple people. To my knowledge, the safe spot only works because the ghosts can't go up from the passage below it. It's hard to isolate this bug unless I get a play-by-play or video to compare with the original.
- undershirt 14y agoI've uploaded a fix, so it's working now. Thanks for the feedback.
- emehrkay 14y agoWorks on the iPad and works well
- kd5bjo 14y agoThank you for making the controls work right. Most remakes I've seen won't register a turn if you press the button early, which makes it almost impossible to play at higher speeds.
- SeanDav 14y agoNicely done. I presume there is no sound? I have also seen this done in an Excel spreadsheet with very realistic game-play and sound.
- rkaplan 14y agoLooks very nice. My only complaint is that all the JavaScript code is in one file, which makes it a bit harder to casually peruse (I was curious how you implemented the ghosts' AI).
- cocoflunchy 14y agoYou can see the whole source here : https://github.com/shaunew/Pac-Man/tree/gh-pages/src https://github.com/shaunew/Pac-Man/tree/gh-pages/src I wonder how he compiles these files into one though ? THis is the main drawback of javascript to me at the moment : having to write everything in one big file.
- prophetjohn 14y agoLooking at the code, I'm pretty sure the contents of each file is just dropped into an IIFE. A pretty simple Ruby script would take care of this.
- akldfgj 14y agoofficial ghost AI: http://home.comcast.net/~jpittman2/pacman/pacmandossier.html http://home.comcast.net/~jpittman2/pacman/pacmandossier.html
- madmikey 14y agohow abt porting it android? using trigger.io!! i guess it would be super cool.
- undershirt 14y agoThe firefox beta on android runs the game really well.
- anonova 14y agoAccurate enough to also include the level 256 bug? http://en.wikipedia.org/wiki/Pac-Man#Split-screen http://en.wikipedia.org/wiki/Pac-Man#Split-screen
- accarrino 14y ago@anonova that's what i was thinking!!! i skimmed the code but couldnt tell if they included the infamous "kill screen" bug. i was never good enough to ever reach that level in the original arcade version, but my best friend's older brother was: Pac-Man’s Kill Screen – Level 256 [video] http://www.methodshop.com/2012/08/pacman-kill-screen.shtml http://www.methodshop.com/2012/08/pacman-kill-screen.shtml
- sunjain 14y agoVery impressive!
- DonnyV 14y agoWorks nice on my Nexus7
- Timothee 14y agoUncompiled source code is available here: https://github.com/shaunew/Pac-Man/ https://github.com/shaunew/Pac-Man/
- modarts 14y agoThe term "source code" implies that no compilation has occurred /nit
- Timothee 14y agoI'll nitpick right back at you: since JavaScript is not compiled in the software sense, I could only mean compile in the sense of "produce (something, esp. a list, report, or book) by assembling information collected from other sources: the local authority must compile a list of taxpayers." ;-)
- CognitiveLens 14y agoIs it therefore accurate to say that the uncompiled source code is compiled in https://github.com/shaunew/Pac-Man/ https://github.com/shaunew/Pac-Man/?
- Timothee 14y agoTouché. I guess so :)
- iamwil 14y agoI like how the learn mode lets you see the AI algorithms and the practice mode lets you rewind. It's like Braid for PacMan. Pretty fun. It'd be interesting to play as the ghosts and see if you can write simple algorithms for a ghost team to capture pacman.
- city41 14y agoExcellent, I like it. Coincidentally I just read the Pac-Man dossier this morning[0]. An excellent resource on how the AI and overall game works. Might be a good way to get the AI a bit more accurate. [0]http://home.comcast.net/~jpittman2/pacman/pacmandossier.html http://home.comcast.net/~jpittman2/pacman/pacmandossier.html
- Jach 14y agohttp://news.ycombinator.com/item?id=4431197 http://news.ycombinator.com/item?id=4431197 Double standard, HN? At least qxcv sees the light: "It's one thing to make a Pac-Man-like game. But this is being called the trademarked name Pac-Man, and you've copied the artwork straight from Pac-Man. Seems certain this isn't an official licensed version. In which case, you should change all those items immediately. It's illegal and it's just not cool. Here are the guys you are ripping off. Tōru Iwatani and his friends at Namco. Tōru is a very nice guy: http://pacmanmuseum.com/history/Toru-Iwatani.php http://pacmanmuseum.com/history/Toru-Iwatani.php "
- arn 14y agoThis is illegal too. I didn't bother posting again because it seems more obvious. In the previous example, many probably didn't know it wasn't an official port. (author added disclaimers later)
- tylerneylon 14y agoIs it morally wrong that this was created? I appreciate that this exists, and personally am more likely to purchase or promote official Pac-Man products because of it. I think it's a good thing. Legality is important, but underneath that is the purpose of law itself. I like the idea of keeping in mind both legality and the intent of the law. If you are making something cool, that adds value (including entertainment), and does not pretend to be, or detract from those you borrow ideas from, it seems ok to me. You may disagree with my particular idea of fair use - the main point is to promote thought about general morality, and not just condemn on the basis of legality alone.
- arn 14y agoSo I presume that the person who made this knows it's "illegal" to use the pacman name and doesn't care. So that's fine, its not like I am not going to report him to whoever owns the ip. The previous example, a) it wasn't clear that the author knew it was not right b) the people affected where the type of people who would post to HN. Let me ask you this, do you see anything wrong with someone creating a hipmunk clone called "hipmunk.co" and use their exact CSS and HTML? It's the same situation. If you see nothing wrong with that, then that's where we disagree. Edit: there's no reason why he can't provide entertainment and value but just name it something else, and use original graphics. To clarify: no one is arguing against the creation of a game that plays the same. The argument is using the exact name and artwork.
- pgambling 14y agoThe creator of this remake gave a talk on it at the houston.js meetup this week. I was thoroughly impressed with how much effort and thought he's put into this project. He said that the Pac-Man dossier was his inspiration and seems to genuinely love the game. For those of you who have criticisms about the game's accuracy, I suggest that you submit a new issue to his github repo: https://github.com/shaunew/Pac-Man/issues https://github.com/shaunew/Pac-Man/issues. That's what open source is all about, right?
- salvadors 14y agoNo — open source is about you being able to take the code and do pretty much whatever you want with it. Being able to report issues is entirely orthogonal to that. Lots of non-open source projects accept such reports, and releasing something as open source does not carry any implicit promise that the author will pay any attention to such reports.
- arasmussen 14y agoThis is awesome, but he should support WASD too.
- daigoba66 14y agoI'm impressed with how well it works with touch input.
- Evbn 14y agoMenus broken on galaxy nexus of touch Browser. When I tap on a menu item, the tap registers twice, including whatever occupies the same position on the next menu. Example: Quit - No, which loops back to the game. Also, Credits.
- undershirt 14y agoThanks, I'll add a delay to prevent that.
- undershirt 14y agoThanks for the detailed bug report. I resolved the issue by adding a 200ms delay after a button press.
- wilfra 14y agoSpeed it up please. The arcade version is much faster. This is plays really slow. I think the pac man should move at least 25% faster.
- undershirt 14y agoI've compared the speeds, and they're accurate. If you're talking about the fast mode in some arcade machines, you can try "play turbo" which emulates that.
- heykoo 14y agoHaving recently watched King of Kong (http://www.imdb.com/title/tt0923752/ http://www.imdb.com/title/tt0923752/) I highly doubt the accuracy of these "remakes".
- heykoo 14y agoI probably phrased this incorrectly, hence the downvotes. These arcade machines have specific timers, odd hardware characteristics, hard memory limits, etc, that are likely impossible to replicate in software accurately - in addition to the software algorythms they use. In king of kong, you will hear how a blob of solder in the right location will change the characteristics of the game to invalidate the entry for world record status. Simply looking at the framerate counter at the bottom you can see that this isn't in any way "accurate". By looking at the github repo, you can even see the author has written about some of the inaccuracies - timing, collision detection, randomization, and bugs.
- undershirt 14y agoHi, I'm the author. The framerate you see at the bottom right corner only indicates how often it is drawn. The game loop is actually sophisticated enough to keep the game updating at a solid 60Hz like the original, so the speeds are accurate because of that. I feel like I hammered out the most of the critical inaccuracies, and I left out the original bugs because I found it preferable.
- heykoo 14y agoYou've done a great job, and I am in no way intending to be critical. My only concern was the claim of accuracy. It is an outstanding simulation of the original, and I commend you for your work on it. However, leaving out the bugs, for example, makes it not accurate. As for the timer, I don't see how you could guarantee the frequency in a javascript VM. It could be similar (by continually testing how inaccurate it is and adjusting the frequency of subsequent iterations), granted, but this is not accuracy (it is emulation). As for memory, etc, many of these older games had "death screens" where a buffer overflows and simple crashes the game, preventing you from continuing past a certain point - that too would be very difficult to accurately model in javascript. The list could go on and on. And this is in no way critical of you, or what you have done - it is simply statement of fact about accuracy! As an aside, Billy Mitchell (the first person to ever get a perfect pacman score) was one of the stars in the movie The King of Kong. Again, I think what you have done is AWESOME. But it is not accurate (and likely could not be). Urghhh... I wish i'd never posted anything now :(
- chinchang 14y agoWhat a marvelous piece of work done in explaining different aspects of the game, specially the level generation. And awesome remake :D Also its really helpful for game programmers to learn from.