Thursday, 21 February 2008

Natural language conversations in Flash

I've been working on a role-play engine in Flash and thinking a lot about how to interact with characters within a role-play game. 

I'll rewind somewhat and put this in context. Back in my old school days, I used to play AD&D with a group of friends. I was normally the DM, the guy who designed the quests and took on the role of the monsters and other characters that the heroes would interact with. This was great fun, and led to some memorable scenes that even today, over a decade later, we will still sometimes discuss fondly. So why have those imaginary experiences stood the test of time within this group of old friends?

I believe that part of the reason is that, being an intelligent human being, I could react to their interactions with the characters in the adventures in a believable way. I had to improvise a lot, going off-script, and inventing back stories as we played. Now computer based role-play games do not really try and tackle this tricky problem in a believable way. Probably the best, most believable characters I have come across are in the computer game Mass Effect, which (like the classic Baldurs Gate series and numerous other RPGs) use conversation trees. Now these work well, but you cannot stray from the possible options that the game's designers have come up with and so when you run out of possibilities (or just want to say something else that hasn't been scripted), well, um, you can't - it's just a game. So there isn't too much role-playing actually going on in computer based role-play games, unless you involve real people like MMRPGs do, but then again, I don't think too many people are staying in character in those games. Correct me if I'm wrong.

So this brings me back to single player games and how conversation trees are good but don't really allow you much freedom. In discussing this with a work colleague a while ago, he alerted me to an old Ultima game that would allow you to free type keywords in to the characters. This (and the excellent Facade  AI demo) got me thinking about the possibilities of this approach. Of course, the problem with this is that you have to know the keywords which will trigger the correct reactions in the NPC's, but this can be solved by involving synonyms and also if you know the issue of second time around playing, where if you know the keyword you can get the correct response right away (my colleague gave the example of a grappling hook that you needed to scale a wall, when you know this, you just said grapple to the NPC and he gave it you right away whether or not you'd even discussed it with him), but this is solvable using an unlock list on the topics themselves.

So here is the results of about four days work in experimenting with this approach. V1.1 of my demo is available here. It is extremely basic; there is no preloader (wait a few seconds and something will actually appear). Type in the light grey box and click the dark grey box to send your query. Treat it as a query engine, where you can ask the character various things. I'd love to solicit feedback on this, so if you have any thoughts, feel free to share them.


JuanPi said...

dear friend,
I really appreciate your intention and your attempt. I am concern with the same kind of questions. I think talking in game is yet not a surmountable problem.
You give two possible solutions or implementation for talking in games (I must confess I don't see the difference in implementation). One gives the player a few options to choose and the other allows the player to type the words. I find the first is more in the spirit of RPG because it is more immersing. I don't enjoy talking to the NPCs like this:
Hello, my friend
Yes, we sell food in this Inn
Our prices fits all kind of customers
Good bye, see you soon.

Talking with keywords is awful.
Here I put my experience with your example.
>Hello. What experiment is this?
Hello and well met.
>Can you talk about the experiment?
Hey did I tell you about my cousin? He makes computer games.

I know this is a terrible problem for AI (See talking with John Lennon and all those attemps, though Façade is very good). I agree with you about MMORPGs.
I think a prblme to solve in all this (even in your example) is motivation. Why should I keep my character? In real-life RPGs it is enforced by the group itself and the situation, but that is lacking in pc games.
I am starting, with a friend of mine, a blog about all this kind of topics. We hope to have some answers, and new questions soon!

The Recursion King said...

These are good points. I'm thinking that this approach may be suitable to tie into a conversation tree to allow you to deviate from it.

An example (in the spirit of the previous ones)...

You are in an inn. The barkeep leans over and asks what you would like.
(option) Order a drink
(option) Ask about rumours
(option) Leave the inn
(option) Enquire about something else [leads to free text entry]

The last option, which leads to free text entry, would allow you to ask the character about his background, opinions on things going off in the world or to ask for further information about things the conversation tree might have brought up.


You order a drink and barkeeper mutters something about rats.
(option) Ask about rumours
(option) Leave the inn
(option) Enquire about something else [player can type in rats and get some more info on that]

So I'm thinking that combination approach may be useful. Of course, this natural conversation approach is only going to be as good as the database that powers it (how many responses does the character have to give)? What's interesting about this, though, is that the engine itself will be able to generate this... I think I may blog about this aspect soon.