A Look into our Improved Conversation System
Published on November 19, 2009 By ScottTykoski In Elemental Dev Journals

Before Elemental, most of us worked on a little title called Galactic Civilizations 2. In this game, you would do spend a significant amount of time conversing with AI players. They would plead, threaten, and barter with you in as intelligent a fashion as we could muster, with much of that 'intelligent' feeling coming from the PAGES of conversation text written.
 
Based on everything from relations to military might, the AI would pop up with dynamic dialog that changes based on gameplay. Needing similar dialog text for Elemental, and knowing the annoyances of the GC2 system, we've been able to implement a conversation system that's incredibly extensible that will allow awesome depth and realism to your/our AI opponents.

With that said, let's do a 'not as awesome' adventure through the new FlavorText XML...


<Topic>
Each section of flavor text has a 'topic'. When certain situations arise ('Step into Foreign Territory', for instance) the game will look for FlavorText that fit.
 
<Text>
The actual flavor text to use. This can have nested naming tags that allow you to interject the world name, faction names, etc.  The game accepts multiple <Text> values, storing them all and returning a random one whenever requested.
 
<SpeakingFaction>
<ListeningFaction>

For story and background specific text, we once again have the ability to specify dialog by faction, and like GalCiv2, you can also couple it to a Listening race to provide Race-To-Race backstory rich dialog.  If no factions are specified, the FlavorText is assumed to be for ANY faction.
 
Now, before you fall asleep, this is where Elemental's Flavor Text get's interesting....
 
<Rule>
This is where things get interesting.  In the GalCiv2 system, much of the more dynamic assigning of text had to be done in code. You'd have topics called DeclareWar_LowerDiplomacy,  DeclareWar_HigherDiplomacy, and DeclareWar_BiggerArmy, each with flavor text for a race declaring war who has a high diplomatic ability, low diplomatic ability, or a stronger army.  This wasn't HORRIBLE, but it did restrict the untethered creativity of the writers....the moment they wanted text for Declaring War by a race who had Low Diplomacy AND a Big Army they would have to dig into code.
 
This time, we have stackable RULES, which can identify special player requirements before using them in conversation....
 
 
- Race of Men -
0 - A Kingdom speaking
1 - A Kingdom speaking to another Kingdom
2 - A Kingdom speaking to a Fallen nation

- Fallen Race -
10 - A Fallen race speaking
11 - A Fallen race speaking to another Fallen Race
12 - A Fallen Race speaking to a Kingdom nation 

- Military Might -
20 - Speaker has a MUCH STRONGER Military than the Listener
21 - Speaker has a Slightly STRONGER Military than the Listener
22 - Speaker has approximately EQUAL Military Might as the Listener
23 - Speaker has a Slightly WEAKER Military than the Listener
24 - Speaker has a MUCH WEAKER Military than the Listener 

- Diplomatic Skill -
30 - Speaker is MUCH MORE DIPLOMATIC than the Listener
31 - Speaker is SLIGHTLY MORE DIPLOMATIC than the Listener
31 - Speaker is EQUALLY DIPLOMATIC than the Listener
33 - Speaker is SLIGHTLY LESS DIPLOMATIC than the Listener
34 - Speaker is MUCH LESS DIPLOMATIC than the Listener


So now the coders can unhide hundreds of different situations for the flavor text XML to tap into, which can be used at the writers discretion. The game will take these rules, crunch some numbers to determine the most applicable one, and bring that up to the player.
 
Have a dragon on your side, but a weak economy and low essence?  Imagine your enemy noting this and sending over a kind reminder...
 
'Your economy is broken and your magic has been spent. Even your mighty friend cannot save your heart from my blade. Give me your lands and perhaps I will show mercy.'
 
I feel intimidated and I'm just playing in my head. 
 
<RevisitedTopicBarrier>
The last value you can set is the 'Revisited Topic' barrier...basically the number of times this topic has to have come up before a given FlavorText is used.
 
Perhaps you keep grabbing artifacts within a peaceful neighbors territory. First it's a simple 'Pardon, friend. Perhaps you could refrain from the taking of lost items across our countryside?'. You keep doing it, and you get a 'Again, we ask that your units not pillage the lost goods from our lands.'.  One more snatched treasure brings up a stern, 'Your lack of respect disappoints me. I am breaking all treaties between out nations and demand that you leave our borders at once.'
 


