ashgrid 1.0.5

ASHGRID is a procedural map generator written in D.


To use this package, run the following command in your project's root directory:

Manual usage
Put the following dependency into your project's dependences section:

ASHGRID

ASHGRID is a procedural map generator written in D.

Examples

Initialization

auto settings = new MapSettings(seed, width, height);

Generating a map

auto biomes = generateBiomes(settings,
[
    Biome.plain : 0.4f, // 40% 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);

bool[] villageTiles;
biomes = generateVillages!Biome(settings, biomes,
    Biome.none,
    Biome.wall,
    Biome.wallBottom,
    Biome.door,
    Biome.floor,
    (b) => b == Biome.plain || b == Biome.forest,
    villageTiles);

auto heights = generateHillHeights(settings, villageTiles);

auto biomeTiles = generateTiles!(Biome, BiomeTileType)(settings, biomes, heights, (g,b,h)
{
    auto tile = defaultTileGenerator(g,b);

    if (tile.baseType != BiomeTileType.water && tile.baseType != BiomeTileType.dirtyWater)
    {
        tile.height = h;
    }

    return tile;
});

smoothTileEdges!(Biome, BiomeTileType)(settings, biomeTiles, (t)
{
    return t.baseType == BiomeTileType.water || t.baseType == BiomeTileType.dirtyWater;
});

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.

Authors:
  • Jacob Jensen
Dependencies:
none
Versions:
1.0.5 2025-Jul-11
1.0.4 2025-Jul-11
1.0.3 2025-Jul-11
1.0.2 2025-Jul-11
1.0.1 2025-Jul-10
Show all 6 versions
Download Stats:
  • 0 downloads today

  • 3 downloads this week

  • 3 downloads this month

  • 3 downloads total

Score:
0.5
Short URL:
ashgrid.dub.pm