1use super::{Age, Gender, Generate, GenerateSimple};
2use rand::prelude::*;
3
4pub struct Ethnicity;
5
6impl GenerateSimple for Ethnicity {
7 fn syllable_fname_count_f() -> &'static [(u8, usize)] {
8 &[(2, 46), (3, 17), (4, 1)]
9 }
10
11 #[rustfmt::skip]
12 fn syllable_fname_first_f() -> &'static [(&'static str, usize)] {
13 &[
14 ("Kal", 2), ("Da", 2), ("Ba", 1), ("Bar", 1), ("Bel", 1), ("Dag", 1), ("Dor", 1),
15 ("Era", 1), ("Eu", 1), ("Fav", 1), ("Glen", 1), ("Gren", 1), ("Gris", 1), ("Ha", 1),
16 ("Hai", 1), ("Hel", 1), ("Hil", 1), ("Ja", 1), ("Ker", 1), ("Krys", 1), ("Le", 1),
17 ("Lher", 1), ("Mag", 1), ("Mak", 1), ("Mi", 1), ("Min", 1), ("Mo", 1), ("Mor", 1),
18 ("Net", 1), ("Nu", 1), ("Phos", 1), ("Ruu", 1), ("Sar", 1), ("Sin", 1), ("Su", 1),
19 ("Tam", 1), ("Thea", 1), ("Then", 1), ("Ti", 1), ("Tor", 1), ("Ty", 1), ("Ulko", 1),
20 ("Vei", 1), ("Vel", 1), ("Yan", 1), ("You", 1), ("Anag", 1), ("Ze", 1), ("Aug", 1),
21 ]
22 }
23
24 #[rustfmt::skip]
25 fn syllable_fname_last_f() -> &'static [(&'static str, usize)] {
26 &[
27 ("ra", 8), ("na", 5), ("da", 5), ("la", 4), ("ria", 2), ("ta", 2), ("ga", 1),
28 ("jit", 1), ("lah", 1), ("leen", 1), ("lia", 1), ("lynn", 1), ("mans", 1), ("mas", 1),
29 ("nee", 1), ("nel", 1), ("rek", 1), ("rys", 1), ("sey", 1), ("ther", 1), ("thmel", 1),
30 ("ti", 1), ("tie", 1), ("tryd", 1), ("ba", 1), ("win", 1), ("bet", 1), ("bia", 1),
31 ("der", 1), ("di", 1), ("dreth", 1),
32 ]
33 }
34
35 fn syllable_fname_count_m() -> &'static [(u8, usize)] {
36 &[(2, 274), (3, 36), (4, 3)]
37 }
38
39 #[rustfmt::skip]
40 fn syllable_fname_first_m() -> &'static [(&'static str, usize)] {
41 &[
42 ("Dor", 6), ("Ta", 5), ("Ha", 4), ("Thar", 4), ("Dur", 4), ("Kar", 3), ("Bo", 3),
43 ("Tor", 3), ("Da", 3), ("Ba", 3), ("Dar", 3), ("Har", 3), ("Ga", 3), ("Gar", 3),
44 ("Brue", 2), ("Mar", 2), ("Kur", 2), ("Ra", 2), ("Yon", 2), ("Tu", 2), ("Sa", 2),
45 ("Ni", 2), ("Stone", 2), ("Mo", 2), ("Be", 2), ("Ma", 2), ("Dun", 2), ("Na", 2),
46 ("Su", 2), ("Ka", 2), ("Hor", 2), ("Bol", 2), ("Gor", 2), ("Dag", 2), ("Grim", 2),
47 ("Ko", 2), ("Bor", 2), ("Jer", 2), ("Cy", 1), ("Crom", 1), ("Crag", 1), ("Beh", 1),
48 ("Ambe", 1), ("Cor", 1), ("Clan", 1), ("Fei", 1), ("Cin", 1), ("Esco", 1), ("Ele", 1),
49 ("Car", 1),
50 ]
51 }
52
53 #[rustfmt::skip]
54 fn syllable_fname_last_m() -> &'static [(&'static str, usize)] {
55 &[
56 ("gan", 4), ("gar", 4), ("den", 4), ("rin", 4), ("ryn", 3), ("lig", 3), ("nor", 3),
57 ("kin", 2), ("nos", 2), ("la", 2), ("dar", 2), ("der", 2), ("dor", 2), ("rim", 2),
58 ("zon", 2), ("ram", 2), ("rak", 2), ("ren", 2), ("lo", 2), ("wer", 2), ("go", 2),
59 ("thar", 2), ("kum", 2), ("ly", 2), ("ri", 2), ("co", 1), ("dio", 1), ("din", 1),
60 ("don", 1), ("cius", 1), ("bleth", 1), ("dik", 1), ("cil", 1), ("gle", 1), ("dek", 1),
61 ("char", 1), ("bit", 1), ("bas", 1), ("darm", 1), ("ger", 1), ("darl", 1), ("car", 1),
62 ("gen", 1), ("ghen", 1), ("ghor", 1), ("gin", 1), ("gis", 1), ("glak", 1), ("gel", 1),
63 ("gaur", 1),
64 ]
65 }
66
67 fn syllable_fname_count() -> &'static [(u8, usize)] {
68 &[(2, 335), (3, 56), (4, 5)]
69 }
70
71 #[rustfmt::skip]
72 fn syllable_fname_first() -> &'static [(&'static str, usize)] {
73 &[
74 ("Dor", 7), ("Ba", 5), ("Ta", 5), ("Da", 5), ("Ha", 5), ("Thar", 4), ("Tor", 4),
75 ("Dur", 4), ("Kar", 4), ("Stone", 3), ("Dag", 3), ("Dar", 3), ("Ga", 3), ("Mo", 3),
76 ("Su", 3), ("Gar", 3), ("Har", 3), ("Bo", 3), ("Dun", 2), ("Ti", 2), ("Stro", 2),
77 ("Brue", 2), ("Ree", 2), ("Ra", 2), ("Sa", 2), ("Bor", 2), ("Mar", 2), ("Na", 2),
78 ("Tu", 2), ("Yon", 2), ("Kol", 2), ("Ka", 2), ("Kur", 2), ("Ni", 2), ("Hor", 2),
79 ("Ja", 2), ("Gor", 2), ("Be", 2), ("Grim", 2), ("Kal", 2), ("Bol", 2), ("Ko", 2),
80 ("Ma", 2), ("Jer", 2), ("Pry", 2), ("Mi", 2), ("Cor", 1), ("Clan", 1), ("Bar", 1),
81 ("Cin", 1),
82 ]
83 }
84
85 #[rustfmt::skip]
86 fn syllable_fname_last() -> &'static [(&'static str, usize)] {
87 &[
88 ("ra", 8), ("na", 6), ("la", 6), ("da", 5), ("gan", 4), ("den", 4), ("gar", 4),
89 ("rin", 4), ("ryn", 3), ("der", 3), ("lig", 3), ("nor", 3), ("ri", 3), ("nos", 2),
90 ("ren", 2), ("ma", 2), ("dar", 2), ("zon", 2), ("rik", 2), ("ta", 2), ("rim", 2),
91 ("thar", 2), ("ram", 2), ("rak", 2), ("ria", 2), ("vin", 2), ("dor", 2), ("ly", 2),
92 ("nin", 2), ("kos", 2), ("go", 2), ("kin", 2), ("lah", 2), ("kum", 2), ("wer", 2),
93 ("lo", 2), ("dek", 1), ("car", 1), ("darm", 1), ("darl", 1), ("bul", 1), ("bert", 1),
94 ("dak", 1), ("bromm", 1), ("dai", 1), ("dagg", 1), ("bold", 1), ("beck", 1),
95 ("garl", 1), ("bald", 1),
96 ]
97 }
98
99 #[rustfmt::skip]
100 fn syllable_fname_middle() -> &'static [(&'static str, usize)] {
101 &[
102 ("da", 4), ("de", 3), ("no", 3), ("ro", 2), ("bul", 2), ("mo", 2), ("ra", 2), ("re", 2),
103 ("bel", 2), ("ri", 2), ("nab", 2), ("ham", 1), ("hed", 1), ("ke", 1), ("kil", 1),
104 ("knug", 1), ("ko", 1), ("li", 1), ("mi", 1), ("nar", 1), ("nel", 1), ("ner", 1),
105 ("pa", 1), ("ril", 1), ("rio", 1), ("ris", 1), ("rum", 1), ("run", 1), ("sen", 1),
106 ("sha", 1), ("shar", 1), ("ta", 1), ("tha", 1), ("ti", 1), ("tok", 1), ("var", 1),
107 ("wa", 1), ("wil", 1), ("zar", 1), ("zo", 1), ("zol", 1), ("bol", 1), ("bot", 1),
108 ("den", 1), ("der", 1), ("du", 1), ("fa", 1), ("gal", 1), ("gi", 1), ("Ha", 1),
109 ]
110 }
111
112 fn syllable_lname_count() -> &'static [(u8, usize)] {
113 &[(2, 166), (3, 108), (4, 15)]
114 }
115
116 #[rustfmt::skip]
117 fn syllable_lname_first() -> &'static [(&'static str, usize)] {
118 &[
119 ("Iron", 14), ("Stone", 13), ("al-", 0), ("Ham", 7), ("Bat", 6), ("Steel", 6),
120 ("Sil", 6), ("Bright", 4), ("Hill", 4), ("Storm", 3), ("Boul", 3), ("Thun", 3),
121 ("Strong", 3), ("Forge", 3), ("Grey", 3), ("Round", 3), ("Brawn", 2), ("Xun", 2),
122 ("Ur'", 2), ("Flame", 2), ("Fla", 2), ("Way", 2), ("Smoke", 2), ("Rock", 2),
123 ("Split", 2), ("Troll", 2), ("Lud", 2), ("Bloo", 2), ("Ho", 2), ("Me", 2), ("Har", 2),
124 ("Ha", 2), ("Hard", 2), ("Gold", 2), ("Brew", 2), ("Grim", 2), ("Black", 2),
125 ("Gra", 2), ("Gar", 2), ("High", 2), ("Iro", 2), ("Sto", 2), ("Mi", 2), ("Ri", 2),
126 ("Coo", 1), ("Coal", 1), ("Clan", 1), ("Chis", 1), ("Bra", 1), ("Ches", 1),
127 ]
128 }
129
130 #[rustfmt::skip]
131 fn syllable_lname_middle() -> &'static [(&'static str, usize)] {
132 &[
133 ("ham", 16), ("mer", 8), ("tle", 6), ("ver", 6), ("sha", 3), ("Ja", 3), ("Ha", 3),
134 ("shoul", 3), ("ter", 3), ("car", 3), ("an", 3), ("der", 2), ("ka", 2), ("crus", 2),
135 ("la", 2), ("per", 2), ("ea", 2), ("ton", 2), ("ra", 2), ("dy", 2), ("wa", 2),
136 ("see", 2), ("kin", 1), ("lair", 1), ("len", 1), ("low", 1), ("mar", 1), ("mes", 1),
137 ("mo", 1), ("ne", 1), ("nes", 1), ("nest", 1), ("nite", 1), ("no", 1), ("nug", 1),
138 ("ped", 1), ("plit", 1), ("rel", 1), ("ron", 1), ("shat", 1), ("sin", 1), ("sing", 1),
139 ("smel", 1), ("sprin", 1), ("stea", 1), ("sun", 1), ("thral", 1), ("thro", 1),
140 ("Thu", 1), ("tles", 1),
141 ]
142 }
143
144 #[rustfmt::skip]
145 fn syllable_lname_last() -> &'static [(&'static str, usize)] {
146 &[
147 ("mer", 16), ("beard", 14), ("shield", 12), ("fist", 11), ("der", 7), ("ver", 5),
148 ("helm", 5), ("hand", 5), ("ter", 5), ("ri", 4), ("ker", 4), ("bar", 4), ("stone", 3),
149 ("skull", 3), ("vil", 3), ("fell", 2), ("dark", 2), ("gray", 2), ("wer", 2),
150 ("dow", 2), ("stream", 2), ("tar", 2), ("steel", 2), ("zar", 2), ("blade", 2),
151 ("dorn", 2), ("sonn", 2), ("naxe", 2), ("smith", 2), ("ler", 2), ("her", 2),
152 ("lin", 2), ("den", 2), ("forge", 2), ("gue", 2), ("gar", 2), ("ma", 2), ("ger", 2),
153 ("far", 1), ("daxe", 1), ("fall", 1), ("duum", 1), ("bold", 1), ("dson", 1),
154 ("drun", 1), ("chasm", 1), ("grym", 1), ("grin", 1), ("grim", 1), ("cap", 1),
155 ]
156 }
157
158 fn compound_word_probability() -> f64 {
159 0.323943661971831
160 }
161
162 #[rustfmt::skip]
163 fn word_lname_first() -> &'static [(&'static str, usize)] {
164 &[
165 ("Stone", 13), ("Hammer", 7), ("Iron", 7), ("Steel", 5), ("Grey", 3), ("Silver", 3),
166 ("Strong", 3), ("Hill", 3), ("Forge", 3), ("Battle", 3), ("Hard", 2), ("Bright", 2),
167 ("Boulder", 2), ("Grim", 2), ("Gold", 2), ("Troll", 2), ("Rock", 2), ("Split", 2),
168 ("Flame", 2), ("Smoke", 2), ("Storm", 2), ("Flagon", 1), ("Flames", 1), ("Foe", 1),
169 ("Fork", 1), ("Fray", 1), ("Frost", 1), ("Gar", 1), ("Gems", 1), ("Giant", 1),
170 ("Glitter", 1), ("Gloom", 1), ("Granite", 1), ("Gravel", 1), ("Gray", 1),
171 ("Grizzle", 1), ("High", 1), ("Hills", 1), ("Honest", 1), ("Ink", 1), ("Irons", 1),
172 ("Mane", 1), ("Moon", 1), ("Muffin", 1), ("One", 1), ("Pebble", 1), ("Pure", 1),
173 ("Red", 1), ("Rising", 1), ("Round", 1),
174 ]
175 }
176
177 #[rustfmt::skip]
178 fn word_lname_last() -> &'static [(&'static str, usize)] {
179 &[
180 ("beard", 13), ("hammer", 10), ("shield", 9), ("fist", 5), ("hand", 5), ("helm", 3),
181 ("anvil", 2), ("seeker", 2), ("tar", 2), ("crus", 2), ("tongue", 2), ("shoulder", 2),
182 ("fell", 2), ("skull", 2), ("dark", 2), ("smith", 2), ("her", 2), ("steel", 2),
183 ("blade", 2), ("stone", 2), ("carver", 2), ("gold", 1), ("grin", 1), ("guard", 1),
184 ("hall", 1), ("head", 1), ("heart", 1), ("hewer", 1), ("ira", 1), ("ire", 1),
185 ("jaw", 1), ("killer", 1), ("kin", 1), ("layer", 1), ("less", 1), ("marrow", 1),
186 ("mind", 1), ("mover", 1), ("night", 1), ("nugget", 1), ("one", 1), ("peddler", 1),
187 ("rut", 1), ("scar", 1), ("shadow", 1), ("shatter", 1), ("shorn", 1), ("singer", 1),
188 ("smelter", 1), ("springer", 1),
189 ]
190 }
191}
192
193impl Generate for Ethnicity {
194 fn gen_name(rng: &mut impl Rng, _age: &Age, gender: &Gender) -> String {
195 format!(
196 "{} {}",
197 Self::gen_fname_simple(rng, gender),
198 Self::gen_lname_simple(rng),
199 )
200 }
201}
202
203#[cfg(test)]
204mod test {
205 use super::*;
206 use crate::world::npc::ethnicity::{test_utils as test, Ethnicity};
207
208 use Age::Adult;
209 use Ethnicity::Dwarvish;
210 use Gender::{Feminine, Masculine, NonBinaryThey};
211
212 #[test]
213 fn gen_name_test() {
214 let mut rng = SmallRng::seed_from_u64(0);
215
216 assert_eq!(
217 [
218 "Gargel Xunterler",
219 "Escokum Moonshield",
220 "Tileen Ironhand",
221 "Torketryd Muffinshield",
222 "Nalig Flamehewer",
223 "Turyn Stonesmelshield",
224 ],
225 [
226 test::gen_name(&mut rng, Dwarvish, Adult, Masculine),
227 test::gen_name(&mut rng, Dwarvish, Adult, Masculine),
228 test::gen_name(&mut rng, Dwarvish, Adult, Feminine),
229 test::gen_name(&mut rng, Dwarvish, Adult, Feminine),
230 test::gen_name(&mut rng, Dwarvish, Adult, NonBinaryThey),
231 test::gen_name(&mut rng, Dwarvish, Adult, NonBinaryThey),
232 ],
233 );
234 }
235}