Delete the Markov name generator, its data and settings, NameFile and GeonameFile
The NameFile records went with commit 2's apply, so the type, Faction key 9 (left as a retired-key comment), NameGeneratorSettings and its parameter on Galaxy and GalaxyStage, the Settings.asset block, the Name Tools editor window, the Geonames resources, the purge leg of place-names and the minor-power and Pirates commands' name-file lookups all go. The Pirates missing-name-file test pins a retired rule and goes with it. Factions shows a places count where the geonames column was. Unity compile owed at merge. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
0a6bbdde13
commit
1d689adfa6
55 changed files with 45 additions and 1879 deletions
|
|
@ -7,7 +7,7 @@ using GameCult.Caching.MessagePack;
|
|||
// Aetheria's stores: one home store per type, composed here and nowhere else.
|
||||
public static class AetheriaStores
|
||||
{
|
||||
public static readonly Type[] CatalogTypes = { typeof(ItemData), typeof(ShipAuthoring), typeof(Faction), typeof(FactionProductData), typeof(PersonalityAttribute), typeof(NameFile), typeof(InputLayout), typeof(Loadout), typeof(FieldKindData), typeof(VerseGrammar), typeof(VerseVerb) };
|
||||
public static readonly Type[] CatalogTypes = { typeof(ItemData), typeof(ShipAuthoring), typeof(Faction), typeof(FactionProductData), typeof(PersonalityAttribute), typeof(InputLayout), typeof(Loadout), typeof(FieldKindData), typeof(VerseGrammar), typeof(VerseVerb) };
|
||||
public static readonly Type[] RunTypes = { typeof(OrbitData), typeof(BodyData), typeof(SavedZone), typeof(SavedGame), typeof(ProvenanceLedger) };
|
||||
public static readonly Type[] PlayerTypes = { typeof(PlayerSettings) };
|
||||
|
||||
|
|
|
|||
|
|
@ -37,8 +37,7 @@ public class Faction
|
|||
[InspectableColor, JsonProperty("secondaryColor"), Key(8)]
|
||||
public float3 SecondaryColor;
|
||||
|
||||
[Inspectable, JsonProperty("nameFile"), Key(9)]
|
||||
public CultRecordRef<NameFile> GeonameFile;
|
||||
// Key 9 was the faction's name-file link, retired by ruling faction-curated-place-names; never reuse it.
|
||||
|
||||
[Inspectable, JsonProperty("bossHull"), Key(10)]
|
||||
public CultRecordRef<HullData> BossHull;
|
||||
|
|
@ -78,9 +77,3 @@ public class FactionPlace
|
|||
public string Name;
|
||||
}
|
||||
|
||||
[CultDocument("aetheria.namefile", "1"), Inspectable, MessagePackObject]
|
||||
public class NameFile
|
||||
{
|
||||
[CultName, Key(1)] public string Name;
|
||||
[Key(2)] public string[] Names;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -20,7 +20,6 @@ public class Galaxy
|
|||
public HashSet<GalaxyZone> DiscoveredZones = new HashSet<GalaxyZone>();
|
||||
|
||||
public SectorBackgroundSettings Background { get; }
|
||||
public NameGeneratorSettings NameGeneratorSettings { get; }
|
||||
public Faction[] Factions { get; }
|
||||
public GalaxyZone[] Zones { get; }
|
||||
public GalaxyZone Entrance { get; }
|
||||
|
|
@ -95,7 +94,6 @@ public class Galaxy
|
|||
public Galaxy(
|
||||
SectorGenerationSettings settings,
|
||||
SectorBackgroundSettings background,
|
||||
NameGeneratorSettings nameGeneratorSettings,
|
||||
CultCache cache,
|
||||
Action<string> log,
|
||||
Action<string> progressCallback = null,
|
||||
|
|
@ -161,7 +159,6 @@ public class Galaxy
|
|||
public Galaxy(
|
||||
TutorialGenerationSettings settings,
|
||||
SectorBackgroundSettings background,
|
||||
NameGeneratorSettings nameGeneratorSettings,
|
||||
CultCache cache,
|
||||
PlayerSettings playerSettings,
|
||||
DirectoryInfo narrativeDirectory,
|
||||
|
|
|
|||
|
|
@ -15,7 +15,6 @@ public sealed class GalaxyStage
|
|||
private readonly SectorBackgroundSettings _sectorBackground;
|
||||
private readonly TutorialGenerationSettings _prelude;
|
||||
private readonly SectorBackgroundSettings _preludeBackground;
|
||||
private readonly NameGeneratorSettings _names;
|
||||
private readonly CultCache _cache;
|
||||
private readonly PlayerSettings _playerSettings;
|
||||
private readonly DirectoryInfo _narrativeDirectory;
|
||||
|
|
@ -28,7 +27,6 @@ public sealed class GalaxyStage
|
|||
SectorBackgroundSettings sectorBackground,
|
||||
TutorialGenerationSettings prelude,
|
||||
SectorBackgroundSettings preludeBackground,
|
||||
NameGeneratorSettings names,
|
||||
CultCache cache,
|
||||
PlayerSettings playerSettings,
|
||||
DirectoryInfo narrativeDirectory,
|
||||
|
|
@ -40,7 +38,6 @@ public sealed class GalaxyStage
|
|||
_sectorBackground = sectorBackground;
|
||||
_prelude = prelude;
|
||||
_preludeBackground = preludeBackground;
|
||||
_names = names;
|
||||
_cache = cache;
|
||||
_playerSettings = playerSettings;
|
||||
_narrativeDirectory = narrativeDirectory;
|
||||
|
|
@ -64,7 +61,7 @@ public sealed class GalaxyStage
|
|||
var background = Copy(_sectorBackground);
|
||||
var random = new Random(Seed);
|
||||
background.NoisePosition = random.NextFloat() * 1000;
|
||||
return new Galaxy(_sector, background, _names, _cache, _log, _progress, Seed);
|
||||
return new Galaxy(_sector, background, _cache, _log, _progress, Seed);
|
||||
}
|
||||
|
||||
// A prelude galaxy: the tutorial settings and their fixed factions, centred in dense cloud.
|
||||
|
|
@ -81,7 +78,7 @@ public sealed class GalaxyStage
|
|||
background.NoisePosition = random.NextFloat() * 1000;
|
||||
_progress?.Invoke($"Finding Galaxy Position: iteration {iteration++}");
|
||||
} while (background.CloudDensity(float2(.5f)) < .5f);
|
||||
return new Galaxy(cast, background, _names, _cache, _playerSettings, _narrativeDirectory, _log, _progress, Seed);
|
||||
return new Galaxy(cast, background, _cache, _playerSettings, _narrativeDirectory, _log, _progress, Seed);
|
||||
}
|
||||
|
||||
private static SectorBackgroundSettings Copy(SectorBackgroundSettings settings) =>
|
||||
|
|
|
|||
|
|
@ -1,129 +0,0 @@
|
|||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using static CultMath.math;
|
||||
using Random = CultMath.Random;
|
||||
|
||||
//Generates random names based on the statistical weight of letter sequences
|
||||
//in a collection of sample names
|
||||
public class MarkovNameGenerator
|
||||
{
|
||||
private Dictionary<string, List<char>> _chains = new Dictionary<string, List<char>>();
|
||||
private List<string> _samples = new List<string>();
|
||||
// The names already given, shared by every generator that must not repeat another's: a galaxy passes one set to
|
||||
// all its factions' generators. Never process-wide, so one galaxy's names cannot change the next galaxy's.
|
||||
private readonly HashSet<string> _used;
|
||||
private int _order;
|
||||
private int _minLength;
|
||||
private int _maxLength;
|
||||
private Random _random;
|
||||
|
||||
public MarkovNameGenerator(ref Random random, IEnumerable<string> sampleNames, NameGeneratorSettings settings, HashSet<string> used)
|
||||
{
|
||||
_used = used;
|
||||
var names = new HashSet<string>();
|
||||
foreach (var line in sampleNames)
|
||||
{
|
||||
foreach(var word in line.ToUpperInvariant().Split(' ', ',', '.', '"'))
|
||||
if (word.Length >= settings.NameGeneratorMinLength && !names.Contains(word))
|
||||
names.Add(word);
|
||||
}
|
||||
|
||||
_random = random;
|
||||
|
||||
_order = max(1, settings.NameGeneratorOrder);
|
||||
_minLength = max(1, settings.NameGeneratorMinLength);
|
||||
_maxLength = settings.NameGeneratorMaxLength;
|
||||
|
||||
Initialize(names);
|
||||
}
|
||||
|
||||
public MarkovNameGenerator(ref Random random, IEnumerable<string> sampleNames, int order, int minLength, int maxLength)
|
||||
{
|
||||
_used = new HashSet<string>();
|
||||
_random = random;
|
||||
|
||||
_order = max(1, order);
|
||||
_minLength = max(1, minLength);
|
||||
_maxLength = maxLength;
|
||||
|
||||
Initialize(sampleNames);
|
||||
}
|
||||
|
||||
private void Initialize(IEnumerable<string> sampleNames)
|
||||
{
|
||||
//split comma delimited lines
|
||||
foreach (string line in sampleNames)
|
||||
{
|
||||
string[] tokens = line.Split(' ','\'','(',')');
|
||||
foreach (string word in tokens)
|
||||
{
|
||||
string upper = word.Trim().ToLowerInvariant();
|
||||
if (upper.Length < _order + 1)
|
||||
continue;
|
||||
_samples.Add(upper + '|'); // Add end character
|
||||
}
|
||||
}
|
||||
|
||||
//Build chains
|
||||
foreach (string word in _samples)
|
||||
{
|
||||
for (int letter = 0; letter < word.Length - _order; letter++)
|
||||
{
|
||||
string token = word.Substring(letter, _order);
|
||||
List<char> entry = null;
|
||||
if (_chains.ContainsKey(token))
|
||||
entry = _chains[token];
|
||||
else
|
||||
{
|
||||
entry = new List<char>();
|
||||
_chains[token] = entry;
|
||||
}
|
||||
entry.Add(word[letter + _order]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//Get the next random name
|
||||
public string NextName
|
||||
{
|
||||
get
|
||||
{
|
||||
|
||||
string s = "";
|
||||
do
|
||||
{
|
||||
int n = _random.NextInt(0,_samples.Count);
|
||||
//int nameLength = _samples[n].Length;
|
||||
s = _samples[n].Substring(0, _order);//get a random token at the start of a sample word
|
||||
while (true)//(s.Length < nameLength)
|
||||
{
|
||||
string token = s.Substring(s.Length - _order, _order);
|
||||
char c = GetLetter(token);
|
||||
if (c != '?' && c != '|')
|
||||
s += c;//GetLetter(token);
|
||||
else
|
||||
break;
|
||||
}
|
||||
s = s.Substring(0, 1).ToUpper() + s.Substring(1);
|
||||
}
|
||||
while (_used.Contains(s) || s.Length < _minLength || s.Length > _maxLength);
|
||||
_used.Add(s);
|
||||
return s;
|
||||
}
|
||||
}
|
||||
|
||||
//Get a random letter from the chain
|
||||
private char GetLetter(string token)
|
||||
{
|
||||
if (!_chains.ContainsKey(token))
|
||||
return '?';
|
||||
List<char> letters = _chains[token];
|
||||
int n = _random.NextInt(0,letters.Count);
|
||||
return letters[n];
|
||||
}
|
||||
}
|
||||
|
|
@ -1,11 +0,0 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 33c3b119ccc9de447b8c8318b6f0d1af
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
|
@ -45,14 +45,6 @@ public class GalaxyShapeSettings
|
|||
public float TwistExponent = 2;
|
||||
}
|
||||
|
||||
[Serializable, MessagePackObject(keyAsPropertyName:true), JsonObject]
|
||||
public class NameGeneratorSettings
|
||||
{
|
||||
public int NameGeneratorMinLength = 5;
|
||||
public int NameGeneratorMaxLength = 10;
|
||||
public int NameGeneratorOrder = 4;
|
||||
}
|
||||
|
||||
[Serializable, MessagePackObject(keyAsPropertyName:true), JsonObject]
|
||||
public class SectorBackgroundSettings
|
||||
{
|
||||
|
|
|
|||
Loading…
Reference in a new issue