Show HN: Pipes puzzle (a.k.a. Net) on a hexagonal grid (opens in a new tab)hexapipes.vercel.app
537 pointsI'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 =).

Comments (161) 65 threads
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 =).
Continue this thread — 1 reply
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?
Continue this thread — 2 replies
This will scratch my nostalgia itch for a good while.
All comments shown.
Couldn't load more comments. Check your connection and try again.