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 3)
3 Pages1 2 3 
on Nov 21, 2009

Tasunke
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.

There are a number folks in the special forces community who would describe the situation differently, but they tend to carry a grudge.  The downside of this scenario is that it leads to playing "whack-a-mole", which is available in other games.  Traditionally, this causes folks to circle around the cave and then capture or kill the pop-up perpetrator.  Remember that Geronimo died in bed of pneumonia at Ft. Sill as a prisoner of the US Army. 

On the other hand, in "Master of Magic" there are instances where the ruling mage is banished from the plane and his empire stops moving units around until he casts the spell of recall.  In that case an all-but-exiled mage can scoop up a lot of territory in the now uncontrolled lands.  An interesting variant of this effect that applies to this thread is that while the returning mage is off-site, they could send snarky comments to the residents of the plane in play.

on Nov 21, 2009

okay fine then, no caves ... just retreat to the nearest Castle. I mean ... a Dragon can probably fight many battles up and down the country before it has to retreat to a castle, if played well. Saying "hide in a cave" was largely irrevelant as a Dragon cannot hide in a cave, merely rest there, to recover HP and stamina.

my main question was wether Dragons can gain levels or not ... cause thats relevant even when you DO have a sizable army you can field.

on Nov 21, 2009

This DevJ made me think about one thing. How much will AI know about me (myself and I)? In other words: will it cheat to get all the info it needs to crush me? Or will it be tied to the same rules as I am, so it will have to send a scout/spy to know more about me.

Why I am mentioning it here? If the AI is to choose an appropriate dialog when speaking with me, shouldn't the choice be made basing on what he has seen, not what I really am? Think about such situation. I was unlucky, and I was spawned in the middle of nowhere - with no bonus zones around. I built like 3 cities which didn't grow too fast making me quite week in comparison to opposition. Now, suddenly I tamed a dragon, however, it's quite late (200 turns have passed) and my foes have much bigger armies, which can crush my dragon + a bunch of soldiers. Eventually I met a AI-controlled enemy with my dragon. He has no info about me, so he assumes that with a moderately strong army and the dragon, I will be able to defeat him. Basing on that event, from now on (until he scouts me, or I lose my dragon) he will communicate with me, as if I was super-powerful opponent.

What ya think?

on Nov 21, 2009

landisaurus
...
 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" 


Well, Boogiebac only talks about AI to player conversation in the OP.  IMHO, it'll be quite a waste, if they only use it in such a limited context.  I just need to expand the OP idea for all other uses, especially role playing.

landisaurus
...
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.
....
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.
 

This is a great idea!  This should allow more organic diplomacy.   In the mechanism you stated, when someone declared war to you, other friendly AI players may or may not help you.   Or when some fractions tries to gang up on you, other fractions will make a defensive pact with you to protect you.

==
Anyway, I will very happy if Boogiebac show us how they will link the result of conversation to action.  How will they make this portion data driven too?

==
red1939
This DevJ made me think about one thing. How much will AI know about me (myself and I)? In other words: will it cheat to get all the info it needs to crush me? Or will it be tied to the same rules as I am, so it will have to send a scout/spy to know more about me.

Why I am mentioning it here? If the AI is to choose an appropriate dialog when speaking with me, shouldn't the choice be made basing on what he has seen, not what I really am? Think about such situation. I was unlucky, and I was spawned in the middle of nowhere - with no bonus zones around. I built like 3 cities which didn't grow too fast making me quite week in comparison to opposition. Now, suddenly I tamed a dragon, however, it's quite late (200 turns have passed) and my foes have much bigger armies, which can crush my dragon + a bunch of soldiers. Eventually I met a AI-controlled enemy with my dragon. He has no info about me, so he assumes that with a moderately strong army and the dragon, I will be able to defeat him. Basing on that event, from now on (until he scouts me, or I lose my dragon) he will communicate with me, as if I was super-powerful opponent.

What ya think?

This is a very keen observation.   It also relates to the 1st point of my reply #8.

The conversation choice MUST be base on what he has seen.   This is a principal that should applies to all other AI decisions too.   There must NOT be any chart comparing player A vs player B's true military strength, true tech/magic level, true diplomacy skill etc.   However, there can be charts showing the "perceived" strength on each category.   Gamer & AI opponent will base their conversation/action on this limited piece of information.   And I may be (or not) happy that such charts do exist at all, because I found that while they are useful, these charts may distract my immersion to the game.

