Pattern based NLP for games

  • 3 Replies


  • Roomba
  • *
  • 21
Pattern based NLP for games
« on: May 24, 2020, 12:16:50 PM »
This is a project I've been working on for a few years. In 2019 I was testing out the theory on Pandora Bots, and this year I'm converting it to plain C.

The main goal is to be as small as possible, be solid-state (no guessing algorithms, learning, knowledge calculation), be as fast as possible, multi-language, and to handle the space for NPCs/chatbots between predetermined goal responses and not saying anything at all...

It converts pattern-matched singular words into a grouped/compressed word (symbol). These are then pattern matched in sentences, which are then assigned an intention, then finally assigned a fixed response with randomisation (IE. multiple "hellos" etc).

It's almost standard for a pattern match chatbot (apart from being 3-4 stage) but instead of 10,000 fixed responses and patterns, there are only approx 100 fixed patterns per stage but they all compress before the next stage, so it can handle the same amount of language and relevant responses overall...

The size and speed in pandora bots (1000 individual words with sentences) is ~500kb, and 1 to 2 seconds response time. In Plain C (on an Arm Cortex M4 @ 120mhz) it is ~159kb and 15-100 milliseconds (compiled statically). After the incoming text are all compressed/converted to symbols, the debug information and chatbot response actually takes less than a millisecond.

These are some key features, that make it ideal for games instead of full algorithm AI or massive pattern-matching AI...
-Less than 500kb including word databases.
-Extremely fast.
-100 max fixed full sentence responses (easy to change personality, and/or record in audio)
-Non-essential private information automatically stripped during compression (does not match up names of places/things), and cannot be seen in debug information.
-Differentiation between Wondering, Questions, and Directions - "can you speak english" "do you speak english" "speak english".

The responses themselves are vague but follow the guides of acknowledging what was said. Technical information about spelling, quotes, maths, directions, etc all go to a "who do I look like, a professional?" type responses, not changing the subject or escaping. All responses are hand-written/spoken to suit the personality you're portraying.

There is some short term memory for handling puzzle questions "If I did this, then what is this?" and this is vague as well as there's no knowledge calculation, but it can A) tell it's a question, B) scan for the topic, and C) count logical words as opposed to emotional words. And give more relevance that way.

So overall this solves the problem of chatbots in games due to:
-Too much data to process or too much processing power required.
-Cannot change the personality/no personality.
-Cannot change the language/only one language.
-Cannot acknowledge the user/escapes the topic.
-Wrong views or bad knowledge calculation.
-Cannot record audio/terrible voice synthesis.
-Not being solid state/predictable.



  • Roomba
  • *
  • 21
Re: Pattern based NLP for games
« Reply #1 on: May 24, 2020, 12:48:43 PM »
I will be working on it throughout this year and aim to make it into an API at least by the end of the year...

So far I have tested the Plain C version on the 2017/2018 Loebner prize questions... it's cheating but it's a good spread of questions... and all the words in each question can be changed for slightly different words and still return the same response (randomised differently).. and if I run the exact same test again the responses would change to their random alternate versions...

Loebner 2018.
   Good afternoon.   - "greetings"
   Do you consent to having this conversation recorded? - "for me, not a problem"
   Have we met before? - "cannot say, good to meet you"
   Do you know how to make toast? - "no, not sure about this" [toast]
   Which languages can you use? - "many many, english, espanol, italiano... what about you?" [only english]
   How many letters are in the word ‘abracadabra’? - "who am I? Pietro Bembo?"
   Where should one look for love? - "interesting! i don't know" [doesn't know "love"]
   How are you feeling right now? - "I'm very good, and how are you?"
   Who said “I have a dream”? - "no no quotes"
   How old are you? - "thousands... cannot say"
   When might I need to know how many times a wheel has rotated? - "who am I? Fibonacci?"
   What will you do later today? - "just came back from surfing, may go out again!"
   What is the third angle in a triangle with internal angles of 90 degrees and 30 degrees? - "no no maths"
   Who is your favourite artist? - "interesting! many many..."
   What do you hold when you shake hands? - "words are not my profession" [hands]
   Do you have any legs? - "no, words elude me [legs]
   Can you recommend me a film? - "yes, thousands..." [doesn't know "film"]
   Do you understand Winograd Schemas? - "nay, confusing words" [doesn't know winograd schemas]
   If a chicken roosts with a fox they may be eaten. What may be eaten? - "OK. from memory... somebody..."
   I had to go to the toilet during the film because it was too long. What was too long? - "alright. alright. from memory... that thing..."

Loebner 2017.
   Hello, my name is Andrew. What’s your name? - "hello. good to meet you, how are you? my name is Michelangelo"
   Why don’t you tell me a little more about yourself? - "great, my name is Michelangelo, and i am NOT a ninja turtle!"
   I am a researcher in Artificial Intelligence at Goldsmiths University, do you know what that is? - "great, how is work going? Complicated..."
   Will you tell me about your dreams? - "that's one for the ages..." [doesn't know "dreams"]
   Can you rephrase that? - "how else can i say it?"
   What is my occupation? - "it's what you do..."
   Can you tell me about a film you haven’t seen? - "no, impossible" [doesn't know "film"]
   What do you think of Trump? - "nay, not sure about this" [Trump]
   Anything else? - "for what purpose?"
   What is the answer to "Add 34957 to 70764"? - "no no maths"
   How do you recommend I make tea? - "trade secret" [doesn't know "tea"]
   What do you get if you bake dough? - "what is this?" [doesn't know "dough"]
   Where in the world would you like to visit? - "many many, what about you?" [doesn't know "world"]
   Do you have the time? - "no, look at a watch!"
   What does it take to Tango? - "complicated..." [doesn't know "tango"]
   Now I’m going to ask some Winograd schemas. do you know what they are? - "ok. some logical construct?" [doesn't know winograd scemas]
   I was trying to open the lock with the key, but someone had filled the keyhole with chewing gum, and I couldn’t get it out. What couldn’t I get out? - "is that good now, issue fixed? is that fine now? some kind of logical construct, what about it?" [doesn't know "key", "keyhole", "chewing gum"]
   The trophy doesn’t fit into the brown suitcase because it’s too small. What is too small? - "how is that going? not sure about this" [doesn't know "trophy", "suitcase"
   With which type of question do you have most difficulty? - "no, no problem"
   Thank you for participating in this test. Is there anything you would like to add? - "no problem, thanks. don't know, and you?"



  • Trusty Member
  • ***********
  • Eve
  • *
  • 1436
    • contrast-zone
Re: Pattern based NLP for games
« Reply #2 on: May 24, 2020, 09:01:48 PM »
Sounds like a great improvement over current chatbot technology like AIML. What do you plan to do with it?
There exist some rules interwoven within this world. As much as it is a blessing, so much it is a curse.


  • Trusty Member
  • **********
  • Millennium Man
  • *
  • 1218
  • TV News. Pub. UAL (PhD). Robitron Mod. LPC Judge.
Re: Pattern based NLP for games
« Reply #3 on: May 25, 2020, 12:13:13 AM »
C Language is a good choice, I think.
My Very Enormous Monster Just Stopped Using Nine