Seeing Names, Changing Dialect, Sentence Generation

Since last week we had a post about my third bullet hell world record high score instead of an URRpdate, this week’s should be the longest in quite some time! Lots has happened in terms of naming NPCs, fixing remaining bugs, changing the player’s dialect in a conversation, and also sentence generation is now actually happening! Most exciting. Read on…

Wikipedia

…but wait! One tangential thing first. A while ago a URR fan made a URR Wikipedia page, which can be found here. I’m very happy with how the page looks, and I see it expanding soon with the release of 0.8 and several books and book chapters coming out in the near future (written by me, and by others) that discuss URR, but that label at the top has been there for some time. Naturally, as the game’s developer, I have an obvious conflict of interest, but for those of you who read the blog and are Wikipedians – if you, in your neutral opinion, think the article is good enough to have the banner removed, is there a process for this? Or with some more references added if that’s what it needs? If someone feels it can be taken down, or can give me advice on what I might need to add, that would be fantastic. I get a substantial amount of traffic from the Wikipedia page so I want to ensure it’s as high a quality as possible. And, of course, it’s a very pleasing mark of legitimacy/relevance to have a Wikipedia page, so it definitely matters to me that the page represents the game well and “deserves” its place on Wikipedia.

capain

Names in Conversations

As well as being generated, names now appear correctly in conversations. In future versions you will naturally not automatically know the names of strangers you bump into – unlike certain RPGs we could mention where the player magically divines the names of every single you talk to – and learning someone’s name will therefore sometimes be a gameplay mechanic. You might, for instance, know that a particular merchant called [Name] knows something, but the civilization that merchant comes from are not particular friendly to you, and you don’t know what they sell, so you’ll have to try to figure out which of seven merchants in a market district the particular merchant you’re after is, and potentially use other clues (sex, clothing, behaviour, whatever). Equally, of course, the game will remember perfectly the names of everyone you meet, and I’m actually thinking of a system that might alert you when you encounter someone whose name you already know – perhaps a message in the text log saying “You see [Name] [doing task X]” for someone you already know, because there is no visual way to mark out someone you recognise from someone you don’t (i.e. two merchants will both be ‘m’ whether you know them or not). Here are a couple of screenshots showing some conversation windows with people from various name-types:

Name1 Name2

Name3

Changing Dialect

You can now actually change your dialect by selecting a different dialect. This is a small thing, but it required me to start building up the code for handling what happens when you press [Enter] on an option in an in-conversation window, and it therefore has to detect the sentence or the item or the dialect you select, and then notice what kind of thing it is the player has selected, and then take the appropriate action. This works correctly now, though, so you can switch to another dialect and all the % chances of uttering each possible sentence immediately update appropriately. You can see in this gif how the chances of successful/unsuccessful words changes as we change dialect from one to the other.

Dialects

Sentence Generation (Part I)

After thinking long and hard about sentence generation, and managing to free up a spare day to do nothing else except working on this, I’ve been able to make a substantial start. So, basically, the game splits sentences down into three categories, I’m naming “clauses“, “archetypes“, and “kennings” (which applies to a range of things that are not technically kennings, but the term gives us a good impression of what we’re talking about here).

Clauses: these are segments of a sentence, which vary massively from culture, religion, geographical background, and all the other factors that basically everything else in URR tends to be varied along.  A sentence will contain several clauses in most cases, and clauses are basically sections of a sentence that the game will generate independently (via archetypes) and then stitch back together (see below for more information on this).

Archetypes: these are hand-written default versions for each possible question. For each of the questions that the player can possibly ask (or the NPC can ask back), I’ve gone through and written a dozen or so variations of that serve as the foundations of possible replies (although once a reply is finished it will be almost indistinguishable from the archetype that created it). These are then distributed to each culture semi-randomly, with some relationships between some archetypes which others are “free-floating”, and each culture then starts the game with a few basic and foundational ways to talk about the things people might need to talk about in-game.

Kennings: in the case of URR, this refers to a particular way of referring to a particular thing. So this might mean referring to historical events, or a title to put in front of the name of a deity, or a particular way to talk about oceans or mountains, and so forth. These are basically segments of clauses that have to be expressed a particular way, so a clause might say [Title of god] and then the game will look up the appropriate “kenning” for that element and place it into the clause; alternatively, if it says [Desert] then maybe that nation says “Deserts”, or “Great Sands”, or “Great Dunes”, or “the Red Expanse”, or whatever, and the game will quickly check what the appropriate (generated) term is for something in a sentence.

So, in trying to create a sentence, the game does the following process:

Stage 1: select clauses. This first stage means that the game looks at how many clauses should be in a sentence, and what they should be. A nation with a dialect with low “sentence complexity” will have very few clauses in the average sentence, for example, whilst a nation with high sentence complexity will have many clauses. I’ve developed a fairly complex but easily-added-to system for adding clauses into sentences based on the nature of the sentence. This means that extra historical, personal, geographical, religious, etc, detail can be added to a sentence depending on how many clauses it has, and those clauses will be handled intelligently and sensibly.

