3 ms·
Show HN: MazeBall [not mobile friendly; sorry]
A colleague provided a maze-solving challenge that I reduced to a game that can be played at the following link:
https://ryan-duve.github.io/mazeball.html
The challenge is to find the shortest sequence of moves to get all the red balls to the green square, as well as an algorithm to generate that sequence. I made the game to guide my intuition and solved it in 188 moves just by eyeballing[1], but I am confident there are considerable gains to be made.
Warning: Javascript is not my primary language, and I have no idea how to make a good webapp. As a result, this is hugely unoptimized and probably unplayable on mobile despite my best Stack Overflow efforts and timeboxing the whole thing to this afternoon. If Javascript is your cup of tea and you are interested in helping improve this, drop me a message on Github[2].
Take a look, have fun and let me know if you come up with a cool solution.
[1] [see comment for long link]
[2] https://github.com/ryan-duve/maze_ball
- ryan-duve 6y agoThe long link to the provided solution is below. Putting it in the body of the post made the post body go really far off the edge of the screen. https://ryan-duve.github.io/mazeball.html?solution=RRDDLDDDDLLLLLLUUUUUURRRUUUUUUUUUUUUUUUUUUUUUUUUUUUURRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRDDDDDDDDDDDLLLLLLLLLLDDDDDDDDDDDDDRRRRRRRRRRDRUUUUUUUUUURRRRRRRRRRRRRRRRRRRRRRRRLLLLLDDRRRDDDDDDLLLUUU https://ryan-duve.github.io/mazeball.html?solution=RRDDLDDDD...
- gus_massa 6y ago265 https://ryan-duve.github.io/mazeball.html?solution=DDDRRLDDLLLLLLLUUUUUULLLURRRUUURRRRRRRRRRRRDDDDDDDDDDDDDRRRRRRRRRRDDDRRRRRRRRRDLLLLLLLLLLDDDDDDDDDDDDDDRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRUUUUUUULLLUURRRRRRRDDDDDDDDDDDDDLLLLLLLLLLLRDDRRRRRRRRRRRRRRRRUUUUDRRRRRUUUUUUURRRRRRRRRRRRRRRRRRRDDLUULLLLLDDLLLDDDDDDRRRRLUUU https://ryan-duve.github.io/mazeball.html?solution=DDDRRLDDL... It's not clear that initially all the grey squares have balls. Some feature request: * Add a button to restart, specially after the game ended. Perhaps save the best score in case people keep playing. * Add an undo button?
- ryan-duve 6y agoThanks for your feedback. Yea, I don't know how to make it more obvious the red squares are balls at the beginning. Let me know if you have any CSS/design chops here and can suggest an implementation. I added the restart button and high score saving. The undo is going to require significant rework since instead of just updating ball positions I would have to track history. I will consider it if I rewrite the game for performance reasons.