Cool, eh? And all data driven!
 
Now obviously this creates an IMMENSE matrix of possibilities, and while we'll fill in the obvious and more likely ones, the system is set up to allow <FlavorText> entries to be read in from any file. We expect many mods that are extend and improve upon the conversations that popup throughout each game.
 
Some of my best GC2 memories involve being surprised by the intelligence displayed by the computer players (even if artificial). A similar system in Elemental will go a long way to bringing weight and history, and 'soul' to the inhabitants of each randomly generated world.


Comments (Page 2)
3 Pages1 2 3 
on Nov 20, 2009

Good luck advancing the idea and making it work.

Yes. I really hope that this idea will have a better ending than the Epic Story Generator in GC2 which was cool on the paper but horrible to implement. It has ended as an event logger (which is useful to remember what has been done)

on Nov 20, 2009

Now obviously this creates an IMMENSE matrix of possibilities, and while we'll fill in the obvious and more likely ones, the system is set up to allow entries to be read in from any file. We expect many mods that are extend and improve upon the conversations that popup throughout each game.

Flipping awesome...great post! Given Stardocks track record for post-release love, I'm sure such a foundation is going to yield great goodness in the long run.

on Nov 20, 2009

having a wide variety of things to be said that relate to the situation at hand is something I really  enjoy.   Both as a player and somebody who wants to create such text (this is all going to be in python right?)

 

I am glad you have it set out here.  I might want to throw in a tid-bit.   Here you have "military might" being compared, but might you also want magical might compared?  Or possibly relating to the strategy choosen by the AI?  (Focusing on heroes vs. focusing on armies vs. focusing on super-channeler)

 

I can imagine a leader saying something like "I grow tired of the tension at our boarders.  Prepare to taste the cold steel of my army"   but that would not make much sense if they were 'going-gandalf' and were basically charging in with just their channeler and a few heroes or a dragon.   The dragon might make the military might higher than an army would, but certainly there is no cold steel here.   I would not expect you to have specific dialog refering to rare fantastic creatures, but the AI player was specifically building his economy (or at least essence distribution) based around "powerful channeler + heroes" mentality.  So it would be more fitting to say something like "I have grown tired of the tension at our boarders.  You will soon fall before my <insert most offensive powerful>"

 

(of course one could have better dialogue than what is above, but its just examples)

 

 

I assume this engine can evolve easily to 2 way conversation.  However, IF it can be easily evolve into scripted actions, it will be even better.   In diplomacy, one can only have a limited number of ways to answer the 'flavored text', i.e. declare war or not.   But on other conversations, the engine will need to have a way to either link to AI or many more scripted actions.

you know what assuming does...   But a 2 way conversation is a bunch of 1 way messages.   Just because the code is setup as "faction sending message" and "faction(s) hearing message"  doesn't mean the listening faction(s) can't respond.  Instant messaging is setup very similarly to what is above, but people hold conversations through the "1 person sends, other person receives" format.  I guess you could say "If both parties are talking at the same time, nobody would be listened"

 

I put "(s)" on the end of faction just  because I would like to have 'wizard council' type diplomacy able to occur.   In Civ4, there was the UN.  And GalCiv2 had the  things you had to vote on from time to time.   But it wouldn't fire up a real discussion about it.

In theory there should be something similar to a 'group chat' where the factions put in a message or request that is sent to several people at once, and they can respond to anything put there.   So if there is agreed that a wizard council should be  formed to dictate the rules of Elemental, and all war declarations then must be done through the magical equivelant to the United Nations,   then the responces to such actions should be put straight into the council room, rather than told to you later in a barrage of "you declare war on my friend, me smash you" messages. 

Also then as a group, factions could decide how things result.   So lets say faction A declares war on faction B...    Factions C would start a council with factions D, and E saying "I am going to join A, but only if you both agree to join faction A's side as well.   Then faction D could respond "I will if I get money" and faction E could agree with C and decide to pay D's request so they are all on the side with A against B.

I guess then you wouldn't just have 

<SpeakingFaction> 
<ListeningFaction>

you might also need something like <TargetFaction> to specify to which faction the statement is referring, while still allowing for the "listening factions" to hear the conversation. 

(perhaps this would be better for an "idea" thread, but it seemed related to the topic enough for me, AND came up in discussion)

 

on Nov 20, 2009

I like this -- "soul" goes a long way!

