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:
Meta Vens 2026-10-03 20:45:26 +02:00
commit c0be2843ea
2 changed files with 8 additions and 9 deletions

View file

@ -14,14 +14,17 @@ public class MarkovNameGenerator
{
private Dictionary<string, List<char>> _chains = new Dictionary<string, List<char>>();
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 _minLength;
private int _maxLength;
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>();
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)
{
_used = new HashSet<string>();
_random = random;
_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
private char GetLetter(string token)
{