These "perceived charts" can be made to be quite accurate but not necessary true.   When you see your opponent has a dozen pole-arm wielding knights & they see that your best units is only foot soldiers, you (& your opponent) will perceive that your military is weak and base their follow up action to that.  (However, they don't know you have 10 dragons hidding somewhere else in their FOW).

on Nov 21, 2009

yea, perception would be cool. However, games like Civ 4 work well with all players constantly knowing the calculated "power" and "economic might" of nations. I mean, there are power charts, food charts, GNP charts, Productivity charts, ect. All of these are points of comparison. However, perhaps it would be better to focus on percieved power in Elemental ... especially since the power of a Sovereign's magic, ect, is hard to make "absolute calculations".

on Nov 21, 2009

I really like the idea of perceived power and limiting the AI to what it has seen rather than giving it any type of meta-information.

This conversation system seems very, very cool.  I have not used Python in the past.  Is it difficult to pick up?

on Nov 22, 2009

Negotiations generally should be quick, short, simple and straight to the point.  No time for small chatter and idle banter.  Unless a very good reason to justify advanced negotiations exist, players might favor the fast route when dealing with many civs.

Now if the game could make negotiations entertaining well that might be a very good reason indeed.  Like if the emmissary I am speaking to is laying out his war plans in a video feed of the cloth map plus moving chess pieces on the next window.  "As you can see the military forces of [player X] is advancing into our neutral zone, mutual action is required to counter this threat."  Think of it as the space war combat video in GalCiv2 only for negotiations.  Would make threats look far more threatening too.

on Nov 22, 2009

Good stuff! I'm always for a more robust AI interaction system!

on Nov 22, 2009

maybe the more airs you are willing to uphold (in order to appease your diplomatic guest) the higher the chance that your proposal will pass. of course, there are only so many airs that you can uphold before making a fopa, and this number increases with your diplomacy score. (so diplomacy score is not purely "I can talk better" but also has a mechanical factor as well)

on Nov 22, 2009

Tasunke
maybe the more airs you are willing to uphold (in order to appease your diplomatic guest) the higher the chance that your proposal will pass. of course, there are only so many airs that you can uphold before making a fopa, and this number increases with your diplomacy score. (so diplomacy score is not purely "I can talk better" but also has a mechanical factor as well)

Actually I don't like this. I think the AI's should make decisions according to their interest and then explain that in some way. The total war series fails in this way by relying on your diplomats skill. If you don't have a high skill diplomat the answer from the AI is always 'no', even when you offer deals that will really help them out.

on Nov 22, 2009

well ... of course I want things that interest the AI to be accepted by the AI. What I mean is that for particularly though things (like getting your son to marry their daughter, or allowing your workers to mine ore in their territory "a gift of raw resources", it might need some ass-kissing, or rather diplomatic and respectful language, and your options in speach are limited by your diplomacy value)

Although, if someone needs a military alliance, it wont matter if your an ugly, hairy, ill-mannered bumpkin

on Nov 22, 2009

If there was a way that each AI could only calculate your military strength by what was visible to them on the map that would be good.

I also have another concern. I know a lot of modders aren't going to put a ton of work into it (I hope to put a ton of work into mine, but not everyone will). So will there be a way to streamline the conversation tree optionally? If there isn't, oh well get back to work slackers!

I am more concerned about the race issue discussed. So when I create my mod adding another race to elemental, how will they interact with humans and Fallen in this conversation tree?

on Nov 22, 2009

perhaps they will make Fallen-Human interactions generic enough (mostly) to just be Bigger creature > Smaller creature interactions, and when "Fallen" and "Human" are mentioned, its a Variable word. "Greetings lowly (enter species here), do you delight in our destruction of your puny ideals? Kiss the royal finger."

If not however, then yes, modders will need to do alot of work. It wont be so bad though ... I mean, you could just copy "Fallen" diplo text ... and then spend hours scouring over it to change discrepancies

Although, either way, doing a mod to a race, with consideration to conversations, is going to take ALOT of time ... even if very little programming knowledge.

on Nov 23, 2009

Back to topic, who launches dialogues?

 

Can dialogues be initiated by individuals or leaders?

For instance, let's say there is a Sphynx unit somewhere. When you meet it, it spawns a dialogue and if you answer correctly, it joins you, otherwise, it eats you. Does the Sphynx have to be a leader of a faction, does it have to have its own faction, or can it be a character of the Neutral/Barbarian faction?

In the latter case, which is probably the best for modding (think a unit which you could bribe or convince to join you), you'd want to change the image in the diplomatic background so you represent the unit and not the civ leader.

So, can a faction be a unit rather than a civ? Ot will it have to be Topic-related?

What about background images/art? How do you link it to the Topic? Does Topic-specific override Faction-specific art/background or vice versa?

on Dec 02, 2009

This is really cool.

 

I wonder however willwe be able to threaten the AI and will they be able to comply in kind?

3 Pages1 2 3