Have you also considered having <RULES> for diplomatic breakthroughs such as (advanced, supreme, etc.) language skill as well as <RULES> for language barriers that may exist between Fallen / Human or Humans and other creatures in the world (e.g. trolls, dragons, etc.)? For the latter, you could imagine that things might get lost in translation (unless you have purchased the applicable diplomatic breakthroughs), so that the flavor text is suboptimal, e.g.

"We thanks you very muchly. My fondness four your kindship has grown to horse-size proportions. May I have a bite of your gold pieces? The consequences are thought."

So not quite "my hovercraft is full of eels", but not great either.

For the first aspect I mentioned, that would simply include better versions of flavor text choices depending on your and your AI opponent's level of Diplo skill. Low levels might give you the choice, based on the <RULES>, "Here is the treaty," but higher levels might allow you to say, "Your Lordship's signature has never looked more majestic than on this seal." or something like that.

on Nov 20, 2009

The talk with AI is nice idea. However bartering in GCII was great. You can see the stance of the other civilisation without the need of clicking on some button again and again. I hope the barter will be similar.

on Nov 20, 2009

Boogie,

This looks really cool, thanks for sharing.  However, so that I don't exceed my gratitude quota, two questions:

1) "Cool, eh? And all data driven!"

Oh yea?

"

- Race of Men -
0 - A Kingdom speaking
1 - A Kingdom speaking to another Kingdom
2 - A Kingdom speaking to a Fallen nation

- Fallen Race -
10 - A Fallen race speaking
11 - A Fallen race speaking to another Fallen Race
12 - A Fallen Race speaking to a Kingdom nation

"

So what if another base race is modded in?  Do you have rule numbers for "Other Base Race 1", "Other Base Race 2", etc?  Or a custom rule that takes the name of a base race or such?  Will the modder have to pick one of the "base base races" to put it under?  That would work as long as no mod wanted more than 2 base categories like that, but 3 or more would be a problem.

 

2) I hope to be much less of a jerk on point number 2, though perhaps invoking even more coder pain: what do you think about adding a rule type that takes as a parameter the name of a python method to call that returns true/false depending on whether the rule is met?  That would allow a much higher degree of flexibility for us insane modders out here.

 

Many thanks, even if you just totally ignore what I just said it should be great

on Nov 20, 2009

Just as a suggestion, a flavor adder for this might be insulting haiku's.  Once during a comment thread fued with a deeply irritating person, I concocted a series of dog insult haiku's to describe the individual and it just drove him bonkers.  While this isn't for everybody, and you might need to put a "no insulting haiku" buttion in the diplomacy options, this could provide a lot of interesting alternatives and opportunities for the community to contribute. 

For referance, I am including some possibilities. 

dog wants to open door
he lacks opposable thumbs
and licks his own butt

your fleets mass nearby
this alliance is in peril
grasping ankles now


cockatrices come 
resistant to flaming bolts
pity they can't swim

your army is huge
your economy in ruins
out of towns to loot

all your friends marching
alongside you to battle
so you came alone

I'm sure there are many more that could add flavor to a variety of situations.

 

on Nov 20, 2009

While were on the subject, I want to give my biggest pet peave with game diplomacy. Every game I've ever played has this problem.

Real life diplomacy is a very complex thing. Countries make requests of one another according to their interests, which they may or may not want everyone to know. There are also intangible things like national pride thrown into the mix. When you are making a diplomatic system in a game, you can only approximate the innumerable variables governing foreign relations, and you can choose any of them to emphasize arbitrarily. Depending on what diplomatic factors are modeled, and which ones are ignored for simpliciites sake, the expected results of the same situation can be very different.

In real diplomacy, the participants often keep their cards close to the vest as they say, and they don't always give honest reasons for their replies. This is very often the case in games as well, as replies to diplomatic requests are often completely unfathomable to the player. This is the problem I am trying to point out! This is one area where real life and games ought to be different.

In real life, it is possible to investigate and make educated guesses regarding how a certain mysterious communication might serve a countries interests. We are all humans with similar needs after all. In a game, you have no idea how carefully the diplomatic AI is modeled, and you end up having to read the developers mind to guess what is willful deception and what is just a bug in the AI.

I would like to see a game where the AI wears it's heart on it's sleeve for the most part so I have a chance to understand how the system works. I'm not saying that the AI can't bluff or deceive, but I want a plausable explanation for every response so I can get a feel for what factors are important to the AI.

