*MOD IDEA* Enchanced Name Generator?

Well, OK. I try to explain what I want to achieve. Sorry for my English by the way :wink:

1. Why?
Because I want to create something, what may be useable for some Stonehearth fans.

2.How it will work?
For the moment, current name generator gives us 198 male and 216 female names (all firstname+lastname combinations included). If you have luck, you may have 2 villagers with the same name already in this starting group. When ways to add another villagers will be aded to the game, some players may end for example with tons of villagers called ā€œBrom Burlyhandsā€.

One of the ways to expand the list is adding more names into the list. The most brute-forcing way though, which in latter parts may expand namefile drastically.

Other idea (that one I want to achieve) will modify this a little ā†’ just changing actual system

FirstName LastName

to

FirstAFirstB LastALastB

may both expand the available list of names and give us the more interesting one.
You want examples? OK - There are some names, which may be get by splitting (almost all) default Ascendancy male names into 2 parts and randomly getting each part: ā€œBromtor Beressaā€, ā€œGarwyn Keerā€, ā€œIrtor Northwellā€, ā€œCamplad Jonlochā€, ā€œNolving Wintooseā€, ā€œIlloff Carriderā€ ā€¦ Sometimes we may get some funny/punny names by the way :wink:

3. Actual problems

  • My lack of LUA scripting ability. I am normally working in PHP and sometimes in Delphi.
  • Problem to check idea in action (after applying the modification, villagers are not spawningā€¦)
    4. Where it may be useable?
    4.1. Nihonjin mod
    Source no. 1: Japanese name - Wikipedia
    According to Wiki, there are over 200ā€™000 surnames in Japan. If you want to add them in actual systemā€¦ prepare for large files. :stuck_out_tongue:

Also, this type of generator may be useable in any fantasy-like mod

3 Likes

This is a great idea, I wish you best of luck !

There are multiple ways to achieve what you want. For a very simple firstfirst lastlast, Iā€™ve written a mod that does just that using my RP framework. Of course, this breaks the GUI with the normal names (as example, ā€˜Sennalaina Baubbrightwellā€™, ā€˜Elenaleah Northpointhuntertonā€™, ā€˜Garethdaff Berallkelochā€™ā€¦).

If you were to introduce a new faction for your mod (which I guess you would do), you could define your own naming generator (basically, Iā€™ve overwritten the default generator - feel free to unzip it and check the lua) just for your faction. That means each faction could have completely different naming. It does not need to follow any rule that the default one is following - get as creative as you can be! Itā€™s not very hard either. A bit hacky perhaps but I think itā€™s still very well within what we should be doing.

2 Likes

Donā€™t worry, I have already prepared files for each of the default civs :stuck_out_tongue:.
My idea is to have generator like [firststart][firstend] [laststart][lastend]. Simple, 2 parts for the first name and for the last name

Very interesting concept. I know a little about Japanese names but Iā€™m not a master at how they are formed. Iā€™ll have to do some more in depth research. The wiki page you linked to is a nice start. :wink:

Just curious: Would there be a way of making it so the mod can also choose from a list of pre made names? Just for example say you want the name Tim in the game but donā€™t want an ending tacked onto it but still want the name generator to create names such as Bromtor Beressa?

At the moment names should be western-stylized though, but you will propably find the way to switch them :wink:

You know, generating japanese names is like building with Lego blocks :stuck_out_tongue:

So you would have two lists for each part, right? So your json could look like this:

{
	"male" : {
		"first_name_1" : [
			"Sumi",
			"San"
		],
		
		"first_name_2" : [
			"masen",
			"hai"
		],
	},
	
	"female" : {
		"first_name_1" : [
			"..."
		],
		
		"first_name_2" : [
			"..."
		]
	},
	
	"surnames" : {
		"first_part" : [
			"Octo"
		],
		
		"last_part" : [
			"cat"
		]
	}
}

It would require very little adaption in the code to make that work (for things like ā€œSumimasen Octocatā€ as example). You would simply need to rewrite the same function, but this time like this:

local faction = api.population:get_faction("civ", "stonehearth:factions:ascendancy")