Stage 2: select an archetype for each clause. The game then checks how that particular culture would express a particular clause and retrieves that archetype (which will then, in stage 3, be massively varied) and readies it. Archetypes are generated/selected in such a way that they should be broadly consistent across a culture, so you shouldn’t get a culture that talks about mountains in one way and talks about oceans in another, but rather talks about all those things in a broadly comparable way. Archetypes also affect sentence structure and in some cases word order, and these elements are also taken into account.

Stage 3: implement kennings/references. This third stage is perhaps the most important part of sentence generation, since at this point the game looks up how to express everything in every clause in that sentence. As we see above, archetypes say things like [Religion-title] and these are all triggers, telling the game to look up the appropriate phrase for the appropriate thing in the appropriate culture. As such, the sentences themselves within archetypes tend to have a large volume of square brackets in them, and aren’t really human-readable – although you can get a good idea of their meaning – until there’s a nice lot of kennings and references in place.

Stage 4: stitch it all together. The game then goes through all the sentence components – now transformed from archetypes with square brackets to archetypes with appropriate references and the like – and stitches them together with appropriate punctuation. This is partially done through the system that places clauses together, and also a bunch of signifiers that handle things like vowels/consonants, plurals, etc.

It was very tricky to find a system that struck the right balance between a) generating a huge volume of potential sentences, b) making the number of hand-made sections relatively low so that I actually get the release out before the 2020s, and c) ensuring a huge amount of modular variation within the sentence structures. With this system – selecting clauses, selecting archetypes, varying almost all of the components of those archetypes, and then stitching the sentence together into a meaningful whole – I’m confident that I’ve found a balance between all of these requirements. I think I’ve struck a balance between large volumes of hand-made sections, large volumes of procedurally-generated sections, and sections of speech that sit somewhere in the middle where handmade elements can be altered or twisted in some way depending on the particular nature of the speaker. I’m really excited to see what this will produce! These are just initial trials, but in the coming week I’ll be trying to build up all the possible conversation options and archetypes and clauses and whatnot, and then we’ll see how that looks. Here are two variations OF THE SAME CONVERSATION, and just look at all that variation!

BAIC

BAIC

(Note: you’ll also see a tiny bit of procedurally-generated calendars there! Some use years, some use a bunch of other systems; this might not make it into 0.8, but I just happened to be testing it out whilst I took these screenshots)

(You’ll also note the lack of ‘?’ in the second – just a typo!)

Having looked at the power of this system, even with the incredibly simple conversation above, I am *so* excited about how this is going to work. I now just need to write all the other words to slot into every other part of the system, and this is a huge task, but by next week’s blog entry I hope to have it all done and to be able to show off some more detailed conversations, as well as some of the other conversation options I’ve been developing this week – these extra things aren’t totally ready just yet, but they’ll be essential to making conversations feel very human, and adding extra depth.

Next Week

Conversations, sentences!

Be Sociable, Share!

9 thoughts on “Seeing Names, Changing Dialect, Sentence Generation

  1. When an NPC tells you their current, for lack of a better word, “job”, you may consider that some jobs that an NPC currently has may not be what defines them as a person or if they recently changed professions this might be relevant in some way.

    For example, say you meet a man who used to be a legendary fighter in such-n-such’s army, but now he’s a freelance adventurer or a stay-at-home mother or something. He might tell the player that “I used to fight along side our nation’s brothers-in-arms in my younger days, but now I can finally rest at home and raise my children” (or something).

    Or if a person “really” wants to do something else (like if you’re keeping track of possible profession changes for the future of an NPC) you might say something like: “I sell herbs and ingredients, but I’m saving my earnings and studying so that one day I can be a great alchemist”

    • Good thoughts – there is a “did you have another job in the past” question for precisely this, but I hadn’t considered the point about self-definition and the like. I’ll think about how I could include that.

      I love the “I’d like to be” bit, though! Lots of great cultural stuff to put in there; someone in a literary nation wants to be a writer, someone in a stratocratic or imperialist nation wants to be an officer…

  2. I think I’ll try to translate the Wikipedia page in french when I’ll consider myself good enough to do it… We’ll see

  3. The two boxes have been removed. Notability for video games is different than notability for products. And the over-reliance on primary sources was solved a while ago.

    The references for the article are surprisingly adequate. The two major ones are the rock, paper, scissors interview and the German-language article by Der Standard.

    Consider declaring your conflict of interest directly on the article’s Talk page.

    Also, can you like to a logo of some sort? I want an image for the infobox. I could just do the start screen from the game I suppose.

  4. It’s exciting to see conversations coming together. I’ve long had a passing interested in this topic, so it’s great to see someone so capable tackle the implementation problems and sharing the journey!

Leave a Reply

Your email address will not be published. Required fields are marked *