Wednesday, December 19, 2018

Artificial happiness

In my quest to make the AI in Civ 6 better I have hit a snag.  Much of my efforts thus far have been focused on making terrible decisions into reasonable ones so that the AI won't be so outclassed, but I have run into a structural problem I don't quite know how to solve.  The AI simply does not recognize and attempt to solve happiness problems.

Nearly every civilization I have conquered in my past couple of games has had huge problems with rebels spawning around its cities and mulching its army as well as pillaging its tiles.  This only happens when you don't pay enough attention to happiness and find ways to get amenities to make your people happy.  The AI does try to purchase luxuries from me, but eventually they get mad at me for some reason and then refuse to trade, even when they desperately need what I have to offer.  They also flat out don't build Entertainment Complexes, which are a necessity for keeping a large empire functional.

In my last game I witnessed 4 of 5 AIs having huge happiness problems to the extent that they were swamped with rebel units.  When I finally conquered the entire world I checked and discovered that not a single AI had ever built a single Entertainment Complex.  They just sat there with terrible happiness problems and ignored it, and that ruined their empires.  After I took their cities I built many Entertainment Complexes in the conquered territories to support my expansion - it is not difficult to do, but they ignored it completely.

This undoes me in several ways.  One, I can't do much to make the AI better if it insists on being an idiot like this.  I know for sure I can't fix its terrible combat planning, but I had thought at least I could make economics work better.  I also tried some changes out where I reduced the bonus Amenities in each city from 1 to 0 in order to tone back Infinite City Spam strategies (I buffed Entertainment Complexes to 2 base Amenities to compensate, and promote more developed cities) but that just made things worse for the hapless AI.

I don't need much to work with.  I just need an AI that chooses to build the district that makes happiness when it has happiness deficits.  I can fix the rest with simple numerical changes!  But right now I don't even have that.

I really want to fix this.  I hate that the way the AI is buffed at higher difficulty levels basically makes the early game absurd in the favour of the AI, and then it plays so badly that you are nearly guaranteed a win in the late game if you manage to get there.  I want the early game to be much more fair so the player can actually get a religion or build a wonder if they really want, but have the AI present some kind of reasonable challenge later on.  Right now I am kind of lost in how to promote that.

Saturday, December 15, 2018

Far less than infinity

Gloomhaven scaling has some issues.  At level 1 you are supposed to fight level 1 monsters, and that is an appropriate challenge.  At level 9 you are supposed to fight level 5 monsters, and that is not an appropriate challenge.  You crush them, it is easy.  You are supposed to address this issue by raising the difficulty of the monsters, but there are two problems with this.  The first is that monster difficulty caps at 7, and that isn't enough for really good groups, and the second is that the ways the monsters scale doesn't work.

Monster scaling mostly just adds health, damage, and speed.  Monsters do get additional bonuses like Immobilize or Poison on their attacks but that isn't a huge deal.  The real issue is that, as one person said in the comments on my last gloomhaven post, if you increased monster damage to infinity that wouldn't actually be a huge problem a lot of the time.  You don't deal with high level monsters by having a lot of shields and health.  You deal with them by disarming them, stunning them, or killing them outright.  Their damage scaling doesn't matter at that point, and when you use instant death attacks their health totals don't even matter!  Nothing about monster scaling prevents you executing them, and that is a problem.

High level abilities and equipment let you spew out status conditions like crazy and lock up the monsters until they die.  This is a problem in all kinds of fantasy games like DnD or WOW - just look at the way that designers give special baddies ways to cheat on saving throws against Hold Person or Polymorph.  They know that those effects are absurd in some situations.  WOW had a variety of systems preventing people from using chained up stuns on enemies, for example, because they didn't want enemies to just be stunned for eternity.  At low level where status conditions are rare this isn't an issue, but eventually they become so plentiful it becomes a problem.  At low levels disarm prevents 2 damage, and heals restore 3 health.  At high levels disarms prevent 5 damage, and heals restore 5 health... but disarms get handed out on big AOEs, and heals are tightly regulated.

