Hacker News new | ask | show | jobs
by emadehsan 1431 days ago
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.

1 comments

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

Could perhaps look into the source of Simon Tatham's variant? Those are generated client side.