local function getRandom(names)
	return names[math.random(#names)]
end

function faction:generate_random_name(gender)
	local names = self._data[gender]

	local surnames = self._data.surnames
	
	return getRandom(names.first_name_1) .. getRandom(names.first_name_2) .. ' ' .. getRandom(surnames.first_part) .. getRandom(surnames.last_part)
end

Itā€™s not that big of a deal; of course you could also do this with multiple files instead of one. But then youā€™d have to load them yourself (which is not that much of a big deal, but less comfy than letting Stonehearth do it for you).

@Avairian: Yepp. My approach here would use one json file, but technically you could use whatever you want (which does not need to be json - for a pure list, a simple text file might be easier, but I havenā€™t looked into other resources.* functions yet.)

2 Likes

indeed! @RepeatPan has gone into much more helpful detail, but effectively the same logic that can randomly generate a name, concatenating ā€œfirstā€ and ā€œlastā€ pieces together, can also (randomly) simply grab (only) either orā€¦

meaning, each time you generate a unitā€™s name in game, there could be a % chance that the name will be created via the more intricate method of piecing together first and last namesā€¦ while there will also be a % chance of having a unit with only a first name (Tim), or perhaps only a last name (Jones)ā€¦

Heh, looks like you made my idea, @RepeatPan . :stuck_out_tongue:

The easiest way to do that (written in pseudocode)

local gencode = random() % 100
if gencode <=[PropabilityOfFirstMethod] {
return [firststart][firstend]
} elseif gencode <= [PropabilityOfSecondMethod] {
return [laststart][lastend]
} else return [firststart][firstend] [laststart][lastend]
1 Like

If you take a look at the current mergename.lua from my repos, youā€™ll see that Iā€™ve added (commented out) code for exactly this occasion ;). Itā€™s using a simple list with pre-defined names, but the getRandom(names) could easily be replaced with getRandomName(names).

2 Likes

Now we may only add option to have name tables directly in mod and weā€™re set :slight_smile:

It is already possible. The things you would need to do are quite simple-ish, assuming youā€™re really going for a new faction:

  • Manage the game so that your faction instead of the normal one is loaded. The easiest way to do that would be to proxy Population:get_faction. Have it ignore the second argument (usually ā€œstonehearth:faction:ascendancyā€) and instead call the original function with your faction name (i.e. ā€œyour_mod_here:faction:your_faction_name_hereā€).
  • Add the faction name above ("ā€¦:faction:ā€¦ thing") to the manifest, pointing to a json that is either similar to the existing one or fits your requirements.
  • Youā€™re done. Stonehearth should now load your factionā€™s file instead of the original one. If you have overloaded your factionā€™s generate_name, it should properly load.

I can make an example mod for you (using RP of course) that takes care of that. I just need you to provide me a json in this format (should be fairly obvious). The format has following advantages:

  • Multipart names are optional, i.e. surnames could be a simple, static list.
  • Multipart names can have more than two parts, with optional chances (for example, you could add an ending that only appears in about 10% of the populace)
  • Surnames can be gender-related too, in case they arenā€™t thereā€™s a _default fallback.

So, with a fitting json I could probably give you something like that. :wink:

2 Likes

Like this? Iā€™ve made one for Ascendancy faction at the moment (exams have started on my uni, so I donā€™t have much time to do rest atm). But I will create that file for rest available factions ( + Nihonjin and any other interested) ASAP.

Yupp, looks proper. As soon as Iā€™ve pushed rp_spawnstuff Iā€™ll start working on it. :slight_smile:

Ok, letā€™s back to learning for tommorow exam. After thise exam I hope Iā€™ll do both Rayyas Children and Northern Alliance name lists.

Nihonjin name list will be quite larger and more interesting to do, so Iā€™ll spend some time in weekend for it. Is it okay, @Avairian? :slight_smile:

At the moment is available to get first name like ā€˜Seethā€™. Two options:

  • leave it as is
  • deal with it (add a little checking to avoid duplicating: last letter of first part and first letter of last part)
1 Like

Sounds good! Iā€™m really liking the progress being made on the name generator systems. The conversation about the code is extreamly interesting. I donā€™t know exactly whatā€™s going on in the code but its giving me a clue at how lua works. :smile:

Have a list of thousand generated names. I took the liberty of adding a few rare pre- and postfixes (such as Duke, Count and Dark Lord of All). You can find the repository with the current source here and the smod ready for download here.

1 Like

Heh, I see some punny names, I see some punny names! :smiley:

Lena Nohands
Broman Bolloch
Garlad Nowine

In current version (v1?) Mario, Daren, Len are female names. Len is functioning in both genders in Japan (for example), but I am now thinking about improving the *.json file.

But now when we have interesting names of villagers, we may start letā€™s playing :smiley:

Good there is on GitHub. Iā€™ve got account here, so looks like i could editā€¦ or couldnā€™t?

EDIT:
I am making first, basic version of Nihonjin namelist and I find one problemā€¦ and possible solution to it :stuck_out_tongue:

Problem: Better to write an example: Ku + tou = Kudou, Shin + hachi = Shinpachi,
Shin + tou = Shindou (do not mistake with Shintō [Shintoism] )
etc. There are some rules in japanese (and in others languages too propably), which are changing the ā€˜readingā€™ a little to make the word easier to speak.

Solution: maybe there will be needed also a table with ā€˜changesā€™ written like, which will be applied if some strings will be found. It may be useable also in other civs.

"ut":"ud",
"nt":"nd"

Yepp, you can (and you did)! Iā€™ve merged your pull request into the main branch. Thanks for participating!

The current data format is a bit of a mess. Iā€™ll have to think about a better way to organize the json in order to allow this. But the idea is good - Iā€™ll certainly add it, along with an option to choose which json file you wish to load (since youā€™ve now provided the nihonjin parts as well, I might as well turn them into something useful ;))

I made an experimental form based off raw consonants and vowels but it had issues, It has a tendency to produce names like Pbouchchm Nkrioj, technically pronounceable with a bit of thought but seriously stupid. Would either of you have any ideas on how to enforce structure in the names? Currently itā€™s just a pretty random thing designed to enforce pronounceable names. If there was a working version and it could be made to work for varying things then we could get very varied names, all weā€™d need to do is make them fit a theme.