Package squidpony
Class WeightedLetterNamegen
java.lang.Object
squidpony.WeightedLetterNamegen
public class WeightedLetterNamegen extends Object
Based on work by Nolithius available at the following two sites
https://github.com/Nolithius/weighted-letter-namegen
http://code.google.com/p/weighted-letter-namegen/
- Author:
- Eben Howard - http://squidpony.com - howard@squidpony.com
- See Also:
FakeLanguageGen is meant for generating more than just names, and can imitate language styles.
-
Field Summary
Fields Modifier and Type Field Description static String[]
COMMON_USA_FEMALE_NAMES
static String[]
COMMON_USA_LAST_NAMES
static String[]
COMMON_USA_MALE_NAMES
static String[]
LOVECRAFT_MYTHOS_NAMES
static String[]
STAR_WARS_STYLE_NAMES
static String[]
VIKING_STYLE_NAMES
-
Constructor Summary
Constructors Constructor Description WeightedLetterNamegen(String[] names)
Creates the generator by seeding the provided list of names.WeightedLetterNamegen(String[] names, int consonantLimit)
Creates the generator by seeding the provided list of names.WeightedLetterNamegen(String[] names, int consonantLimit, IStatefulRNG rng)
Creates the generator by seeding the provided list of names. -
Method Summary
Modifier and Type Method Description String
generate()
Gets one random String name.String[]
generate(int amountToGenerate)
Gets an array of random String names, sized to match amountToGenerate.ArrayList<String>
generateList(int amountToGenerate)
Gets an ArrayList of random String names, sized to match amountToGenerate.
-
Field Details
-
Constructor Details
-
WeightedLetterNamegen
Creates the generator by seeding the provided list of names.- Parameters:
names
- an array of Strings that are typical names to be emulated
-
WeightedLetterNamegen
Creates the generator by seeding the provided list of names.- Parameters:
names
- an array of Strings that are typical names to be emulatedconsonantLimit
- the maximum allowed consonants in a row
-
WeightedLetterNamegen
Creates the generator by seeding the provided list of names. The given RNG will be used for all random decisions this has to make, so if it has the same state (and RandomnessSource) on different runs through the program, it will produce the same names reliably.- Parameters:
names
- an array of Strings that are typical names to be emulatedconsonantLimit
- the maximum allowed consonants in a rowrng
- the source of randomness to be used
-
-
Method Details
-
generate
Gets one random String name.- Returns:
- a single random String name
-
generateList
Gets an ArrayList of random String names, sized to match amountToGenerate.- Parameters:
amountToGenerate
- how many String items to include in the returned ArrayList- Returns:
- an ArrayList of random String names
-
generate
Gets an array of random String names, sized to match amountToGenerate.- Parameters:
amountToGenerate
- how many String items to include in the returned array- Returns:
- an array of random String names
-