This little script was my first attempt at a random word generator. I developed it for my Python text adventure game ICE 404, because what good would trains be if they did not connect fun places to travel to? As I wanted to create something humorous rather than a realistic simulation, I decided to generate my own names (toponyms) for cities, towns, and villages.
For simplicity, I divided them into four parts:
<prefix> body + ending <suffix>
For example: <St.> Licht + hofen <an der Backe>
(“St. Lichthofen an der Backe”). While the body and ending would always be present, the prefix and suffix would only be included in 20% of the game’s stations, respectively. You can toy with the values yourself by using the prefix chance [%] and suffix chance [%] text boxes above. Over time, I collected more than 50 prefix words, 1800 body words, 470 endings, and 260 suffix words, with some help from friends. Theoretically, this allows for more than 45 billion permutations, considering all musician memorial stones as separate train stations.
The search for endings was largely based on Wikipedia, Google Maps, and some Autobahn trips, but almost anything could be used as a body word. The general rule is: the more embarrassing, the better. Perfect candidates are diminutives, bodily sounds and excretions, insults, or just typically German things. The list is still growing. Surprisingly often, the generator returns names of existing places, which can be attributed to the fact that I gave the common endings (such as stadt
or dorf
) a higher chance to be chosen.
Some care had to be taken at the “weld” of two joined body and ending words, for example, when two or more of the same letters clash. Because combinations like Sufffort
or Semmelsstätt
would likely be contracted to Suffort
and Semmelstätt
, respectively, the first letter of the ending is removed in this case. Similarly, when two vowels clash (even if they are different), they are usually contracted in natural language settings. For simplicity, I only remove the trailing vowel of the body word. For example, Klotzeow
becomes Klotzow
, or Schabeig
becomes Schabig
. Of course, these two systems are not failsafe but cover most cases of bad welding.
Leave a Reply