*MOD IDEA* Enchanced Name Generator?


#1

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


RP and RepeatPan's mods
#2

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


#3

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.


#4

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


#5

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?


#6

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:


#7

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.)


#8

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)…


#9

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]

#10

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).


#11

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


#12

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:


#13

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.


#14

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


#15

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)

#16

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:


#17

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.


#18

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"

#19

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 ;))


#20

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.