A galaxy's zone names are unique within the galaxy, not across the process
MarkovNameGenerator kept every name it ever gave in a static list, so each later galaxy in a session drew different zone names at the same seed, and ZoneGenerator seeds a zone from its name: a fixed-seed scenario relaunched in one session got a different arena. Galaxy now passes one used-name set to its factions' generators. The unused Reset goes. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
d0782a7d14
commit
c0be2843ea
2 changed files with 8 additions and 9 deletions
|
|
@ -333,12 +333,13 @@ public class Galaxy
|
||||||
ref Random random,
|
ref Random random,
|
||||||
Action<string> progressCallback = null)
|
Action<string> progressCallback = null)
|
||||||
{
|
{
|
||||||
|
var used = new HashSet<string>();
|
||||||
for (var i = 0; i < Factions.Length; i++)
|
for (var i = 0; i < Factions.Length; i++)
|
||||||
{
|
{
|
||||||
progressCallback?.Invoke($"Feeding Markov Chains: {i + 1} / {Factions.Length}");
|
progressCallback?.Invoke($"Feeding Markov Chains: {i + 1} / {Factions.Length}");
|
||||||
//if(progressCallback!=null) Thread.Sleep(250); // Inserting Delay to make it seem like it's doing more work lmao
|
//if(progressCallback!=null) Thread.Sleep(250); // Inserting Delay to make it seem like it's doing more work lmao
|
||||||
var faction = Factions[i];
|
var faction = Factions[i];
|
||||||
_nameGenerators[faction] = new MarkovNameGenerator(ref random, cache.Get(faction.GeonameFile).Names, nameGeneratorSettings);
|
_nameGenerators[faction] = new MarkovNameGenerator(ref random, cache.Get(faction.GeonameFile).Names, nameGeneratorSettings, used);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Generate zone name using the owner's name generator, otherwise assign catalogue ID
|
// Generate zone name using the owner's name generator, otherwise assign catalogue ID
|
||||||
|
|
|
||||||
|
|
@ -14,14 +14,17 @@ public class MarkovNameGenerator
|
||||||
{
|
{
|
||||||
private Dictionary<string, List<char>> _chains = new Dictionary<string, List<char>>();
|
private Dictionary<string, List<char>> _chains = new Dictionary<string, List<char>>();
|
||||||
private List<string> _samples = new List<string>();
|
private List<string> _samples = new List<string>();
|
||||||
private static List<string> _used = 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 _order;
|
||||||
private int _minLength;
|
private int _minLength;
|
||||||
private int _maxLength;
|
private int _maxLength;
|
||||||
private Random _random;
|
private Random _random;
|
||||||
|
|
||||||
public MarkovNameGenerator(ref Random random, IEnumerable<string> sampleNames, NameGeneratorSettings settings)
|
public MarkovNameGenerator(ref Random random, IEnumerable<string> sampleNames, NameGeneratorSettings settings, HashSet<string> used)
|
||||||
{
|
{
|
||||||
|
_used = used;
|
||||||
var names = new HashSet<string>();
|
var names = new HashSet<string>();
|
||||||
foreach (var line in sampleNames)
|
foreach (var line in sampleNames)
|
||||||
{
|
{
|
||||||
|
|
@ -41,6 +44,7 @@ public class MarkovNameGenerator
|
||||||
|
|
||||||
public MarkovNameGenerator(ref Random random, IEnumerable<string> sampleNames, int order, int minLength, int maxLength)
|
public MarkovNameGenerator(ref Random random, IEnumerable<string> sampleNames, int order, int minLength, int maxLength)
|
||||||
{
|
{
|
||||||
|
_used = new HashSet<string>();
|
||||||
_random = random;
|
_random = random;
|
||||||
|
|
||||||
_order = max(1, order);
|
_order = max(1, order);
|
||||||
|
|
@ -113,12 +117,6 @@ public class MarkovNameGenerator
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//Reset the used names
|
|
||||||
public void Reset()
|
|
||||||
{
|
|
||||||
_used.Clear();
|
|
||||||
}
|
|
||||||
|
|
||||||
//Get a random letter from the chain
|
//Get a random letter from the chain
|
||||||
private char GetLetter(string token)
|
private char GetLetter(string token)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue