[HN Gopher] Show HN: Pipes puzzle (a.k.a. Net) on a hexagonal grid
       ___________________________________________________________________
        
       Show HN: Pipes puzzle (a.k.a. Net) on a hexagonal grid
        
       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 =).
        
       Author : gereleth
       Score  : 115 points
       Date   : 2022-07-24 18:50 UTC (1 days ago)
        
 (HTM) web link (hexapipes.vercel.app)
 (TXT) w3m dump (hexapipes.vercel.app)
        
       | [deleted]
        
       | dematz wrote:
       | Fun game and nice site, it feels like to pipes what wordle is to
       | words!
        
         | gereleth wrote:
         | Compared to wordle, what an honour =). The site design actually
         | comes from the default SvelteKit skeleton project. I was
         | focused on the game part so I never changed it.
        
       | yesthisiswes wrote:
       | Awesome puzzle. Great job!
        
       | swayvil wrote:
       | My first, a 5x5, in 3:08
       | 
       | It was fun, but on the edge of annoying, which seems appropriate.
        
         | WesleyJohnson wrote:
         | 2:37 for me, and I'm not terribly good at puzzles. I was
         | getting frustrated and then it just kind of clicked. The color
         | changing is incentivizing. I found it fun in general; might
         | have to do a couple more...
        
         | mkoryak wrote:
         | my first 5x5 I couldn't solve in 4 minutes, then I gave up.
         | This puzzle makes me angry.
        
         | TOMDM wrote:
         | I finished my first on 1:33, starting from the edge and working
         | in, moving to a different spot when I noticed too much flex was
         | my strategy.
         | 
         | Given the authors note in this thread about each puzzle only
         | having one solution probably means I stumbled onto a decent
         | strategy
        
           | swayvil wrote:
           | Ya, the edge is key. So are hexes that have minimal possible
           | positions.
           | 
           | I did my second 5 in 3:08 too. Which is weird.
        
           | Arrath wrote:
           | I started in the top left corner and worked connections down
           | from there. So far I have a solve yet to take over a minute.
        
           | gereleth wrote:
           | This is pretty much how I solve regular puzzles too. I can do
           | most 5x5s in under 20 seconds. Too often did my debugging
           | sessions devolve into puzzle marathons =).
           | 
           | 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).
        
             | klyrs wrote:
             | > Too often did my debugging sessions devolve into puzzle
             | marathons =).
             | 
             | This is why I suck at game development. Congratulations for
             | getting it out the door!
        
       | mdavis6890 wrote:
       | 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 wrote:
         | 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.
        
         | gereleth wrote:
         | Fair enough, I'll think how to word all this.
        
       | harpersealtako wrote:
       | Solved my first 5x5 in 1:54. At first I thought it would be
       | really difficult but then I found a hex which could only go one
       | way (a corner hex with V shape) and then from there the adjacent
       | pipes could only orient one way. There were a few times where I
       | had to think down a tree of possibilities (if this hex goes like
       | this, then this hex can't possibly fit here because of a
       | previously solved hex, therefore it must go like this instead),
       | but never more than one or two steps. All in all it's a very
       | satisfying puzzle format.
        
       | evan_ wrote:
       | What are the green/red lines that appear when you click the
       | junction between two hexes?
       | 
       | (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.)
        
         | gereleth wrote:
         | Those are edge marks, they let you mark some edges as
         | "definitely a wall" or "definitely a connection". It sometimes
         | helps in harder puzzles).
        
       | bilekas wrote:
       | This is quite fun actually.. nice work!
        
       | OisinMoran wrote:
       | This is super fun! Just played a few and my best on the 5x5 was
       | 0:42. Thanks for sharing!
       | 
       | 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.
        
       | emadehsan wrote:
       | 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....
        
         | gereleth wrote:
         | 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 wrote:
           | 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.
        
             | gereleth wrote:
             | 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 =).
        
           | emadehsan wrote:
           | I see. Amazing work you have done! This game is enticing.
        
       | pyrolistical wrote:
       | Its annoying having to tap so many times, especially when certain
       | pieces have few valid orientations.
        
         | gereleth wrote:
         | You can check out "Orient / Lock" control mode in the settings.
         | It lets you orient a tile in one tap but needs precision about
         | where you tap. I mostly use this mode but it takes some getting
         | used to, so I didn't make it the default.
        
       | michannne wrote:
       | Solved in 1:39, very fun game and great implementation! I'm not
       | much a fan of pipes games but have played similar concepts such
       | as Infinite Energy on mobile. This is a good job for such a
       | quickly developed project
        
       | bunsenhoneydew wrote:
       | Love it!
       | 
       | 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.
        
       | forty wrote:
       | Is there always a single possible solution ? (I did a bunch of
       | small ones and always found a solution pretty quickly)
        
         | gereleth wrote:
         | All puzzles on the site have a unique solution At least my
         | solver thinks so)). Configurations with multiple solutions are
         | possible, but I weeded those out when generating.
        
         | emadehsan wrote:
         | _if_ the pipes are cut from a Spanning Tree connecting all the
         | hexagons (like the one you witness once you have solved), then
         | yes, for those give pipe pieces, there should be only one
         | solution.
        
       | loganc2342 wrote:
       | I have a minor nitpick to share. I'd like it if there was an
       | option to hide the timer, because being under time pressure to
       | solve a puzzle can stress me out. Overall, it's a fun puzzle,
       | though!
        
         | gereleth wrote:
         | Thanks for sharing, I'll add that option (on the weekend most
         | likely).
        
         | boosteri wrote:
         | I'd like an opposite option.. where the timer runs out :-)
         | maybe with a neat graphics of water flowing from the bulb
         | starting point(s)
        
           | joeframbach wrote:
           | You would enjoy Ant Run, which I played for hours on end in
           | the late 90s. https://www.dosgames.com/game/ant-run. There is
           | a browser-based emulator available here.
        
       | Syzygies wrote:
       | Wow! What fun. You have to make this a phone/tablet app...
        
         | mbusheikin wrote:
         | Well, this seems an appropriate place to plug the phone/tablet
         | app we made with these puzzles, called Noodles 2.
         | 
         | 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
        
           | nathancahill wrote:
           | That's awesome. Really slick app.
        
           | gereleth wrote:
           | Nice graphics, I love the soft lines.
           | 
           | I have wrapping infinite grid variants too, but disappearing
           | pieces? Intriguing =)).
        
         | gereleth wrote:
         | Glad you liked it! I actually play it often on my phone, it's
         | workable when zoomed in. An app would be nicer surely but I
         | don't know how to build those =).
        
           | moomin wrote:
           | You 100% need to figure that out, because this is _really_
           | good and there's money to be made here. Make sure you're the
           | one who makes it.
        
       | adenozine wrote:
       | 40x40???? Wow, that would take me several hours if not a workday
       | or more. Goodness lord
        
       | ranman wrote:
       | Why are the SVG tiles specified to 599.99999999 instead of 600 or
       | something? I think a SVGO optimizations run would reduce the size
       | of the assets a tad.
        
         | gereleth wrote:
         | There aren't really any assets though. I just create the svgs
         | dynamically. Maybe I need to place some strategic `Math.round`
         | calls here and there, never thought of this =).
        
         | Etheryte wrote:
         | I would guess that the assets were made in Inkscape or
         | comparable software where you work visually and don't actually
         | look at the generated code.
        
       ___________________________________________________________________
       (page generated 2022-07-25 23:00 UTC)