537 points · by gereleth · 4y ago · 161 comments
I'm rather fond of the pipes puzzle where your goal is to restore a scrambled network of connections by rotating tiles. It's usually played on a grid of squares and this all started when I decided to make a programmatic solver for that kind of puzzle. Then I realized that with some minor changes the solver could generate new puzzle instances. I thought about what kind of puzzle to make and someone suggested a hexagonal grid. Adapting the generator wasn't too hard but then I had to create a way to play this variant. So I did just that =).
I find hexagonal pipes a bit more difficult than the square variant because there's a larger variety of possible tile shapes. For an extra challenge I implemented wrap mode where the board can connect to itself (right to left and top to bottom), so there are no convenient outer walls to start from.
The site is made with Svelte Kit, its code is available on github at <https://github.com/gereleth/hexapipes>.
Hope you enjoy playing =).
Full disclosure: I’m CTO at Rune, but I genuinely think it might be fun and easy for you to do. Here’s a similar popular game on Rune: https://app.rune.ai/untangle-H-vghwxUfO
I humbly suggest that you flesh out the rules just a bit more. I struggled to figure out if pipes were allowed to run out of bounds, whether they all had to be connected into a single network, and the significance of the bulb-ended ones. I'm not totally dense and could make some guesses, but this still made the puzzle less than approachable for me at first. Basically I just guessed at these things, tried to see if I could solve one, and once I did and saw my complete solution all was clear. But why not state these things up front? Or maybe that's part of the puzzle? :-)
My first solve took 9min, then 3, then 1.5min for my third.
What algorithm are you using for it Spanning Tree?
I have been working on Maze Generation[0] and found randomized Prim's, Kruskal's to be useful for Spanning Tree creation but the good old Depth First Search increases the difficulty of solving a Maze.
[0] https://github.com/emadehsan/maze/blob/main/media/hexagonal....
The generator basically does the same but every tile starts out with a full set of possible orientations - every rotation of every tile shape (there are 62 I think). I remove some orientations due to border conditions, then pick a random possible orientation for some tile and so on till the board is filled. There usually is some backtracking involved.
This isn't terribly efficient and can get stuck for quite long when generating large puzzles. I actually want to look into adapting maze generation algorithms for creating these puzzles, so thanks for the link, I'll check it out.
"Rotate the tiles so that all pipes are connected with no loops."
These is exactly what a Spanning Tree is. So, any spanning tree generation algorithm would do. You just generate a random ST each time and cut this tree where the hexagon borders intersect with it (to get pipe pieces) and randomize their orientation.
These algorithms are not going to disappoint you in terms of performance.
I made tutorials on the topic as well. Might help me clear my point: https://youtu.be/d5yzKkG1n1U?t=36
Apologies for spamming. Sorry, if I'm suggesting premature optimization.
An efficient generator could perhaps even work client side, so I wouldn't have to store premade puzzle instances in the repo. That would be cool =).
You might consider implementing the traditional 3 mouse button controls (rotate left, mark correct, rotate right). If you can keep the Firefox context menu from popping up.
Maybe there's a way to support wrapping, and help the player understand which edge wraps to which? Maybe affecting the shape?
Related: 5 days ago "Simon Tatham's Portable Puzzle Collection (greenend.org.uk)": https://news.ycombinator.com/item?id=32170592
My wrap puzzles show an infinite tiled grid, so there shouldn't be questions about which edge wraps where. There are no edges, tiles just start repeating after a while. Maybe I didn't understand your question about wrapping?
This will scratch my nostalgia itch for a good while.
No can do. Psychology is a funny thing.
> or even write a script that hides it client side
Sure, or just update the code and host it myself. I was just making a casual comment, which the author is free to casually ignore.
It's not like you are having to rewrite his game.
Your edge-case psychological issue should be worth GP rewriting his game, when you couldn't be bothered to change some CSS in two seconds.
Full disclosure: I’m CTO at Rune, but I genuinely think it might be fun and easy for you to do. Here’s a similar popular game on Rune: https://app.rune.ai/untangle-H-vghwxUfO
Thank you and I hate you. I've infected my friends with this.
Also, since we're bragging about scores: 39s for the 5x5 wrapping, but I'll definitely be coming back to this.
Same for Loopy/Slitherlink. It's the same game, but changing shapes vastly changes the game. Very fascinating and refreshing.
All general principles still apply though, so experience with Net certainly helps here.
Edit: I like how I can mark known edges. So many digital puzzle games make it hard to mark the same stuff I would on a paper.
And good time on the wrap! Small wrap boards can actually be harder than larger ones because there's less chance of finding some seed tiles to start from.
I force myself to fix each cell as I scan the board from top to bottom, left to right. I thus have to visualize how my choices unfold downward, in search of clues, or ideally proofs, for how best to proceed. This manner of play reminds me a bit of the "reading" one does in the game of Go to explore variations before placing one's stone.
I hope other people find this more constrained version of interest as well...
(really fun game btw, I will have to return to this later. I'm looking forward to sharing this with my 8 year old who's fascinated with logic puzzles.)
I first played the version of this with squares on a Palm Pilot and that was a long time ago. I was even looking for that version for my iPhone the other day but was drowning in other random games (and little network tools) until I gave up.
It shouldn’t take much effort to turn it into a PWA, so then people can use it just like an app. I already saved it to my Home Screen and would certainly play this as a daily puzzle, just like Wordle. Keep up the great work.
Love your description too—would love to see a more in-depth write up if you get the time! It's so fun when you can flip from solving something to generating it. I'm also a fan of solving games with code and have made an Upwords bot that plays perfectly but realized I could use it to try to find better "hyperparameters" for the game (like how many points certain bonuses are) by getting it to play itself and having some metric of what a better game would be. Though as you can probably tell from the lack of a link I have yet to do that part.
Spanning trees may be required but not sufficient for a unique solution.
My frustration with wasting time (23 hours; I slept on it) on an unsolvable puzzle is somewhat mitigated by the fact the problem taught me this: if you count the free ends and come up with an odd number, you can know immediately that the puzzle isn't solvable, without rotating any tiles. An even number doesn't prove the puzzle is solvable, but an odd number definitely indicates a problem.
Edit: Nevermind; there was a 4th loose end I was overlooking. Finding it led to getting unstuck & the puzzle was solvable after all.
Unfortunately due to the way the site works, I don't seem to be able to get a new 10x10 puzzle by refreshing the page? So I'm stuck on the unsolvable one. I can imagine saving the progress is a feature, but you should also add a "pass" or "skip" button. Oh - I just realized I can "hack" it by manually changing the number in the URL to something else, e.g. /10/851.
Before I realized the puzzle was unsolvable I was also looking for a button to randomize/reset the initial tile positions. I was thinking maybe I wasn't seeing the solution due to my preconceived ideas from already-placed tiles. That wouldn't have helped here, but maybe on a solvable one being able to re-randomize would help a player get unstuck.
With a randomize button do you mean a complete reset to initial state? Or something like keep the locked tiles, reset the rest?
Didn't get a chance to look at your source.
My svg handling was very much "learn as I go". An earlier version even had circles instead of hexagons because they're simpler to do. There's a cool playthrough video of that version: https://www.youtube.com/watch?v=vlpPr485NUY
Edit: found the app, https://apps.apple.com/us/app/noodles/id967624193
Looks like they have a sequal to it and it includes a triangle grid!
PS: Make a start button instead of starting on load. Also the other game had a hypnotic looping music. Which could be put off.
I hope NYTimes buys this from you for lots of money! ;)
Really bad code here: https://github.com/justecorruptio/hexapipes
Sorry about your sleep schedule).
I did the 20x20 in 32:31.596 and now feel like I can close this tab :P
You can try the wrap variant for an extra challenge.
Often this will lead to more tiles with only one viable configuration.
(At very least you'll reduce the search space.)
My 5x5 is record is 28s on my 5th game. The strategy is actually really simple once you get going: run through and identify all the "lockable" (only one possible configuration) tiles and then run through the consequences of those configuration and keep repeating
Why would you lock a cell?
It's fairly handy when you're certain it is the only possible orientation and you want to prevent accidental rotations.
It's the same puzzle style, with square, triangle and hex shapes, with some extra mechanics - disappearing pieces, infinite grid (it wraps around).
gereleth, great job on the puzzles - I played a few of the bigger hex puzzles and it was real smooth. :)
https://play.google.com/store/apps/details?id=com.lummoxlabs... https://apps.apple.com/us/app/noodles-2/id1520711405
Big fan of the original many years ago. Will definitely check out the sequel
Noodles and all the Conceptis games were the only puzzle apps I never deleted off my phone
I have wrapping infinite grid variants too, but disappearing pieces? Intriguing =)).
I’m curious, did you use a special coordinate system for the hexagons or did you just make it work without any sort of coordinate system at all?
The hardest part was making the board repeat for the wrap variant making sure that all tiles have consistent wrap neighbours. I almost deployed a version that worked fine on odd-sized grids and went completely bananas on even-sized grids. The danger of always testing on a 5x5 board)).
Edit: Oh, now I see that right-click locks the tile. Yeah, that's a nice function, too.
This contextmenu issue is sure showing me the ugly side of frontend development :/
- changing puzzle size seems to break the back button - scroll behaviour is a bit strange
(Pixel 5, Chrome, if it helps)
Current bests are 5×5: 00:22.056, 7×7: 01:01.394.
Edit: also, a control to randomize the orientation of all unlocked tiles would be nice.
You sure are brave to take on a 40x40 =)
It was fun, but on the edge of annoying, which seems appropriate.
Given the authors note in this thread about each puzzle only having one solution probably means I stumbled onto a decent strategy
Wrap variants are another story as they have no outer edges. Discovering which tile groups give initial clues there is pretty fun too (when the regular puzzles aren't much of a challenge any more).
This is why I suck at game development. Congratulations for getting it out the door!
I did my second 5 in 3:08 too. Which is weird.