So you can't just scale monster difficulty by giving them more health and damage.  That just makes healing and tanking even more pointless, and makes instant kills and status effects even better than they are.

What to do?

The answer is that you have to nerf players.  Players don't like this, but sometimes it is necessary for the game to work.  Gloomhaven, like many other games of its type, works best when you get hit and heal up, not when you never let the enemies have a turn.  Complicated formulas like WOW's diminishing returns on status effects are not possible in this format, but we can make other changes.

There are two ways to approach it, I think.  The first is to deal with the effects that are overpowered at high difficulties - status effects and instant death.  Instant death is easy to deal with.  Any effect that instant kills a regular monster does 8 instead.  Still strong compared to regular damage abilities, but not capable of dealing 30 damage to monsters.  It forces you to respect their health totals.  Instant kills that kill elites do 12.  Again, big numbers, but not that far out of the realm of what beatdown can do.  Curses don't delete an enemy attack entirely - they count as -3.  Still excellent, but big hitters still get to punch.  You can do the same for disarm.  At low levels these still function basically the same way, but at high level you don't get to just ignore the enemies.  If you really want to tear off the security blanket, then make curses and disarm only impose -2.

That deals with some of the problems.  The other problem is that gear combinations get out of control, and this is largely to do with stamina potions and the fact that players get so many potion slots.  Deleting stamina potions entirely prevents people from running outrageous combos back to back, and that goes a long way.  The other choice is to simply say that you get 1 potion no matter what your level is.  This basically means that every character takes a stamina potion, which is boring, but it does ratchet back their power level a TON.  You won't have a healing potion if you happen to get bashed, and you won't have other free stuns, bonus damage, and other effects that potions can bring.

In my home game the first thing I would try is nerfing disarms / curses / instant death effects, and combine it with getting rid of stamina potions.  I think that those things combined would leave players with a sense of progression as they accumulated gear but would prevent the worst combos from getting out of hand - you only get one shot at each card each time through your deck, and the most powerful cards that ignore enemy stats don't work.  I also think it would introduce more variety into potion selection because without stamina potions as the high level default choice you have all kinds of interesting stuff to choose from.

Ultimately you don't have to do this - you can just revel in your power when you are high level and roflstomp the monsters all day.  But I loved it when the scenarios were hard and we came down to the last card, and I want that feeling again.  Pulling back on the most brutal of abilities seems like a really good place to start doing that.

Tuesday, December 11, 2018

Helping the unfortunate

The AI in Civ 6 has some issues.  The game is incredibly complicated though, so I don't blame the developers - making an AI that is better would be a serious endeavour, and would certainly end up making the overall game experience worse.  You can't have a powerful AI for a super complicated task that runs quickly, and I have no interest in playing Civ with 15 minute intervals between my turns so the AI can think a lot.

But you can, if you work at it, do things to make the AI better that don't have any cost at all in terms of coding time or performance.

For example, in the game you gradually build up influence to earn Envoys.  Envoys can be sent to city states to earn their favour, and the attendant bonuses.  There are two early policies that you can implement to affect this.

1.  Charismatic Leader - earn 2 more Influence per turn towards Envoys.

2.  Diplomatic League - when you send your first Envoy to a city state, it counts as 2 Envoys.

Now the AI, when it is picking a policy, is going to pick randomly between these two things.  They both affect city states, they take up the same policy slot, and they show up at the same time.  The problem is that the AI will just park on one or the other (or perhaps swap back and forth randomly), but the player won't.  The player will sit on Charismatic Leader until they have saved up 3-4 Envoys, then swap over to Diplomatic League for a single turn, send their saved Envoys to any city state where they currently have no Envoys, then swap back.  In this way the player gets 90% of Diplomatic League, and 90% of the benefit of Charismatic Leader.  The AI gets 50% of each.  

I don't know if the AI is smart enough to never take Diplomatic League again once it has Envoys with every city state, but given the way the rest of the game works I suspect it will still have Diplomatic League in use even then, which is a total waste.

This is a crushing disadvantage for the AI, since the player gets nearly a full extra policy worth of power.  This can feel good for the player, using tactics to get a big advantage like this, but it means that the AI just falls behind, and that means that in order to pose a challenge the AI needs to be given lots of kludgy bonuses.  More production, more food, more science, etc.

When policies grant steady benefits over time the player can still maximize value.  If a policy grants a bonus to libraries and universities, for example, it pays to swap into that just as your universities finish production.  The trouble comes when some policies can have all of their benefits packed into a tiny span of time, and others are stuck purely giving ongoing benefits.

One thing I have been aiming to do is change these sorts of policies that have benefits that are packed into a tiny time span.  (Another example is Professional Army, which cuts upgrade costs by 50%.  Players swap into that for 1 turn, upgrade their entire army, then back out again.)  I don't need to get rid of their effects entirely, and I don't necessarily want to.  What I want to do is give those policies extra ongoing benefits so that if the AI parks on them it actually gets something out of the deal, and reduce the one shot benefits so the policy swap trick isn't so powerful.

For Professional Army I reduced the benefit from 50% to 25%, and gave it an ongoing bonus.  It is a fine policy for the AI, who will use it randomly, but swapping in to it for a single turn is way less broken for the player.  Diplomatic League on the other hand is a thornier beast.  The granularity of 1 vs. 2 doesn't lend itself to a partial nerf, so if I want to change it I have to change it completely.  I can just add on an ongoing benefit though, which wouldn't change anything for the player who is doing the policy swap thing, but would at least make it a decent policy for the AI.

I am performing similar changes for wonders, districts, units, and buildings.  When I see something that is just trash and you should never make it, I upgrade it until it is worth building.  Aqueducts, for example, are hot garbage.  You can reasonably build one to get a eureka, but never a second one.  That is a terrible situation because the AI keeps on building them, wasting its resources, and players never build them, so they have fewer interesting decisions.  I made aqueducts grant 4 food and 1 more housing, and now suddenly they are a good thing to build.  I don't make them in every city or anything, but now building them is a real choice.

My mantra here is that there should be many instances of 'sometimes' when discussing strategy and few instances of 'always' or 'never'.  If the answer to 'when do I build this?' is 'never' then something needs to change.  That isn't interesting for the player, and it makes the AI unnecessarily stupid.

Sunday, December 9, 2018

Marvelling at the infinite

In modding Civ 5 years ago one of the things I struggled to contain was ICS, or Infinite City Spam.  At launch the game greatly favoured a style of play where you completely ignore terrain and pack cities in as tight as possible, covering everything with trading posts.  Every city built the same buildings (Monument / Library / Market / Colosseum) and you went to infinity because every city improved your empire and brought in tons of money.  This isn't necessarily a failure from a strategy standpoint as there was still lots of decision making but it sure didn't feel as immersive or fun as actually picking your city locations and empire expansion based on situation / terrain etc.

I am doing the same thing in Civ 6.  The mechanics aren't identical of course because the game is different but the fundamental problem is still there.  In Civ 6 there is no reason to stop expansion.  Having a few core big powerful cities is good, but after that you should just keep on slamming down small cities in every nook and cranny.  Every city can build a Commercial Hub to get a bunch of gold and a trade route, and then a Campus to power out science.  After that you don't even care, and in fact you should probably prevent the city from growing so it won't use up valuable Amenities from the rest of your empire.  A carpet of featureless, identical cities stretching to the horizon!

Not great.

It is made even worse by later game buildings that affect all cities in a radius.  This encourages cramming cities in tight to fit them into the effects of Factories and Zoos, and means that every city starts off with a huge benefit, but still ends up being entirely interchangeable.

There are a bunch of ways to tackle this, but here are the major problems:

1.  Tiles.

Tile expansion cost in a single city scales up dramatically.  Getting a lot of workable tiles into your empire is a struggle, and requires immense culture output.  However, if you build a Settler your new city instantly grabs 7 tiles when founded, and can build a simple Monument and grab 3 more pretty quickly.  If you want more luxuries or strategic resources, same thing.  Spew out tiny cities to coat the map and you get everything easily.  Waiting for your big cities to expand enough to grab things is futile.

2.  Growth.

Growing new citizens in big cities has a ludicrous cost, easily getting up to 20 times as much as the cost of growing a citizen in a starting city.  If you want to work more tiles, you are far better off spewing Settlers for new cities that will grow quickly than trying to get citizens in big cities.  Growth also requires investment in Housing, and new cities get a bunch of Housing for free while big cities have to build things to get their Housing up.

3.  Districts.

Making science (and other resources) is best done with district production.  But each city can only build one of each district no matter how big it is.  Want that 18 science from a Campus, with Library and University?  (Counting a science CS and civic bonus.)  Well, you can get that from a size 2 city.  Your size 15 city already has a Campus and can't really do anything to get more science, because getting new citizens (see above) is painfully slow.

4.  Amenities. 

The first 2 citizens of a city don't cost Amenities.  That means you absolutely want to have as many tiny cities as possible because they can still produce stuff but they minimize your Amenity cost.  Adding 2 citizens to a big city costs 1 Amenities.  Adding a size 2 city costs 0 Amenities.  That is easy math to do.

I don't object to building lots of cities!  I like empires.  But what I want is two things:  First, that city site choice be highly relevant.  I want to pick my sites carefully, and for terrain to matter a great deal.  I don't like the idea that you just put cities in a grid, I want to choose based more on rivers and resources and such.  Secondly, I want expansion to come at a price.  Sure, I can build new cities, but I have to get infrastructure in place first.  If I just keep on slamming them down I should have problems, and it should negatively impact my empire.  Simply put, I want to have a situation where sometimes you expand because you are in good shape to do it, and sometimes you have to focus on building up infrastructure to support a later expansionary period. 

In order to do this I have to address all the points above.  I can't do much about districts directly.  Districts is a core part of Civ 6 and changing that would derail the game too greatly.  I would be pretty much starting from scratch, so I need to just let that go.  There are plenty of things I can do though.

First off I increased the rate of tile acquisition from culture.  I want big cities who invest in culture to be able to collect a lot of tiles so I dramatically reduced the cost of later tiles.  The early ones are the same, but you don't have to slam down a ton of tiny cities to get your stuff.

Secondly I increased the rate of growth for big cities.  The amount of food required to grow still rises, but it rises dramatically less.  A size 15 city requires 53 food to grow, whereas a size 1 city requires 20.  That is still more, but it means that you can realistically grow big cities instead of completely relying on spamming tiny ones.  (The base value for a size 15 city is 440 food to grow.) 

I couldn't totally change Districts, but I could change the way the buildings work.  Currently all the buildings in a District mostly offer flat returns.  Library gives 2 science, University 4, Research Lab 5.  This means that small cities can get nearly the same output as huge ones.  But I changed Research Lab and all the other top end buildings to add to tile yields instead - The Research Lab puts 1 science on every tile in the city.  That means that huge cities working more tiles get a massive benefit from the Lab, while a tiny city gets very little.  A huge city can build only one Campus, but it can still get paid off for having a ton of people.

Lastly I altered the Amenities formula.  No longer do you get 2 free citizens that don't require Amenities in each city.  The city immediately needs an Amenity to get started.  I gave the Capital 2 extra Amenities to keep the early game working, and increased the Amenities from an Entertainment Complex from 1 to 2.  That means that long term you can absolutely build a huge empire but it requires investment and time to get there.  You will need to build up Entertainment Complexes to keep your cities happy, and you can invest that happiness in new cities if you like - or just grow existing ones.

Expansion is still good.  You want to hold more territory, find more resources.  But with my adjustments you will have to consider when to expand and make sure you support your expansion.  If you have resources to spend, you could expand or you could invest in established cities, and the quality of that expansion site will really factor in.  In the base game it doesn't, really.  Always expand, never stop.  With my modifications it becomes a real question, and that is my goal.  Take those juicy spots and fight to keep them.  Build cities in prime locations.  But don't just slam them down in deserts or tundra without a thought.  Balance infrastructure and expansion.  Those considerations will make the game more fun for me, I am sure, and given the comments I have read on forums I think many other people feel the same.

