Here, I found it fun to write a small bot to play automatically. Just paste this JS code in the dev console. It reached 9000 points on my first attempt to let it run. Feel free to tweak the code to make pac-man survive longer :-)<p><pre><code> function bot() {
/* direction of the enemy: to our right (1) or to our left (-1) */
dir = (enemy.x > player.x) ? 1 : -1;
/* if pac-man... */
if (
/* ...has no powerup or powerup expires in less than 10 "ticks" */ powerTicks < 10 &&
/* ...is headed toward enemy */ player.vx == dir &&
/* ...is too close to enemy */ abs(player.x - enemy.x) < 25 &&
/* and if enemy's state is not "eyes flying back" */ enemy.eyeVx == 0
) {
// "ArrowUp" or any arrow key reverses the direction of pac-man
document.dispatchEvent(new KeyboardEvent('keydown', {code: 'ArrowUp'}));
document.dispatchEvent(new KeyboardEvent('keyup', {code: 'ArrowUp'}));
}
}
setInterval(bot, 100);
</code></pre>
The strategy is ultra simple. Every 100 ms it evaluates the situation and chooses to move away from the enemy (ghost) if it's too close to it, and has no powerup (or if the powerup is expiring very soon).<p>The corner cases where pac-man dies is the game difficulty progressively increases (the ghost becomes faster) until you eat it, so sometimes some pellets are left in the middle and pac-man doesn't have enough time to eat them until the ghost reaches it. The ghost will progressively get faster and faster and death is guaranteed. You could improve the code by tempting the ghost to get close to one edge, then cross over to the other edge and quickly eat the middle pellets.<p>Also, as soon as new pellets are added, one should prioritize eating the middle pellets.<p>Also, one could add code to detect the powerup pellets, and chose to NOT move away from the ghost if it calculates it can eat the powerup pellet before the ghost reaches pac-man.
Nice game! I managed to 6,600 points<p>Per my experience The optimal strategy is to deprioritize eating the ghost. You can get some nice streaks sometimes eating him but it generally doesn’t help.<p>What you want to do is use the power up to collect the middle dots. The sides you can collect safely on reflexes alone. By about 3000 points it becomes impossible to recover if you don’t pick up the middle and have consumed your power up. Eating the ghost is ok if it happens incidentally.<p>Because you’re trying to use the power up to collect the middle that often means the ghost will be further from the middle than you when you finish a line. So finish a line, then 180 immediately to collect the middle again. The worst case is you end up with your power up ending just as you’re finishing a line and you are on the side. But up until very high point values I think it’s always safe to grab the power up as it tends to be on the sides.<p>Edit: 6800<p>Might play more if other HNers step up their game :)
The game's designer/developer, Kenta Cho[1], has made countless experimental games for decades.<p>I'd nearly forgotten about his work until I saw this post, and I'm very happy to see that he hasn't stopped with experimental game design after all these years, and I have a huge backlog of games to play[2].<p>[1] <a href="https://en.wikipedia.org/wiki/ABA_Games" rel="nofollow">https://en.wikipedia.org/wiki/ABA_Games</a><p>[2] <a href="http://www.asahi-net.or.jp/~cs8k-cyu/index.html" rel="nofollow">http://www.asahi-net.or.jp/~cs8k-cyu/index.html</a>
Wow, that's fun. I wish I could articulate why the music and dying sound effect are both so great. The gameplay has a great rhythmic feeling to it. It's also really tense. I scream every time that damn ghost catches me.<p>The best part is when I die I feel like I made a dumb mistake, and that if I improved just a few things I could be way better.<p>Too many games these days give you the allure of depth and complexity by making things difficult in the wrong ways.
The developer of this game is Kenta Cho. He's been making games like this for 20+ years.<p>In 2021 he used his Crisp Game Lib to create 111 one button games! That's one every ~3 days.<p>For me, he's the greatest active game designer in the world today.
That's more fun than I expected it to be! I like all the little subtle choices - how the ghost respawns, the speed of the ghost vs pac-man, the time it takes for the ghost to flash. It's simple, but I could feel myself learning the timing as I played and working through the strategy, such as it was.
Another interesting thing by the same person that got pretty popular on HN:<p>The Joys of Small Game Development
<a href="https://news.ycombinator.com/item?id=37799387">https://news.ycombinator.com/item?id=37799387</a>
<a href="https://en.wikipedia.org/wiki/ABA_Games" rel="nofollow">https://en.wikipedia.org/wiki/ABA_Games</a><p>Oh, I had completely forgotten about aba games (the work of Kenta Cho) for some years until seeing this HN post! He has been making little mini-games and posting them on his site (both browser-based and windows-based) for more than 20 years now.<p>Here's his games (I always liked Torus Trooper):
<a href="https://www.asahi-net.or.jp/~cs8k-cyu/index.html" rel="nofollow">https://www.asahi-net.or.jp/~cs8k-cyu/index.html</a>
People who liked 1D Pac-Man also liked Wolfenstein 1-D<p><a href="https://en.wikipedia.org/wiki/Wolfenstein_1-D" rel="nofollow">https://en.wikipedia.org/wiki/Wolfenstein_1-D</a>
I don’t know if anyone else noticed, and I’m not sure whether this is intentional, or maybe the dev found it too hard to do well in browser-based games, but it seems like most of his games don’t sync the sound with actions happening in the game.<p>For example, in Pac Man, the dots chomping sound seems like it’s just a repeating sound that is toggled on and off, vs. actually syncing with the timing of chomping the dots.<p>Also, if you check out his other web-based games [1], you’ll notice the same thing — the actions (by tapping) cause a sound that is just repeated at a pre-set rhythm that doesn’t sync with when you tap.<p>It’s subtle, but can actually have an adverse affect on the performance of the game. I often use sound feedback as a way of timing, and when this doesn’t match what I’m doing, it can definitely throw me off my rhythm.<p>The Timber Test game [2] is a perfect example of this, particularly on the later levels where you need to cut the log into equal fractions, but the sound timing is always the same, making beeps in unequal intervals.<p>[1] <a href="https://www.asahi-net.or.jp/~cs8k-cyu/browser.html" rel="nofollow">https://www.asahi-net.or.jp/~cs8k-cyu/browser.html</a><p>[2] <a href="https://abagames.github.io/crisp-game-lib-11-games/?timbertest" rel="nofollow">https://abagames.github.io/crisp-game-lib-11-games/?timberte...</a>
Controls would be better if left arrow went left, and right arrow went right. As is, they both toggle, which can lead to wrong inputs when trying to stall (left/right in succession)
It was hard until I realized that the ghost doesn't change when you cross the edge of the screen. After that, it turned into an uninteresting stalemate.<p>The controls really need to be edited, though. Left should be exclusively left, and right exclusively right. Having them both toggle makes input the primary challenge.
This reminds me of the book Flatland which is about what a 2 dimensional universe would be like and the experience of a 3 dimensional entity visiting it. Great read! <a href="https://en.wikipedia.org/wiki/Flatland" rel="nofollow">https://en.wikipedia.org/wiki/Flatland</a>
Love it! I like seeing Pac-man put into strange scenarios.<p>I made a slightly similar (1.5d?) game for the CHIP-8. Pacman can only go left and right, but the ghosts fall from the sky.<p><a href="https://veganjay.itch.io/falling-ghosts" rel="nofollow">https://veganjay.itch.io/falling-ghosts</a>
Nice. Now do it on a Mobius band: there's a "ceiling" and "floor", and when you go out the left, you end up on the ceiling on the right, and vice versa. Two ghosts chasing you, one on the ceiling and one on the floor.
Should be named ·--· ·- -·- ··- ·--· ·- -·- ··- . ("Paku paku" in morse, though I changed the characters to be more obviously plausibly one dimensional themselves so your favorite converter may not work.)
I have been looking for 1D game ideas to implement on an addressable RGB LED strip. 1D pacman seems perfect, as it's instantly recognizable even with a single-pixel pacman and ghosts, by using the right colors.
Bugs…<p>Ghost spawns to never be on a player. It’s not fair.<p>The big dots should give X seconds of ghost eating ability, not just make the existing ghosts edible. That way new ghosts that spawn instantly after you eat a big dot wouldn’t hurt you.
See also Line Wobbler by Robin Baumgarten: <a href="https://www.youtube.com/watch?v=9dufXuWDjLU" rel="nofollow">https://www.youtube.com/watch?v=9dufXuWDjLU</a><p>1D dungeon crawler hardware game.
I reached over 110000 points by below code. We may can reach 50000 by average.
Basic strategy is that player turns lately as possible so that enemy can't catch with a distance in a bit. However, this strategy has extremely weak point, that is if yellow feed remains in the center of screen, player can't reach forever.<p>I'm not so interested in this game already.
But I think this can improve to close perfect, which player can infinitely escape from enemy, by considering "Offense" aspect, like player's invincible mode and enemy's escape mode.<p>function bot() {
dir = enemy.x > player.x ? 1 : -1;
const Xp = player.x;
const Xe = enemy.x;
const pvx = player.vx;
const escaping = (Xp < Xe && pvx < 0) || (Xp > Xe && pvx > 0);
const escD = Xp < Xe ? Xp : 100 - Xp;
const Vp = player.vx * 0.5 * difficulty;
const evx =
enemy.eyeVx !== 0
? enemy.eyeVx
: (player.x > enemy.x ? 1 : -1) * (powerTicks > 0 ? -1 : 1);
const Ve =
evx *
(powerTicks > 0 ? 0.25 : enemy.eyeVx !== 0 ? 0.75 : 0.55) *
difficulty;
const VRatio = abs(Ve / Vp) === 0.5 ? 1.1 : abs(Ve / Vp);
console.log(VRatio);
const minD = (VRatio - 1) * escD + 3 * (VRatio + 1) + difficulty;
const D = abs(Xp - Xe);
if (!escaping && D <= minD) {
document.dispatchEvent(new KeyboardEvent("keydown", { code: "ArrowUp" }));
document.dispatchEvent(new KeyboardEvent("keyup", { code: "ArrowUp" }));
}
}
setInterval(bot, 10);
Absolutely fantastic, please make a version for Playdate or gameboy DMG and put it on itch.io for $10-$100 so I can give you money for this case study in gameplay perfection.<p>It's so beautiful and inspiring that one lone coder can still make something with so much joy and playability in an era of multimillion dollar games that take the work of hundreds of people for years on end.<p>This is a tribute to humanity itself, well done.
In college I made a 1D space invaders game - but it ran on an Arduino (with one physical 'shoot' button) and was played on an 8foot RGB LED light strip. I had it mounted on a wall and I would catch students and professors playing it from time to time during the quarter. It was surprisingly fun.<p>This pac man game would be awesome to play on an LED strip as well!
It does not seem to work on my side. I get a blank canvas with 0 on top left and HI 0 on the top right. Everything else is blank.
In developer tools I've noticed that one of the GET on the main.js script is returning 404 so maybe that is the problem?
IMHO, needs an appropriate stack of single row of microfluidics display[0][1] instead of single crt row.<p>An appreciation of 'Alice in Wonderland' quantum decision making might help too.<p>----<p>[0] <a href="https://www.youtube.com/watch?v=ncfZWqPm7-4" rel="nofollow">https://www.youtube.com/watch?v=ncfZWqPm7-4</a><p>[1] <a href="https://pubs.rsc.org/en/content/articlelanding/2019/lc/c9lc00160c" rel="nofollow">https://pubs.rsc.org/en/content/articlelanding/2019/lc/c9lc0...</a>
Diving into mrb's 1D Pac-Man bot adventure is like stepping into a coder's dream, complete with a shareable JavaScript code that's ripe for tinkering. Along comes AnotherGoodName, who cleverly tweaks the code, turning a good run into an epic high-scoring saga by solving those tricky edge cases. mrb's reaction, a simple 'Of course! Nice.', captures the essence of community-driven coding - where one good idea sparks another, and everyone's game levels up!
Took me a while to realize that it treats a (potentially repeating) key press as the condition to turn around, which badly messes with you if you assume the game has direct control.
Artifcial constraints/trade-offs creating new unexpected properties.<p>Examples:<p>- up to 21 million Bitcoins limit - Artificial scarcity<p>- original 140 character limit for tweets, later expanded to 280, then removed for paid users<p>- up to 500 users per group in WeChat groupchat<p>- ip· o· gram. ˈlipəˌgram, ˈlī- : a writing composed of words not having a certain letter (as the Odyssey of Tryphiodorus which had no alpha in the first book, no beta in the second, and so on)<p>- wireframes vs realistic prototypes (low-fidelity vs high-fildelity)<p>- monochrome UI for smartphones to remove distractions<p>- feature phones vs smartphones<p>- 1D Pac-Man<p>- etc.
mrb's venture into the world of 1D Pac-Man with an auto-playing bot is a neat twist on a classic, complete with shared JavaScript code for all to tweak. Then AnotherGoodName steps in, tweaking the bot to dodge those pesky edge-case issues, skyrocketing the score into six digits. mrb's response to this upgrade? A cool 'Of course! Nice.' - a nod to the joys of collaborative coding and the magic that happens when minds meld over games and code.
Almost completely broken on Firefox 121/Mac OS. I was wondering what the fuss was about because it was just a mess. But threw it up on chrome, and looks completely different...<p>Also there is a weird latency thing if you hold the direction key down and then switch to the other direction.
Good game. I also played 3D Pacman in DOS in an IBM PS1, this was years before Wolfenstein and Doom. Today we have come full circle!<p><a href="https://m.youtube.com/watch?v=ajWIYW-wk6U" rel="nofollow">https://m.youtube.com/watch?v=ajWIYW-wk6U</a>
My 12 year old son spend today making this game in Scratch, creating the graphics with Lego:<p><a href="https://scratch.mit.edu/projects/946299317/" rel="nofollow">https://scratch.mit.edu/projects/946299317/</a>
I find playing this super ironic having just read this HN post about A* pathfinding tricks in video games <a href="https://news.ycombinator.com/item?id=38833658">https://news.ycombinator.com/item?id=38833658</a>
My 12 year old son remade this game today in Scratch using Lego:<p><a href="https://scratch.mit.edu/projects/946299317/" rel="nofollow">https://scratch.mit.edu/projects/946299317/</a>
I'm loving this thread about the 1D Pac-Man bot. mrb starts with a great concept and then AnotherGoodName comes in and boosts its performance. It's like a mini hackathon in here!
Found another small bug...<p>When you eat a ghost, the dots under the ghost don't get eaten. So you skip over 1-2 dots at higher levels when eating a ghost. Then you have to go back to snag them.
This is so fun! Makes me feel like I’m conducting a 1 dimensional random walk. Who knows, maybe this is being used to generate pseudo stock prices or something.
This was way more fun than it should be. Wonderful!
Reminds me of Linelight on Steam and my game Kanso, both have 1D game mechanics (but with 2D visuals).
not as "1D" as I'd imagined, but much more fun. I'm still toying with the idea of making a game that "renders" a 1D projection of a 2D space. (yes, I know, the line would be infinitely thin, I'll compromise on that by stretching it vertically so it's visible)
The evolution of mrb's Pac-Man bot through community input, especially AnotherGoodName's contribution, is a perfect example of the power of collective brainstorming in tech. It's like watching a good idea become great through teamwork!
Bruh, the ghost moves faster than you do! But this is a pretty cool idea, difficulty level spikes after the first screen though, especially if you waste the power pellet, then because the ghost moves as fast or faster it becomes impossible to goad it to either side enough that you can get the remaining pellets.
WONDERFUL.<p>It better be landscape only on mobile. Add a pitfall bomb (what was that game that created a hole for the critters to fall into, and you could walk over them, but the climb out and the hole heals in a short period... ? Let the ghosts to fall in a hole, then you can place more than one ghost on the path, but you need as many "hole bombs" as there are ghosts on screen+1 (or N)... to not make it rage quit-worthy.
mrb's journey into automating 1D Pac-Man turns a nostalgic game into a coder's playground, sharing their JavaScript bot that impressively scored 9,000 points on its maiden run. Enter AnotherGoodName, who amps up the game by fine-tuning the bot's edge strategy, blasting the score through the roof. mrb's reaction to this ingenious tweak? A simple yet appreciative 'Of course! Nice.', showcasing the spirit of collaboration and innovation in the programming community.