LexiconLang.SciFi
1.5.0
dotnet add package LexiconLang.SciFi --version 1.5.0
NuGet\Install-Package LexiconLang.SciFi -Version 1.5.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="LexiconLang.SciFi" Version="1.5.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="LexiconLang.SciFi" Version="1.5.0" />
<PackageReference Include="LexiconLang.SciFi" />
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 LexiconLang.SciFi --version 1.5.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: LexiconLang.SciFi, 1.5.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 LexiconLang.SciFi@1.5.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=LexiconLang.SciFi&version=1.5.0
#tool nuget:?package=LexiconLang.SciFi&version=1.5.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
LexiconLang.Net
A complete C#/.NET port of the deterministic procedural generation system LexiconLang. Designed for games, tabletop tools, and narratives, focusing on absolute determinism, composability, and 1-to-1 parity with the TypeScript library.
Features
- Absolute Determinism: The entire generation tree is driven by a hierarchical
Contextseeded randomly or strictly.Context.Child("node")automatically forks the Random Number Generator to maintain isolated state streams—meaning adding or removing content elsewhere won't shift unrelated lists! - Data-Driven & Composable: Use small atomic string/object generators combined via
Combinators.Repeat,Compose,WeightedList, etc. - Tracery-style Grammars:
LexiconLang.Grammarsupports complex, recursively expanded templates and custom text modifiers (#name.capitalize#). - Markov Models:
LexiconLang.Markovallows you to train text models to procedurally generate cohesive names and prose. - Phonotactics & Glyphs:
LexiconLang.LanguageandLexiconLang.Glyphsenable generation of culturally distinct languages, unique words, and corresponding SVG procedural runes/glyphs. - Content Packs out-of-the-box:
LexiconLang.Fantasy,LexiconLang.SciFi, andLexiconLang.Modern.
Included Packages
LexiconLang.Core(RNG,Context, Combinators)LexiconLang.GrammarLexiconLang.MarkovLexiconLang.LanguageLexiconLang.GlyphsLexiconLang.Fantasy,LexiconLang.SciFi,LexiconLang.Modern
Usage Examples
1. Minimal Quickstart
using System;
using LexiconLang.Core;
using LexiconLang.Fantasy;
class Program
{
static void Main()
{
// 1. Initialize root context with a deterministic seed
var ctx = LexiconContext.Create("hello-world");
// 2. Generate random results from an included content pack
var faction = FantasyEncounters.FactionGenerator.Generate(ctx.Child("faction"));
var title = FantasyEncounters.TitleGenerator.Generate(ctx.Child("title"));
Console.WriteLine($"The {title} of {faction}");
}
}
2. Custom Generators
public record IronKnight(string Name, string Rank);
var house = Combinators.OneOf<string, object?>("Vael", "Kessel", "Vorden", "Bayard");
var rank = Combinators.WeightedList<string, object?>(new[]
{
new Weighted<string>("Squire", 4),
new Weighted<string>("Knight", 8),
new Weighted<string>("Knight-Captain", 2),
});
var ironKnight = Combinators.Compose<IronKnight, object?>("ironknight", ctx =>
{
return new IronKnight(
"Sir " + house.Generate(ctx.Child("name")),
rank.Generate(ctx.Child("rank"))
);
});
var rootCtx = LexiconContext.Create("iron-watch");
var k = ironKnight.Generate(rootCtx.Child("watch:0"));
3. Grammars (Tracery Style)
var rules = new GrammarRules<object?>
{
{ "start", new Weighted<string>[]
{
new ("#prefix.capitalize# #element.capitalize# #form.capitalize#", 5),
new ("the #adj.capitalize# #form.capitalize#", 2)
}
},
{ "prefix", new[] { "lesser", "greater", "true" } },
{ "element", new[] { "fire", "frost", "shadow" } },
{ "form", new[] { "bolt", "ward", "veil" } },
{ "adj", new[] { "unsleeping", "patient", "errant" } }
};
var spellName = new Grammar<object?>(rules);
var ctx = LexiconContext.Create("spellbook");
// Prints e.g. "Greater Shadow Bolt"
Console.WriteLine(spellName.Generate(ctx));
4. Markov Model
var corpus = new[] { "caernarfon", "carmarthen", "ceredigion", "conwy", "gwynedd" };
var entries = corpus.Select(x => new TrainEntry(x));
// Train the generator
var model = Trainer.Train(entries, new TrainOptions(Order: 3, MinLength: 5, MaxLength: 12));
var townName = Sampler.AsGenerator<object?>(model);
var ctx = LexiconContext.Create("welsh-towns");
Console.WriteLine(townName.Generate(ctx));
5. Culture & Glyphs
var ctx = LexiconContext.Create("glyph-demo");
// Generate a culturally appropriate name and translation
var dwarfName = Templates.GenerateName(FantasyCultures.Dwarvish, "given", ctx.Child("dwarf"));
// Setup the glyph system to be phoneme-based
var visualSystem = new VisualGlyphSystem(
Name: "dwarvish-runes",
Strategy: MappingStrategy.Phoneme,
Complexity: Complexity.Medium,
Format: RenderFormat.Svg,
Palette: new[] { "#333", "#666" }
);
// Map the generated name strictly structure-to-glyph
var dwarfGlyphs = GlyphGenerator.GlyphsFor(dwarfName, visualSystem, ctx.Child("dwarf"));
Build and test
dotnet build -warnaserror
dotnet test LexiconLang.Net.slnx
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net9.0 is compatible. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. 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
- LexiconLang.Core (>= 1.5.0)
- LexiconLang.Grammar (>= 1.5.0)
- LexiconLang.Language (>= 1.5.0)
- LexiconLang.Markov (>= 1.5.0)
-
net9.0
- LexiconLang.Core (>= 1.5.0)
- LexiconLang.Grammar (>= 1.5.0)
- LexiconLang.Language (>= 1.5.0)
- LexiconLang.Markov (>= 1.5.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.