yellowstonegames / SquidLib

Useful tools for roguelike, role-playing, strategy, and other grid-based games in Java. Feedback is welcome!
Other
448 stars 46 forks source link

DenseRoomMapGenerator has unconnected areas #208

Closed madmenyo closed 5 years ago

madmenyo commented 5 years ago

I generated a view maps with the DenseRoomMapGenerator.Java and it always leaves some unconnected areas. Your link to the output in the comments has everything connected.

Reproduce:

I have yet to find a seed that connects every section.

new DenseRoomMapGenerator(40, 40, new GWTRNG(101)); // look top left
new DenseRoomMapGenerator(40, 40, new RNG(40)); // Look top left

throw it in here to see results, but I bet you have other ways :).

private void showMap(char[][] map) {
        StringBuilder sb = new StringBuilder();
        for (int y = 0; y < map[1].length; y++) {
            for (int x = 0; x < map.length; x++) {
                sb.append(map[x][y]);
            }
            sb.append("\n");
        }

        System.out.println(sb.toString());
    }

Version: 3.0.0-b10'

tommyettinger commented 5 years ago

Sounds about right; DungeonGenerator (or SectionDungeonGenerator) is the class that blocks out disconnected areas. You can feed the char[][] to DungeonGenerator and it will find the largest walk-able area and wall off any areas that aren't connected to it. DungeonGenerator can also add doors, grass, and boulders, and splash water around.

You can also use DungeonUtility.debugPrint(char[][]) to print dungeons; your approach works fine though and also allows substitutions on the StringBuilder or the String it produces, which debugPrint() does not.