Improved Sector Map
Added Boss Icon Added Home Icon Added Legend Placing bosses at chokepoints Adjusted home zone placement Added per-faction areas of influence
This commit is contained in:
parent
f10804ac11
commit
7f3f198f61
29 changed files with 2936 additions and 308 deletions
|
|
@ -5,6 +5,7 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using static Unity.Mathematics.math;
|
||||
using Random = Unity.Mathematics.Random;
|
||||
|
||||
//Generates random names based on the statistical weight of letter sequences
|
||||
|
|
@ -18,20 +19,40 @@ public class MarkovNameGenerator
|
|||
private int _minLength;
|
||||
private int _maxLength;
|
||||
private Random _random;
|
||||
|
||||
public MarkovNameGenerator(ref Random random, string nameData, SectorGenerationSettings settings)
|
||||
{
|
||||
var names = new HashSet<string>();
|
||||
var lines = nameData.Split('\n');
|
||||
foreach (var line in lines)
|
||||
{
|
||||
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)
|
||||
{
|
||||
_random = random;
|
||||
//fix parameter values
|
||||
if (order < 1)
|
||||
order = 1;
|
||||
if (minLength < 1)
|
||||
minLength = 1;
|
||||
|
||||
_order = order;
|
||||
_minLength = minLength;
|
||||
_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)
|
||||
{
|
||||
|
|
@ -39,7 +60,7 @@ public class MarkovNameGenerator
|
|||
foreach (string word in tokens)
|
||||
{
|
||||
string upper = word.Trim().ToLowerInvariant();
|
||||
if (upper.Length < order + 1)
|
||||
if (upper.Length < _order + 1)
|
||||
continue;
|
||||
_samples.Add(upper + '|'); // Add end character
|
||||
}
|
||||
|
|
@ -48,9 +69,9 @@ public class MarkovNameGenerator
|
|||
//Build chains
|
||||
foreach (string word in _samples)
|
||||
{
|
||||
for (int letter = 0; letter < word.Length - order; letter++)
|
||||
for (int letter = 0; letter < word.Length - _order; letter++)
|
||||
{
|
||||
string token = word.Substring(letter, order);
|
||||
string token = word.Substring(letter, _order);
|
||||
List<char> entry = null;
|
||||
if (_chains.ContainsKey(token))
|
||||
entry = _chains[token];
|
||||
|
|
@ -59,7 +80,7 @@ public class MarkovNameGenerator
|
|||
entry = new List<char>();
|
||||
_chains[token] = entry;
|
||||
}
|
||||
entry.Add(word[letter + order]);
|
||||
entry.Add(word[letter + _order]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -75,7 +96,6 @@ public class MarkovNameGenerator
|
|||
{
|
||||
int n = _random.NextInt(0,_samples.Count);
|
||||
//int nameLength = _samples[n].Length;
|
||||
//s = _samples[n].Substring(UnityEngine.Random.Range(0, _samples[n].Length - _order), _order);//get a random token somewhere in middle of sample word
|
||||
s = _samples[n].Substring(0, _order);//get a random token at the start of a sample word
|
||||
while (true)//(s.Length < nameLength)
|
||||
{
|
||||
|
|
@ -86,11 +106,11 @@ public class MarkovNameGenerator
|
|||
else
|
||||
break;
|
||||
}
|
||||
s = s.Substring(0, 1) + s.Substring(1).ToLower();
|
||||
s = s.Substring(0, 1).ToUpper() + s.Substring(1);
|
||||
}
|
||||
while (_used.Contains(s) || s.Length < _minLength || s.Length > _maxLength);
|
||||
_used.Add(s);
|
||||
return s.First().ToString().ToUpper() + s.Substring(1);
|
||||
return s;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue