digitalmars.D.announce - ASHGRID - Procedural Map Generator
ASHGRID is a procedural map generator written in D. It's kind of basic now but it gets the job done. It can generate various maps and also dungeons. It has a lot of flexibility in terms of configurations and also types can be replaced such as enums for biomes, tiles etc. https://code.dlang.org/packages/ashgrid https://github.com/bauss-dev/ASHGRID Examples Initialization ``` auto settings = new MapSettings(seed, width, height); ``` Generating a map ``` auto biomes = generateBiomes(settings, [ Biome.plain : 0.4f, // 405 plain Biome.forest : 0.4f, // 40% forest Biome.swamp : 0.2f // 20% swamp ]); generateWaterBiome!Biome(settings, biomes, Biome.water, (b) => b == Biome.plain || b == Biome.forest); generateWaterBiome!Biome(settings, biomes, Biome.dirtyWater, (b) => b == Biome.swamp); generateRivers!Biome(settings, biomes, Biome.water, (b) => b == Biome.plain || b == Biome.forest); generateRivers!Biome(settings, biomes, Biome.dirtyWater, (b) => b == Biome.swamp); auto heights = generateHillHeights(settings); auto biomeTiles = generateTiles!(Biome, BiomeTileType)(settings, biomes, heights, (g,b,h) { auto tile = defaultTileGenerator(g,b); tile.height = h; return tile; }); ``` Generating a dungeon ``` auto biomes = generateDungeon!Biome(settings, Biome.none, Biome.wall, Biome.plain); auto heights = createCoordinateArray!int(settings.width, settings.height); auto biomeTiles = generateTiles!(Biome, BiomeTileType)(settings, biomes, heights, (g,b,h) { auto tile = defaultTileGenerator(g,b); tile.height = h; return tile; }); ``` How you render everything is up to you and will depend on your game engine etc. You may use the functions createCoordinateArray() and getCoordinateIndex() to interact with the final produced map.
Jul 10
On Friday, 11 July 2025 at 00:06:16 UTC, bauss wrote:...just realized a typo with 40% ... hope it's okay for now.
Jul 10