Lurker News
Hello, HN - I wanted to share this puzzle game I made during my vacation.

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 =).

Comments (161) 65 threads

nabakin4 replies#
Make a daily one where everyone has the same game for the day and you can share your scores and my entire friend group would play along with the other ones we do like Wordle and NYT Mini Crossword. Let me know if you add this!
alexb_1 reply#
Agree, this is what can really push it. A daily 5x5 w/ easily shareable scores is the way you can bring this to a lot of people.
bravura#
Or, a daily 5x5, 7x7, etc. for the true addicts
endlessvoid941 reply#
Absolutely. I haven't been pulled into a puzzle like this in awhile. I'd pay a very modest amount for an app
kasbah#
You might enjoy an existing app called Infinity Loop. It's a similar puzzle game using the traditional square puzzle-piece shape.
yencabulator#
Plumble?
mdavis68903 replies#
Great game!

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.

seanalltogether#
This was exactly the same for me. I wasn't sure if all pipes had to be water tight or not. Once I understood what the actual constraints were I could solve the next ones quicker.
gereleth3 replies#
Fair enough, I'll think how to word all this.
mdavis68901 reply#
- All sections must be connected into a single, contiguous network. - The whole network is contained in the grid, and no pipes may run outside the grid. - Bulb-shaped pipes with a single connection are terminations (dead-ends).
mdavis6890#
I'll agree with other commenters that actually just showing a complete solution is better. Or both!
JelteF1 reply#
I think simply having an image of what a solved network looks like would help a lot.
Bootvis#
Agreed, I didn’t bother reading the rules and just started clicking. I doubt I would read the rules even if they were written perfectly.
hombre_fatal#
a pic of a before and after puzzle would answer these questions intuitively as well.
jonny_eh#
Those kinds of edge cases can be easily overlooked by people that play a lot of these types of puzzle games. Great feedback.
emadehsan1 reply#
Captivating! So, while generating the puzzle, you are essentially creating a random Spanning Tree for the given nodes (hexagon) arrangement? Then you randomize each pipe piece's direction within a hexagon?

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....

gereleth2 replies#
Well the way I wrote my pipes solver was to keep a set of possible orientations of every tile and gradually remove impossible options by using border conditions and some heuristics like avoiding islands and loops. And when this doesn't turn up any new info I resort to depth-first search.

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.

emadehsan#
I see. Amazing work you have done! This game is enticing.
emadehsan1 reply#
My understanding is that since the game mentions:

"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.

gereleth1 reply#
There might still be issues with multiple solutions... Because when a board has multiple solutions they're all valid Spanning Trees. But there probably is some way around this.

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

neilv2 replies#
Neat. The multiple colors for groups is another innovation beyond SGT's Net.

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

gereleth1 reply#
Mm, middle button, why didn't I think of it.

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?

culi1 reply#
A "click and hold" to lock a tile into place would also be great and mobile accessible
kbenson2 replies#
It already does that on mobile. It allows marking edges as connecting or not, and locking tiles with a long press.

Continue this thread — 2 replies

effingwewt#
I don't know how I missed that post but thanks a ton!

This will scratch my nostalgia itch for a good while.

Load more comments