Show HN: Pipes puzzle (a.k.a. Net) on a hexagonal grid (hexapipes.vercel.app)
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 =).
163 comments
[ 4.5 ms ] story [ 279 ms ] threadIt'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
I have wrapping infinite grid variants too, but disappearing pieces? Intriguing =)).
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
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
I did my second 5 in 3:08 too. Which is weird.
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!
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 =).
Spanning trees may be required but not sufficient for a unique solution.
(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.
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.
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.
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
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.
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
Edit: Oh, now I see that right-click locks the tile. Yeah, that's a nice function, too.
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