JST.LevelGen
1.0.0-beta.0
This is a prerelease version of JST.LevelGen.
dotnet add package JST.LevelGen --version 1.0.0-beta.0
NuGet\Install-Package JST.LevelGen -Version 1.0.0-beta.0
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="JST.LevelGen" Version="1.0.0-beta.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="JST.LevelGen" Version="1.0.0-beta.0" />
<PackageReference Include="JST.LevelGen" />
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add JST.LevelGen --version 1.0.0-beta.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: JST.LevelGen, 1.0.0-beta.0"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package JST.LevelGen@1.0.0-beta.0
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=JST.LevelGen&version=1.0.0-beta.0&prerelease
#tool nuget:?package=JST.LevelGen&version=1.0.0-beta.0&prerelease
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
LevelGen
LevelGen is a .NET 10 library for assembling 2D tile-based dungeon layouts from reusable prefab blocks.
It includes:
src\LevelGen: core generator librarysrc\LevelGen.Playground: console playground for rerolling mapstests\LevelGen.Tests: xUnit tests for parser and generator behavior
Requirements
- .NET SDK 10.0+
Build
dotnet build LevelGen.slnx
Run the playground
From the repository root:
dotnet run --project src\LevelGen.Playground -- --once
The playground will auto-discover blocks.txt (included at src\LevelGen.Playground\blocks.txt), generate a level, print the ASCII map, and exit.
Useful options:
--blocks <path>: use a specific blocks file--seed <int>: deterministic generation--max-prefabs <int>: target number of room placements--max-corridor-length <int>: generated corridor max length--no-loops: disallow extra loop connections--no-corridors: disable generated corridors--no-mirror: disable mirrored prefab variants--once: generate once and exit
Generation model
- Generation is deterministic for a fixed
Seedand identical inputs. - Prefabs are expanded from connectors using backtracking search.
- Open connectors with fewer valid candidates are expanded first to reduce dead-end branching.
- Candidate placements are shuffled with a seeded Fisher-Yates shuffle before recursion.
- Finalization enforces a contiguous walkable floor region and resolves connectors to floor/wall based on whether they were linked.
Use as a library
using LevelGen;
using LevelGen.Blocks;
var text = File.ReadAllText(@"src\LevelGen.Playground\blocks.txt");
var prefabSet = BlocksPrefabParser.Parse(text);
var result = LevelGenerator.Generate(
prefabSet,
new GenerationOptions
{
Seed = 12345,
MaxPrefabCount = 6,
AllowLoops = true,
AllowGeneratedCorridors = true,
AllowMirrorTransforms = true,
MaxCorridorLength = 8
});
LevelMap map = result.Map;
IReadOnlyList<PlacedPrefab> placements = result.Placements;
blocks.txt format
Prefabs are defined in sections:
- Section header starts with
>(for example> Square) - Tile rows follow the header
- Blank line ends the prefab
- Lines starting with
/are comments
Supported tokens:
#wall.floor*connector?optional doodad marker (stored as doodad, tile is floor)A-Pdoodad marker (stored as doodad, tile is floor)- space = empty tile
Test
dotnet test tests\LevelGen.Tests\LevelGen.Tests.csproj
Generate a Cobertura coverage report:
dotnet test tests\LevelGen.Tests\LevelGen.Tests.csproj --collect:"XPlat Code Coverage" --settings coverage.runsettings --results-directory .\TestResults\Coverage
Troubleshooting prefab input
FormatExceptionduring parse typically means a malformed section header (>), unsupported token, or tiles before a prefab header.- Connectors (
*) should represent boundary openings. Ambiguous connector orientation can trigger validation errors during variant generation.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net10.0 is compatible. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
net10.0
- No dependencies.
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 1.0.0-beta.0 | 79 | 8/23/2026 |