• Register

We're an indie team developing a series of dark-themed mystery games and light novels, set in a world called Kikai.

Post tutorial Report RSS Teach the kids English (Part 4)

I have improved the whole language system greatly. It now has a rather solid structure and flow, with other supporting systems like the NPCs’ short and long term memories, different contexts, relationships between the characters, etc. I have also added some random factors so the kids won’t respond exactly the same every time.

Posted by on - Intermediate Client Side Coding

Introduction

I have improved the whole language system greatly. It now has a rather solid structure and flow, with other supporting systems like the NPCs’ short and long term memories, different contexts, relationships between the characters, etc. I have also added some random factors so the kids won’t respond exactly the same every time.

The Structure/Flow of Conversations

There is a class called ConversationContext which holds the information of each conversation. The most basic information is the participants of the conversation. Apart from that, each said sentence by a character is transformed into a ConversationQuery, which is saved in the ConversationContext and used to help determine the current context, the main subject, etc of the conversation.

These queries are also pushed to the participants, so they can follow each sentence, then decide to stay quiet or respond, “change” or learn new things.

A ConversationQuery holds information like lists of words, adjectives, objects, etc in the sentence, who the sentence is referring to/talking about, etc. These pieces of information are built up from a pure English sentence, to help both the NPCs and the ConversationContext object grasp that sentence.

ConversationContext

MS Paint is back!


For example, if the player asks “What color do you like”, that sentence is then converted into a ConversationQuery which looks like:

- the original line: “What color do you like”

- sentence type: question

- list of words: “what”, “color”, “do”, “you”, “like”

- list of objects: “color”

- list of verbs: “do”, “like”

- refer to the speaker: no

- refer to the listeners: yes

(debug information and empty information like list of adjectives is omitted)

This query is then sent to Kai and Kira. If they decide to respond, new queries are created from their responses. All these queries are then pushed to the ConversationContext object. For this example, the kids will know that the player is asking about their favorite color and the main subject of the conversation is also switched to favorite color.

So, how would the kids answer this question?

NPCs

The kids (and possibly more NPCs) will hold a lot of information to themselves. From basic information like name, age,... to information about favorites, likes/dislikes, etc. Apart from their own information, which is always correct, they also hold information of other characters which they think is true. For example, if you tell the kids that you are 27 years old, they will remember your age like that. And these pieces of knowledge are different among individuals. So it’s possible to tell Kai you’re 27 and tell Kira you’re 17. They won’t doubt a thing until they talk about it.

These NPCs also hold values describing their thoughts/feelings towards other characters. For example, Kai’s value for the player will be comfortable, since the player has helped him a ton since the beginning. Kira’s will be uncomfortable because even though the player has helped her a lot too, she just doesn’t trust people that fast. These relationships/thoughts will have huge effects on the conversations between the characters. For example, if you make the kids dislike you, they won’t say a thing to you. Their tone will differ too, so in the beginning, Kira’s sentences are always shorter and colder than Kai’s.

Other notes

  1. Most of these kinds of information are stored in std::map, which can then be easily stored in binary files. Eg:

    std::map<EnumCharacter, EnumCharacterRelationship> relationships; 
    std::map<EnumCharacter, CharacterInfos> charactersInfos;
    struct CharacterInfos {
    std::map<std::string, std::string> basicInfo; 
    std::map<std::string, bool> likes;
    ...
    };
  2. Apart from the conversation context and the kids’ knowledge, there’s also a thing called WorldContext which has direct effects on the conversations too. It holds information like what time it is, how cold it is today, is there much food left in the house, etc.
  3. I have also added some random factors so the kids won’t respond exactly the same every time. These are only interchangeable phrases for now.


Visual Studio’s Post-Build Event

I knew there must be something like this but haven’t really looked it up until recently. It’s cool.

With it, I can now copy the files automatically to the “Kikai on Slack” folder after each build. So whenever I make a change and rebuild, the files are instantly served without the need to restart the server for Slack bots! It’s very helpful for many other situations as well, try it out soon if you haven’t!

For example, to automatically copy needed files to the server folder for Slack bots:

xcopy /y "$(TargetDir)$(TargetFileName)" "E:\Projects\Kikai\KikaiSlack"
xcopy /y /e /i "$(ProjectDir)nnet\*.*" "E:\Projects\Kikai\KikaiSlack\nnet\"
xcopy /y /e /i "$(ProjectDir)sentence_type\*.*" "E:\Projects\Kikai\KikaiSlack\sentence_type\"
xcopy /y /e /i "$(ProjectDir)words\*.*" "E:\Projects\Kikai\KikaiSlack\words\"
xcopy /y /e /i "$(ProjectDir)npc\*.*" "E:\Projects\Kikai\KikaiSlack\npc\"
Post a comment

Your comment will be anonymous unless you join the community. Or sign in with your social account: