A Winding Road – Diplomacy in At the Gates

Late last year I talked about how I was gearing up for a head-first dive into diplomacy. I’m still in that pool, but happy to report I’ve finally made my way out of the deep end. Without a doubt, this has been the biggest challenge I’ve undertaken. Accordingly, the whole process has taken a bit longer than I had planned.

But let’s not skip ahead, and instead turn back to the beginning of our lengthy story.

 

The Plan

From the very beginning my primary goal with diplomacy was to put players in the driver’s seat. If you’ve been following along since day one you may remember this article, which outlined my plans for diplomacy, now almost exactly a year old. The core of that design was AI Leaders making requests and you could pick from at your leisure. A few months ago I finally started getting my hands dirty, and it wasn’t long before I discovered some serious flaws in the approach.

Topping the list was the dearth of interesting requests that actually make sense. Sure, you have the obvious “Please give me some food” and “Go beat up that guy” missions, but… where do you go from there?

Many possibilities that could work from a gameplay perspective don’t make much sense thematically. Attila could ask you to build a big statue of him but, uh, why would he really care all that much? Wouldn’t he rather just have your land or some iron? You’re Attila’s peer, not his official statue carver.

Okay, so maybe Attila is actually that full of himself and asks for his visage to be erected in granite – we have another problem now. Is building statues… fun? Is there even any strategy to it? Empire builders aren’t city builders, and plopping down new structures in this genre is rarely super-engaging. It’s the same reason why peaceful victory conditions are nearly always less fun than their more militaristic counterparts.

By this point it was clear that building one of the game’s most important features on top of one of the genre’s weakest was unwise. The question was where to go next.

 

The Plan v2.0

I decided to throw out everything and go all the way back to the drawing board.

I started by analyzing the two strategy games which have done the best job with diplomacy: Alpha Centauri and King of Dragon Pass. The common trait they both shared was driving diplomacy through personality rather than mechanical diplomatic knobs Sister Miriam may not have been the most strategically sound leader on the block, but you sure as heck knew who she was and what she wanted.

Taking the same approach would be a pretty big shift for AtG, but I concluded this was the right road to take. As much as we might like to pretend otherwise, there’s simply no getting around the fact that interacting with another human is radically different from dealing with a computer. We’re hard-wired to think of living organisms as agents with feelings, agendas and preferences. Computers are just logic and math, and it’s impossible to truly mask that.

The new plan I came up with was for diplomacy to instead evoke the feeling of an interesting book, only different every time you pick it up. Each story should contain memorable characters and events, not just dry mechanical systems.

So we had a new destination – now I just had to figure out how to get there.

A relatively minor feature from the original design would turn out to be the starting point. One of the AI leader requests was insulting another leader, and doing so would improve relations with the initiator and damage them with the target. I had a thought… “What if this sort of interpersonal drama wasn’t just an element of diplomacy, but the diplomacy?”

A big advantage AtG has over other games in the genre is that it’s exclusively single-player. Systems need not be symmetrical or even fair. After all, our AI leaders might pretend to have feelings, but they obviously don’t actually care who wins or loses or if life’s unfair. This freedom to bend the AI to our every last whim is a huge asset, as it means the diplomacy system need not be symmetrical.

At this point I knew I was on to something. I brainstormed for a couple weeks, exploring where this new design could take us.

I realized that instead of waiting around for you to initiate contact AI leaders could take matters into their own hands and force you to answer questions you’d rather not.

In other empire builders it’s incredibly annoying when AI leaders pop up between turns and there’s no way to progress until you’ve made a decision, and I knew I wanted to fix this. AtG’s single-player-only nature means that putting things on hold until your turn came with no drawback. The game would require a reply before you could end your turn, but you’d have as much time as you’d like to research your options beforehand.

Okay, so AI leaders would ask you to answer tough questions. But what should they ask for?

 

Sight to the Blind

Personality. Everything comes down to personality. I kept reminding myself throughout this process, and continue to do so. To bring this out I would have the AI leaders ask you questions relevant to their unique situation and philosophical leanings.

There should be no mystery as to whether or not Genseric and Attila like each other. They should often make comments about one another and trade barbs through the diplomatic channels. But this would get old quick if they kept saying the same line over and over again. It was clear that avoiding this would require AI leaders to be very attuned to what was going on around them in the world.

Genseric might think Attila is a threat and ask if you see things the same way. Either way, your answer will obviously have an effect on how much each AI leader likes you, but it should also mean more than just that. If you do in fact agree that Attila is a threat Genseric should remember that, and expect you to put your money where your mouth is when the time comes.

I also thought about what sorts of things a human player would care about and realized that context-awareness could be elevated to an even higher level.

Let’s say you’re exploring and come across a valuable iron deposit, and you know that Attila also happens to be in the neighborhood. Wouldn’t it be cool if you could, you know, tell him to stay away? Or maybe instead of a demand you could negotiate, giving up small concessions in return? Yes please!

 

Not Given, But Earned

I now had many of the basic pillars for the new diplomacy design roughed out, but still hadn’t yet figured out how all this would translate into actual gameplay mechanics.

A concern I’d long had regarding diplomacy was that a single ‘Relations’ value between you and each AI leader wasn’t really deep enough. I played with adding other metrics like ‘Trust’, but came to the conclusion that this was barking up the wrong tree. When dealing with an AI opponent all that matters in the end is whether it’s going to be nice to you or not. Splitting this up into different numbers muddies the water and poses some serious problems for a designer (how does an AI leader behave when he loves you but doesn’t trust you? Does that even make sense?).

The concept of multiple relationship metrics was certainly flawed, but I was convinced that there was still something there, and maybe it just needed to be utilized differently…

Further brainstorming eventually gave birth to the answer and a new feature: ‘Respect’. The key difference between the other failed ideas is that Respect is a global value. High Respect improves Relations and unlocks new diplomatic actions with all Leaders, while low Respect has the opposite effect. If you stare down a bully or aid someone in need your deeds will be whispered of in palaces, great halls and back alleys all across Europe. Conversely, word of you backing down will spread just as quickly, and may come back to haunt you.

Respect offers a completely new axis to consider when an AI leader puts you on the spot. Telling Attila and his horde of horse archers to shove it might seem like a bad idea in the short term, but doing so could also earn you long-term friendship with other members of the diplomatic community. As we’ve already discussed, AI leaders pay attention to what’s going on, and neither friends nor enemies will soon forget acts of extreme courage and character.

To raise the stakes even further I decided that hard-earned reputation of yours would be incredible fragile. As in the real world, the only way to build up a good reputation is by working hard for a long time. And alas, a single slip-up can cost you everything. The benefits of being respected worldwide are great, but the challenge of holding onto them is equally so.

This new mechanical knob got me thinking about another interesting possibility: wishy-washy answers. Maybe instead of always having to agree or disagree, in some situations you could hedge and give a non-committal answer. Doing so would eliminate the risk of a strongly negative reaction by any specific AI leader, but the price would be your global Respect.

There are times when this could save your bacon, but others when it’s downright crippling. Perhaps you’re good friends with both Attila and Genseric, and one asks if you hate the other. You don’t want to risk offending either party, so you play it smooth and give the ‘diplomatic answer’. Everyone knows what you did, but at least you’ve avoided taking sides. Hmmm… smells like the kind of interesting, difficult decisions I love!

 

Loose Ends

So far I’ve covered the big changes to the design of the diplomacy system, but there have been a few smaller ones also worth mentioning.

My original thinking was for AI Leaders to have a handful of personality traits, similar to other empire builders. The list of traits would be lengthy, but some would inevitably be shared between leaders. Not only would this make it easy to hook behaviors in code up to specific traits, but these tags could be shown in-game, immediately giving you, the player, a basic feel for who these leaders are and and how they might act.

After spending several days fleshing out the design for several dozen Traits I stepped back, looked at what I’d made, and decided to scrap pretty much all of it.

The problem with shared traits is that they’re actually in complete opposition to our primary goal: making each leader feel like a real, unique character. If Attila and Genseric are both labeled as “Wrathful” we’re already starting off on the wrong foot. This is better than having no clue, but as soon as you see the trait duplicated in another leader the immediate, undeniable implication is that the leaders are very much not unique. And no matter what we do that mechanical, copy-pasted flavor never quite goes away.

There will probably still be visible personality traits, but none will be shared. I’d also like for there to be variation between games so that a single AI leader doesn’t always behave exactly the same. The sweet spot for strategy is when you know enough about the situation to make educated decisions, but not so much that things become predictable.

To switch gears a bit, some of you might recall the ‘first meeting gift exchange minigame’ I talked about a while ago. Well, hopefully you didn’t get too attached to it, because it’s as dead as our good friend Julius Caesar. From the beginning there was always a niggling voice in the back of my head, and eventually it grew so loud that I couldn’t ignore it any more. Along with just being kinda weird, I was never completely satisfied with the strategic trade-offs it offered.

Sure, you could choose to keep some cash in reserve and ensure you were always able to provide a gift, but spending money is a whole lot more fun than, you know, not spending it. And discourages you from utilizing the same approach in every game? In my mind’s eye I saw a future where virtually everyone gave gifts either 100% or 0% of the time. The correct answer being the same every time is pretty important in mathematics, but in game design it’s a major flaw.

So alas first meeting gift minigame, we never knew ye. Still, the goal of spicing up first meetings lives on. The idea I’m playing around with now is every AI leader making an offer, request or demand of some kind upon meeting him. Not only does this highlight their personality far better than the gift minigame would have, but it still also puts some pressure on you to respond. If meeting Attila also means him demanding one thing or another it won’t take to establish some pretty clear opinions of the man!

 

Rubber, Meet Road

So that’s the long, winding story of how the design of diplomacy has changed this winter. Congratulations, we’ve finished Chapter 1! Yep, everything we’ve talked about so far was still just the beginning.

A design is just that: a design. Not an actual, playable, fun game. Nearly all games sound like fun when all they are is a design doc. The unfortunate reality is that most fall apart long before the first playtest. I had the design, but not the game. My challenge was now translating all of these interesting ideas I’d pulled from various places into usable logic and code.

It wasn’t really a surprise, but it didn’t take long before any shred of hope of being past the hard part evaporated. Computer AI is nothing more than rules, math and numbers. Even if you know exactly what you want, crafting an entity with a near-human understanding of context with such crude tools is like building a skyscraper out of Popsicle sticks and glue.

Making a random die roll and deciding an AI leader pops up and say he’s declaring war on you because he doesn’t like you is, obviously, trivial. But it’s a completely different ballgame if he needs to do so because you ignored his second warning about straying too close to his eastern border, stating such in a natural-sounding manner. And let’s not forget this is just one possible exchange among many dozens.

When implementing a gameplay feature my usual process is to spend a few days brainstorming the high and mid-level design objectives, then start pounding out code like a fiend. Gameplay code is remarkably fast and easy to write – unfortunately, the remaining 90% of the work is the hard part of iterating, bugfixing and polishing.

Given the scope and complexity of what I had planned for diplomacy in AtG I knew my traditional approach wouldn’t work. Instead, I would plan out every last minute detail before writing a line of code, ensuring any architectural flaws or oversights would be caught before causing real problems. The importance of this really can’t be exaggerated. A single structural error in a system as intricate as diplomacy in an empire builder can result in weeks of rework far down the road. In game development surprises are just part of the deal, but you want to catch and eliminate as many as you can while still in the design stage.

So I rolled up my sleeves and prepared for what I knew would be a messy affair, and I may have gotten a little carried away at the beginning. Wouldn’t it be cool if AI leaders could mix and match comments relating to a shared topic? I sure thought so. Genseric might talk about how Attila was encroaching on his territory, then note that he’d also stolen an iron deposit, then finally ask you to undermine Attila in some way. Each of these could be combined, separated and used in any number of ways. The sky would be the limit!

Or not. The fatal problem was that the web of connections this results in grows to astronomical complexity in a hurry. Which statements are valid with one another? Which seem close but are subtly incompatible? How do you ensure the grammatical transitions between statements are sound right? Hell, how do you even figure out what order to put things in?

I do still think a system like this could work in theory, but even if it that’s true the end result would most likely be composite statements more disjointed than clever. We’re making a game here, not exploring interesting theories in an academic setting.

For my diplomatic design to even be feasible I knew I’d have to step back a bit and start with a simpler foundation. The priority would be an AI that was extremely sharp and context-sensitive within tight limits. Quality, not quantity. Genseric could still complain about Attila getting too close and ask you to lend your support, but this would be a specific package of statements defined in code.

This approach would also allow me to ramp up scope down the road, if desired. Genseric noting that Attila is up to no good would be an ‘Observation’ comment type, while a follow-up statement asking you to go beat up on him would be a ‘Judgement’. That Observation could be used in a completely different situation, perhaps a greeting when you open up the diplomatic screen. Other Judgments could be hooked into it – maybe Genseric notes that Attila is up to no good, then asks you to break off your trade treaty with him. Flexible, but still simple.

I had reached a point where I had answers for all of the big questions on both the design and architecture side. I buckled down. Hard. I spent weeks mapping out the contents and logic for every single class and every single method in painstaking detail. After countless hurdles and breakthroughs I finally reached a point where I was satisfied with my preparation. I was ready to start programming.

 

Too Prepared?

However, I faced a mounting problem I’d never anticipated or even experienced before.

Fatigue.

I’d planned out the diplomatic system to such great detail that calling what I now had on my plate ‘programming’ seems like a cruel joke. What I was actually doing was copying text out of a text document into a code window and cleaning up the syntax so that it would compile. Over. And over. And over. Not for hours or days, but weeks. Weeks of copying and pasting text. What started as a massive, exciting challenge devolved into a daily chore I dreaded.

I did finally make it through to the end, but my enthusiasm towards the diplomacy system had waned considerably. I now had a robust framework in place, but a massive amount of work still remained. AI leaders could stitch Observations and Judgments together and figure out whether saying a mean thing about that other guy made sense, but there was basically zero actual content to take advantage of it.

I tried to buckle down again, but this doesn’t really help when you have to be creative again. I decided it was best to step away from diplomacy for a little bit. Normally I like to use these opportunities to brainstorm some new gameplay feature, but my brain was too toasted for even that.

Instead, I recharged over the following couple weeks by working on small polish features (hello, unit flag command icons!), catching up on business stuff I’d been putting off (ugh, taxes…), organizing my spreadsheets, penning this epic (!) tale, and fixing bugs.

About a week ago I was ready to jump back in. I started by implemented AI leader intrusion detection, demands to pledge to get or stay out, visualizing the tiles you’re not allowed to enter again. A couple more days of testing and we were in business – everything was functioning just as I’d hoped. At long last I could see the fruits of my labor in the game, and all at once the hard work that was needed to breathe life into the monster finally seemed worth it. There’s really nothing quite as exhilarating as watching your baby take its very first breath.

The most exciting thing is that this is just the beginning. Writing the logic for each type of exchange and instilling each leader with a unique personality will certainly take time, but I now know that it can be done. I don’t know how long it will ultimately take to get everything in and polished, but I can’t wait to see how it turns out.

 

Looking Back

For two and a half months solid I ate, breathed and lived diplomacy. Thinking back on it now, I’m actually kind of surprised I didn’t run out of gas sooner. Even so, the core issue wasn’t the amount of time I spent on one single feature – I was changing gears every couple weeks to a completely new dimension of the project.

No, the problem was that preparing so methodically ended up sucking the joy out of the necessary next step of executing said plans. I don’t mind a little busywork here and there, but two straight weeks of literally zero creativity and challenge was too much. I know this is what many people have to endure every day of their lives, and I have a great deal of respect for those who do.

And as much as I wish it were so, when crafting a computer opponent for a game as ambitious as AtG you can’t just try harder and push your way across the finish line by sheer force of will. Good AI requires planning, patience and a good bit of excitement to keep you going. It’s kind of like building a whole separate game, only one where you can’t really see what’s going on!

Taking the time to do this right is the main reason why I decided to push AtG back into 2015. These days it’s just kind of assumed that strategy games and indie games (to speak nothing of those which are both!) won’t be as polished as they could be at release. I don’t know how much longer it will take, but I promise you AtG will not be one of those games.

If I were to go back in time and repeat the past three months, I honestly wouldn’t change a whole lot. The key difference would be limiting my planning to high-level stuff, and not writing out the exact contents of individual methods.

I’m sure some programmers swear by this in-depth approach, and it certainly did lead to me sitting on a more robust framework today than I’d have had I coded it up by the seat of my pants. But the cost isn’t one I want to pay again. If that means spending a week or two in the distant future rewriting a class or two – well, that’s a price I’ll happily pay. Games are an extension of the development team’s creativity and passion. Lose those and your game loses its soul.

 

Looking Ahead

Phew, I think we made it! Now let’s put a bow on this thing.

The plan from here is to flesh out the diplomatic skeleton currently in place and dress it up all nice and pretty, finish up a couple medium-sized features (which I’ll talk more about in the next update), then kick off the beta test in 4-6 weeks.

Alright then! Time to get back to it. I snuck a quick glance at my other screen and I think Attila is giving me the stink eye. Probably something to do with me putting his logic for declaring war on hold to finish up this post.

Hmmm… On second thought, maybe I should leave that particular feature out…

- Jon

Official AtG Website | Follow @ConiferGames on Twitter | Like us on Facebook

 

About these ads
Leave a comment

6 Comments

  1. Good to know you are working productively!

    I like the respect idea. About trust, myself i thought of trust-fear system.
    opponent can:

    1. you trust and not fear of you (friendship)
    2. trust and fear (respected enemy)
    3. not trust not fear (disdain)
    4. not trust and fear (hated enemy).

    Reply
    • I was actually thinking along similar lines, but I started running into trouble once I needed to flesh out what each of those meant. How much does being a friend differ from being a respected enemy? In reality there’s obviously a lot of room, but there’s no so many ways to interact in a computer game with fixed rules.

      Ultimately the two things that matter are whether or not a leader will trade and interact with you, and how likely they are to attack you. I actually didn’t talk about it in the article (only so many words in me!) but in the screenshot you can see that both of these are represented, the latter of which with a “War Eagerness” rating, which takes things like relative strength and past interaction into account.

      – Jon

      Reply
      • On the picture I see mood is indifferent and war eagerness is possible. Can there be a friendly mood and high war eagerness at the same time? How war eagerness is determined?

        About trust-fear system, extorting things from your friend would lead to a great loss of trust (both for him and other players). If you are a respected enemy, you can demand tribute. If you are disdained or hated, the opponent would not likely pay. What fear means – if you are feared, your opponents would seek an opportunity to destroy you, but at the same time they would be more willing to fulfil your demands when you are stronger.

        Reply
        • ps: war eagerness, i see, is determined by relative strength and past interactions. so its a function of the mood + other factors like relative strength.

  2. Louis XXIV

     /  March 7, 2014

    Isn’t the mind-numbing work what you get interns for? ;)

    Very interesting overall. I look forward to the new approach in action. I seem to recall Romanization perks being vaguely quest related (I could be wrong). Is that gone as well? Or should I stay tuned to hear more about them?

    As an aside, I wonder if the respect meter would make sense for the endgame. I remember you saying you wanted some way to avoid marching on Rome too early. Would requiring your global respect be at a certain level work or would that unduly compound elements that should be far more separate (and that respect should be a reward for its own sake)?

    Reply
    • Hehe, you’re not the first person to suggest that! Yes, an intern would be great, but the problem is that while this kind of task might be “busywork”, it’s very delicate busywork. One of the biggest challenges with AI development is just making sure the AI is doing what you think it is. Tragically, the tiniest error can be crippling but still go unnoticed.

      To be fair, I’ll make plenty of mistakes while coding just as someone else would, but I also have to be the one to debug it later in the project. Knowing the code like the back of your hand is a huge, huge asset.

      My next update will talk about the Romanization Perks system, along with a couple of other new features.

      I do think Respect is better left independent of anything Roman-related, although I do reserve the right to change my mind at any point! The Romans have completely different priorities from the barbarians, and in many ways are in complete opposition with them. Your peers might care if you’re badmouthing another leader, but the Romans don’t really care as long as you’re watching the frontier and keeping their taste for salt satiated.

      – Jon

      Reply

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.

Join 155 other followers