Skip to content

Commit 8e94a9e

Browse files
committed
chiss
1 parent 4f9869a commit 8e94a9e

File tree

6 files changed

+99
-0
lines changed

6 files changed

+99
-0
lines changed

CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ add_executable(namgen
6161
src/harry_potter-goblins_lib.cpp
6262
src/eve_online-gallentes_lib.cpp
6363
src/star_wars_the_old_republic-cathars_lib.cpp
64+
src/star_wars_the_old_republic-chiss_lib.cpp
6465
src/military-royal_navy_lib.cpp
6566
src/towns_and_cities-west_european_towns_lib.cpp
6667
src/places-plazas_lib.cpp

score.csv

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,3 +20,4 @@ guild_wars-sylvaris,aider-ce,nous-hermes2:latest,udiff,2025-12-13-20:09:49,17656
2020
pets-elephants,aider,llama3.2:latest,diff-fenced,2025-12-14-04:35:17,1765708517,855.197293479,0,interrupt-fail
2121
star_wars_the_old_republic-mirialans,aider,llama3.2:latest,diff-fenced,2025-12-14-05:51:10,1765713070,150.490844468,0,initial-fail
2222
star_wars_the_old_republic-mirialans,aider,llama3.2:latest,diff-fenced,2025-12-14-06:07:25,1765714045,1133.468466859,0,interrupt-fail
23+
star_wars_the_old_republic-chiss,cecli,DeepSeek-R1:70b,diff-fenced,2025-12-14-04:47:19,1765709239,437.336228477,0,initial-fail

src/namgen.cpp

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@
7070
#include "game_of_thrones-dothrakis_lib.h"
7171
#include "eve_online-gallentes_lib.h"
7272
#include "star_wars_the_old_republic-cathars_lib.h"
73+
#include "star_wars_the_old_republic-chiss_lib.h"
7374
#include "places-plazas_lib.h"
7475
#include "dragon_age-dwarfs_lib.h"
7576
#include "pets-reptiles_lib.h"
@@ -276,6 +277,7 @@ struct CommandLineOptions {
276277
bool harryPotterGoblins = false;
277278
bool eveOnlineGallentes = false;
278279
bool starWarsTheOldRepublicCathars = false;
280+
bool starWarsTheOldRepublicChiss = false;
279281
bool militaryRoyalNavy = false;
280282
bool placesPlazas = false;
281283
bool dragonAgeDwarfs = false;
@@ -582,6 +584,8 @@ int main(int argc, char* argv[]) {
582584
opts.eveOnlineGallentes = true;
583585
} else if (arg == "--star_wars_the_old_republic-cathars") {
584586
opts.starWarsTheOldRepublicCathars = true;
587+
} else if (arg == "--star_wars_the_old_republic-chiss") {
588+
opts.starWarsTheOldRepublicChiss = true;
585589
} else if (arg == "--military-royal_navy") {
586590
opts.militaryRoyalNavy = true;
587591
} else if (arg == "--dragon_age-dwarfs") {
@@ -658,6 +662,7 @@ int main(int argc, char* argv[]) {
658662
std::cout << " --pets-reptiles Generate reptile pet names (legacy JS generator)\\n";
659663
std::cout << " --rift-bahmis Generate a Rift‑Bahmis name (uses built‑in generator)\\n";
660664
std::cout << " --star_wars_the_old_republic-cathars Generate Cathars style names (uses built‑in generator)\\n";
665+
std::cout << " --star_wars_the_old_republic-chiss Generate Chiss style names (uses built‑in generator)\\n";
661666
std::cout << " --towns_and_cities-dwarven_citys Generate dwarven city names (towns_and_cities‑dwarven_citys)\\n";
662667
std::cout << " --towns_and_cities-east_european_towns Generate East European Towns and Cities\\n";
663668
std::cout << " --warhammer-daemons_of_chaos Generate Warhammer “Daemons of Chaos” style names (uses built‑in generator)\\n";
@@ -1044,6 +1049,19 @@ int main(int argc, char* argv[]) {
10441049
continue;
10451050
}
10461051

1052+
if (opts.starWarsTheOldRepublicChiss) {
1053+
std::string chissName = generate_star_wars_the_old_republic_chiss_name(rng);
1054+
if (optDebug) {
1055+
printGeneratedName(chissName, countzero, counto,
1056+
fs::path(), fs::path(),
1057+
fs::path(), fs::path(),
1058+
""); // no separator
1059+
} else {
1060+
std::cout << chissName << "\n";
1061+
}
1062+
continue;
1063+
}
1064+
10471065
if (opts.militaryRoyalNavy) {
10481066
std::string militaryRoyalNavyName = generate_military_royal_navy_name(rng);
10491067
if (optDebug) {
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
#include <vector>
2+
#include <string>
3+
#include <random>
4+
#include <algorithm>
5+
#include "star_wars_the_old_republic-chiss_lib.h"
6+
7+
// The name parts for the Chiss generator. These are taken directly from the
8+
// original implementation; they are kept unchanged except for the bug‑fix
9+
// below.
10+
static const std::vector<std::string> nm1 = {"B", "C", "D", "G", "H", "J", "K", "M", "N", "P", "R", "S", "T", "V", "W", "Z"};
11+
static const std::vector<std::string> nm2 = {"a", "e", "u", "i", "o", "a", "e", "u", "i", "o", "ra", "re", "ru", "ri", "ro", "la", "le", "lu", "li", "lo"};
12+
static const std::vector<std::string> nm3 = {"th", "tth", "tt", "s", "ss", "sh", "st", "sd", "g", "gh", "w", "q", "qh", "r", "rr", "rs", "rt", "rd", "rg", "rk", "rm", "rn", "c", "rc", "sk", "z", "zz", "m", "mm", "n", "ng"};
13+
static const std::vector<std::string> nm4 = {"i", "a", "o", "e", "u", "", "", "", "", "", "", "", ""};
14+
static const std::vector<std::string> nm5 = {"b","c","d","g","h","m","n","l","p","r","s","t","v","w","z","b","c","d","g","h","m","n","l","p","r","s","t","v","w","z","ab","ac","ad","ag","ah","am","an","al","ap","ar","as","at","av","aw","az","ob","oc","od","og","oh","om","on","ol","op","or","os","ot","ov","ow","oz","ib","ic","id","ig","ih","im","in","il","ip","ir","is","it","iv","iw","iz","eb","ec","ed","eg","eh","em","en","el","ep","er","es","et","ev","ew","ez"};
15+
static const std::vector<std::string> nm6 = {"a","e","u","i","o","a","e","u","i","o","ae","ea","au","ua","ao","oa","ou","uo","ia","ai"};
16+
static const std::vector<std::string> nm7 = {"n","t","th","w","l","m","sh","s","k","w","z","r"};
17+
static const std::vector<std::string> nm8 = {"i","a","o","e","u","","","","","","","","",""};
18+
static const std::vector<std::string> nm9 = {"b","c","d","f","g","h","k","l","m","n","p","r","s","t","v","z","","","","","","","","","",""};
19+
static const std::vector<std::string> nm10 = {"a","e","u","i","o","a","e","u","i","o","ra","re","ru","ri","ro","la","le","lu","li","lo","ae","ea","au","ua","ao","oa","ou","uo","ia","ai"};
20+
static const std::vector<std::string> nm11 = {"th","tth","tt","s","s","s","g","g","r","r","c","c","m","m","n","n","z","z","ss","sh","st","sd","g","gh","w","q","qh","r","rr","rs","rt","rd","rg","rk","rm","rn","c","rc","sk","z","zz","m","mm","n","ng"};
21+
static const std::vector<std::string> nm12 = {"i","a","o","e","u"};
22+
static const std::vector<std::string> nm13 = {"th","tth","tt","s","s","s","g","g","r","r","c","c","m","m","n","n","z","z","ss","sh","st","sd","g","gh","w","q","qh","r","rr","rs","rt","rd","rg","rk","rm","rn","c","rc","sk","z","zz","m","mm","n","ng","","","","","","','','','','','','','','','','','','','','','','','','','','','','','','','','"};
23+
static const std::vector<std::string> nm14 = {"i","a","o","e","u","","","","","","","","","","","","","","","","","","","","","","","","","","","","","",""};
24+
25+
/**
26+
* @brief Generate a single Chiss name.
27+
*
28+
* The original implementation mistakenly used a single random index (`rnd`)
29+
* for *all* of the name parts, which caused out‑of‑bounds accesses when the
30+
* random value was larger than the size of some of the vectors. The fix
31+
* is to use a distinct random index for each vector (rnd1 … rnd14).
32+
*
33+
* @param rng A reference to a seeded std::mt19937 random number generator.
34+
* @return A generated Chiss name.
35+
*/
36+
std::string generate_star_wars_the_old_republic_chiss_name(std::mt19937& rng) {
37+
// Generate a random index for each name‑part vector.
38+
const int rnd1 = std::uniform_int_distribution<int>(0, static_cast<int>(nm1.size()) - 1)(rng);
39+
const int rnd2 = std::uniform_int_distribution<int>(0, static_cast<int>(nm2.size()) - 1)(rng);
40+
const int rnd3 = std::uniform_int_distribution<int>(0, static_cast<int>(nm3.size()) - 1)(rng);
41+
const int rnd4 = std::uniform_int_distribution<int>(0, static_cast<int>(nm4.size()) - 1)(rng);
42+
const int rnd5 = std::uniform_int_distribution<int>(0, static_cast<int>(nm5.size()) - 1)(rng);
43+
const int rnd6 = std::uniform_int_distribution<int>(0, static_cast<int>(nm6.size()) - 1)(rng);
44+
const int rnd7 = std::uniform_int_distribution<int>(0, static_cast<int>(nm7.size()) - 1)(rng);
45+
const int rnd8 = std::uniform_int_distribution<int>(0, static_cast<int>(nm8.size()) - 1)(rng);
46+
const int rnd9 = std::uniform_int_distribution<int>(0, static_cast<int>(nm9.size()) - 1)(rng);
47+
const int rnd10 = std::uniform_int_distribution<int>(0, static_cast<int>(nm10.size()) - 1)(rng);
48+
const int rnd11 = std::uniform_int_distribution<int>(0, static_cast<int>(nm11.size()) - 1)(rng);
49+
const int rnd12 = std::uniform_int_distribution<int>(0, static_cast<int>(nm12.size()) - 1)(rng);
50+
const int rnd13 = std::uniform_int_distribution<int>(0, static_cast<int>(nm13.size()) - 1)(rng);
51+
const int rnd14 = std::uniform_int_distribution<int>(0, static_cast<int>(nm14.size()) - 1)(rng);
52+
53+
// Assemble the name. The original format inserts an apostrophe after the
54+
// fourth and eighth parts.
55+
return nm1[rnd1] + nm2[rnd2] + nm3[rnd3] + nm4[rnd4] + "'" +
56+
nm5[rnd5] + nm6[rnd6] + nm7[rnd7] + nm8[rnd8] + "'" +
57+
nm9[rnd9] + nm10[rnd10] + nm11[rnd11] + nm12[rnd12] + nm13[rnd13] + nm14[rnd14];
58+
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#ifndef STAR_WARS_THE_OLD_REPUBLIC_CHISS_LIB_H
2+
#define STAR_WARS_THE_OLD_REPUBLIC_CHISS_LIB_H
3+
4+
#include <string>
5+
#include <random>
6+
7+
/**
8+
* @brief Generate a single Chiss name.
9+
*
10+
* The implementation resides in `star_wars_the_old_republic-chiss_lib.cpp`.
11+
*
12+
* @param rng A reference to a seeded std::mt19937 random number generator.
13+
* @return A generated Chiss name.
14+
*/
15+
std::string generate_star_wars_the_old_republic_chiss_name(std::mt19937& rng);
16+
17+
#endif // STAR_WARS_THE_OLD_REPUBLIC_CHISS_LIB_H

test/full.bats

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -335,3 +335,7 @@ setup() {
335335
result="$(counto=10 ./namgen --descriptions-prophecys|wc -l)"
336336
[[ "$result" -eq 80 ]]
337337
}
338+
@test "test namgen --star_wars_the_old_republic-chiss at 10" {
339+
result="$(counto=10 ./namgen --star_wars_the_old_republic-chiss|wc -l)"
340+
[[ "$result" -eq 10 ]]
341+
}

0 commit comments

Comments
 (0)