I've actually played games where anytime I come up with a proposal that is even remotely fair, the diplomatic answer is always and forever 'no'. I want reasons, and I don't want the reason to be that the AI is sacrificing its own interests to present a challenge to the player.

"Ok, I have a huge army and you are down to one territory and a handful of defenders who could be wiped out next turn, I offer you peace with no strings attached. What is your reply?"

"No."

No? Is there a reason for this or are you just a bugged AI??

The system proposed in the OP seems like a great step in the right direction.

 

 

 

on Nov 20, 2009

advisor and heroes should be taking parts of the discussion too.

on Nov 20, 2009

Just a random thought.  It wouldn't be too terribly complicated to have certain words be replaced with more nuanced words in the flavor text.

So for ex, for a greeting to Friendly Nation, you could have "Hello [friend]. Do you want to discuss our treaties?" 

and then depending on the exact level of Friendliness the [friend] could be replaced with 'fellow emperor' ,'friend', 'neighbor', 'good buddy', 'my BFF,' 'you super sock puppet master and future ruler of my world'. 

It just seems that it would let you have an even more granular level of detail in the text.

I guess you could accomplish this with the aforementioned system, you'd just have to add a bunch more conditions and would have a bunch of nearly identical sentences, which kinda seems inefficient.

on Nov 20, 2009

keithLamothe
Boogie,

2) I hope to be much less of a jerk on point number 2, though perhaps invoking even more coder pain: what do you think about adding a rule type that takes as a parameter the name of a python method to call that returns true/false depending on whether the rule is met?  That would allow a much higher degree of flexibility for us insane modders out here.

 

I would like to strongly second this. As currently described the set of rules is all hard coded, so while the system is more extensible than before it is still not as flexible as I would like. Allowing some method for modders to create custom rules would allow for much richer interactions.

Such custom rules would allow for a basic question multiple response RPG like dialog system. The second question could check a custom rule for a saved value from the first response. This would allow actual branching dialog.

Oh and what is with the prejudice BoogieBac? We are not fallen, that is just kindom propoganda. We are Empire! In all seriousness I agree with keithLamothe on this point as well, I would try to avoid hard coding names of anything into these rules if you can.


 

 

on Nov 20, 2009

but it did restrict the untethered creativity of the writers
 

who are the writers anyway?   I know you've got us a book in the works.   But are the people who are writing the book also going to be making game text?  (obviously one is based on the other, but that doesn't mean they are the same people making and organizing it)

on Nov 20, 2009

It would be done so that it wouldn't give away intelligence on your enemy for free, right?

on Nov 20, 2009

it'd be kinda cool if you could make a permanent alliance once every 10 turns ... although it uses up alot of prestige. however making a new Perm Alliance breaks the former one. you could call these "Ultimate Alliances" ... and then it would be possible to form a true "Permanent Alliance" if you have shared an Ultimate Alliance for ~30 turns or so.

That way a country could be your "ex" .... a previous Ultimate Alliance partner, and now just a Friendly Ally.

Friendly Ally is practically like a rival, just like normal "friendly" always is, however Ultimate alliance would act like a Permanent Alliance ... share technology and line of sight ... only that its not guaranteed to be permanent. I think you should only get the chance to form a new Ultimate Alliance once every 10 turns after the first one ... and you can't simply break your Ultimate alliance, you have to form a new one. This way you can't simply revoke such an alliance any time you please ... every 10 years you would have to decide if you wish to renew the contract or not. Making it so that you cannot simply break up with the country ... but requiring you to form a new alliance ... makes it so that people don't drop out of the race and try to retreat into neutrality. Once your part of the game, you can't get out. (although it might eventually be decided that you simply choose to "renew" every 10  years, so on an aniversary divisable by 10 you can break the alliance if its truly your wish)

Anyways ... I just think it would be fun to create dialogue for a country you have Allied and then not-renewed the alliance (broke up with them) ... it would be interesting special dialogue only for Ex-Allies.

on Nov 20, 2009

Can Dragons level up? For one, that would be incredibly awesome, and two .. Ive always wanted to fight against a much, much stronger Mundane empire with only a dragon usign Guerilla warfare. Sure it might not be the best strategy for "victory" ... but fighting impossible battle after impossible battle with my elite battle-hardened dragon, and then retreating to the nearest castle or cave ... that just seems really, really cool.

3 Pages1 2 3