v1.4.4
This commit is contained in:
commit
9c94d113d3
10260 changed files with 1237388 additions and 0 deletions
42
source/game/StarNameGenerator.hpp
Normal file
42
source/game/StarNameGenerator.hpp
Normal file
|
@ -0,0 +1,42 @@
|
|||
#ifndef STAR_NAME_GENERATOR_HPP
|
||||
#define STAR_NAME_GENERATOR_HPP
|
||||
|
||||
#include "StarJson.hpp"
|
||||
#include "StarRandom.hpp"
|
||||
|
||||
namespace Star {
|
||||
|
||||
STAR_EXCEPTION(NameGeneratorException, StarException);
|
||||
|
||||
STAR_CLASS(PatternedNameGenerator);
|
||||
|
||||
struct MarkovSource {
|
||||
size_t prefixSize;
|
||||
size_t endSize;
|
||||
StringList starts;
|
||||
StringMap<StringList> chains;
|
||||
StringSet ends;
|
||||
};
|
||||
|
||||
class PatternedNameGenerator {
|
||||
public:
|
||||
PatternedNameGenerator();
|
||||
|
||||
String generateName(String const& rulesAsset) const;
|
||||
String generateName(String const& rulesAsset, uint64_t seed) const;
|
||||
String generateName(String const& rulesAsset, RandomSource& random) const;
|
||||
|
||||
private:
|
||||
String processRule(JsonArray const& rule, RandomSource& random) const;
|
||||
|
||||
bool isProfane(String const& name) const;
|
||||
|
||||
MarkovSource makeMarkovSource(size_t prefixSize, size_t endSize, StringList sourceNames);
|
||||
|
||||
StringMap<MarkovSource> m_markovSources;
|
||||
StringSet m_profanityFilter;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
Loading…
Add table
Add a link
Reference in a new issue