Wednesday, December 5, 2018

A lacking of wonder

This past week I have been madly modding Civ 6.  Years ago I threw a couple thousand hours into modding Civ 5, and that same fever has seized me again.  Funnily enough I am changing many of the same sorts of problems and doing the same things over again, even though the game is entirely new.

The first thing that bothered me enough to try to fix it in Civ 6 was the Wonders of the World.  Wonders should, to my mind, be powerful.  They can only be built by one player, they cost a ton, and they have their own cinematics and stories.  All that build up shouldn't just go to waste on a terrible effect that nobody needs. 

Mostly, wonders end up ranging between hot garbage and mediocre.  The standard I use is the number of turns until the wonder has paid off its investment.  That is, if a wonder takes 900 production to make, how long until you get 900 production back?  The benchmark is how wonders compare to buildings.  Good buildings pay themselves back in 30-50 turns, and are pure profit from then on out.  There are some that are far better than this, particularly the early buildings like granary and monument, which can pay out as early as 20 turns from build completion.  To make this work I use the game's base assumptions, which is that production, food, science, culture, and faith are all of equal value, and gold is worth half of what the others are.  That isn't necessarily exactly right, but it gives you a ballpark.  I also assumed that great person points were worth the same as other yields, and while sometimes they can be way more, they can also be way less.  At any rate, that is the ratios I went with.

Some wonders paid themselves back really quickly.  Bolshoi Theatre and Oxford University, for example, give 2 free civics or techs.  Those usually pay back immediately, and then you get some small, decent ongoing benefits.  These wonders are solid, and need no changes.  They pay for themselves in a single turn, but they have a cost (a lost tile) and a risk (someone could beat you to it), so they aren't broken.

However, for the wonders that just generate resources over time there is an absurd range of power.  Chichen Itza, for example, would make your city about 10 stuff/turn once it appears, (assuming three workable rainforest tiles and another bonus resource rainforest tile), so it pays itself off in 70 turns.  That is *garbage*.  You would be far better off just building regular stupid buildings so you don't have to risk losing the wonder to somebody else, and so you don't lose a tile space.  Hilariously, Chichen Itza isn't even close to the worst, it is just weak, and virtually never worth building.

Sydney Opera House is the worst.  It is worth roughly 13 stuff per turn, costs 1850 production, and comes at the end of the tree.  So if, somehow, the game lasted 142 turns after you finished off the entire civic tree, then the Opera House would have paid itself off.  It is the saddest sack of crap you can imagine.

I have to fix these things.  Wonders don't have to be good for everyone all the time - it is completely fine for wonders to be good for specific strategies and not others, in fact that is a positive thing.  I want Mont St Michel to be only useful if you are doing the religion thing, and the Hermitage to be relevant to people who are aiming for a cultural victory.  There should be meaningful choices.  But when the choice is always 'don't build that wonder under any circumstances' then there is no choice at all.

And even those wonder that manage to get themselves into the 40 turns to payoff range, that isn't good enough.  Wonders aren't supposed to be about the same payoff as a generic Market or Library.  They are supposed to be *wondrous*.  You should be gunning for them and working to get them done because they impress you!  The risk you take in trying to build them and sometimes losing that race should pay off when you hit and get the wonder done first.  A sweet spot I have been aiming for is to make wonders do 2 things:  First, a premium payoff rate of 30 turns.  Second, some kind of extra, usually immediate, benefit.  For many of the wonders that has meant giving them free units, cash, or other payoffs that do something right away as well as generating an effective ROI long term.

For example, the Sydney Opera House got a modifier that makes it so that you get 10 times your culture per turn in gold.  This feels appropriate - at the end of the culture tree you get a huge payoff for building up culture income, and it is big enough that it is worth the wait.

The combination of math, coding, and creative thinking is great for me.  It is a feeling I get in particular from game design, and modding games is much the same.

I can't write any more right now.  I have more things to build!  Wondrous things!