CaptainJester
One second faster and I would have to play 16x10 plane all over again, just to reinstate order in the universe
The source is included in the jar (in one big jumble. But it was the way Netbeans liked it, and I didn’t feel like messing around. And I didn’t write proper comments. And the gui code is a mess. I’ll have to get it sorted out sometime. Enough with the excuses). The game is under GPL, so you are free to tinker with it as long as long as modified versions use the same license.
I use the simplest generation algorithm I could conceive.
Generation
An edge candidate is a potential connection from one tile to one if its neighbours. Each tile thus has four edge candidates which are shared among tile neighbours (so candidate count = 2 * tile count).
Make one big list of all possible edge candidates, then shuffle that list.
For each edge candidate in the shuffled list, connect the two corresponding neighbouring tiles, UNLESS that connection would be “illegal”.
Illegal means that the tiles are already connected somehow. Of course this means that we’ll have to keep track of connected tiles, which we’ll consider now.
Connectedness
Every tile is assigned a number, called its index. Whenever a tile is connected to another tile during map generation, the indices of both tiles is set to the lower of the two tile indices. Actually this is done by means of a recursive flood fill through all the thus interconnected tiles, so any body of connected tiles has the same index at all times. The criterion of not connecting tiles that are already interconnected is thus enforced by requiring that the two tiles have different index.
This always results in the lowest possible connection count, namely n vertices connected with n-1 edges. So not only does the generated map have no closed loops, there is indeed no solution at all with any closed loops, which can be quite a powerful criterion when solving difficult games. Also it is, not surprisingly, impossible to find any solution with any loose tile connections.