Thursday, April 25, 2019

Engineering

In my quest to help the Civ 6 AI I have found lots of little things that I can do, small changes that help in nearly invisible ways.  One of the things I felt I should try to fix is the Fort spam that the AI often engages in.  Forts are defensive structures built by Military Engineers, and each Engineer can build 2 Forts in total.  I have found Forts to be pretty much worthless because while they do grant a small defensive bonus that bonus rarely comes up.

Once you slam down a Fort you only get a benefit while the war is in that exact location - advance a single tile, the Fort is junk.  Retreat a tile, the Fort is junk.  If you put up a Fort and your enemy advances when you didn't expect it, they can even use it against you.  In any case that tile can't get a proper improvement to increase its productivity like a Mine and you have to sink 85 production into making it.  Forts are bad.

But the AI likes building Forts.  Especially in cities that have little productive territory, it would seem, because desert and tundra cities are usually surrounded by Fort after Fort, defending trash terrain that nobody would bother attacking anyway.  It is a waste.  I wouldn't mind this so much if the AI at least built Forts on its borders so it looked like it was doing something, but the tundra being filled with Forts smashes that illusion.

My solution was to increase the number of Forts a Military Engineer could build to 6.  I figured this way the player will still never build Military Engineers (beyond 1 to get the eureka, probably) but at least the AI will not have to build so many of them to fill the deserts of the world with pointless Fort spam.

This was a mistake.

The AI didn't respond by making less Military Engineers... no, it simply put Forts absolutely everywhere.  I walked into enemy territory to find big cities with 12 Forts surrounding them, covering all the productive territory.  My attempts to help the hapless AI simply caused it to do even stupider things.

Instead of making Forts cheap, I had to make them good.  My next solution was simple, and ended up looking a lot like my solution for Wall spam by the AI:  Add an Amenity to Forts.  I also restricted them to 1 per city, to avoid bizarre Fort spam.  The roleplaying justification is that people like knowing they are protected so building Walls and Forts makes them feel secure from war.  The numbers justification is that Forts are quite powerful when they grant an Amenity, but only having 1 per city means you won't be slamming them down everyplace.  Forts will cost more to build than a normal Builder improvement would, and they will be better.  Seems reasonable to me.

Now I just have to run through another game or two and see if this actually sorts out the problem or not.  If anything breaks it will be the Forts being restricted to 1 / city.  The AI may well end up with Military Engineers it doesn't have a use for, and they will end up wandering around pointlessly.  I hope not, but only real testing will tell.

Tuesday, April 23, 2019

I am the cylon

This past Friday on Lounge Day I played Battlestar Galactica for the first time.  People were kind of flabbergasted that I hadn't played it before, but after playing it I think my hesitations about getting into that game were warranted.

I was a cylon.  The game was five players, and in the first round it was four experienced players all being humans, and me, the noob, playing as a cylon.  At first I tried to sneakily damage their plans, and managed to do so effectively, I think.  There were several important failures because of my actions, but it wasn't completely obvious what was happening.

Then player 2 decided I was the cylon and took an action that either would toss me in the brig or damage the Galactica.  He declared that I was a cylon and he was going to brig me.  He was right, of course, but I vigorously denied it and the other players seemed inclined to agree with me, or at least be doubtful.  I had taken several aggressive actions to blow up cylon ships, to sell my 'but I am a human guys, seriously' position, and it had worked.

As a cylon, I want the ship damaged and I don't want to go to the brig.  So I should do nothing and hope the 'brig Sky!' plan fails.  As a human, I would want to avoid the brig, so I should do nothing and hope the 'brig Sky!' plan fails.

But at this point I was pretty sure I was losing and that all other players were humans, so I decided to do something interesting.  I voted to brig myself.  I put in five cards for the vote, and when all the cards were revealed it was indisputable that I had voted to go to the brig instead of damage the ship.  This caused player 2 to conclude that he had been wrong, as I must surely be human, but he still had to brig someone!

My plans, unorthodox as they were, had come together perfectly.  He was going to brig another human, and then I could reveal myself as a cylon and crush them mercilessly!

Player 2 rolled a die to determine who to brig.  He rolled a 2, and that said to brig me, so he threw me in the lockup anyway.  All my scheming, for nought.

Of course I convinced everyone else I was a human who was just the unfortunate victim of bad luck, so they spent some more cards busting me out of the brig.  Then I pretended to be bad at the game and convinced them to spend even more cards when I got a bad event - 'to protect the good cards in my hand'.  (My hand was total rubbish.)

Finally we reached the midpoint of the game and another round of human/cylon cards were dealt out, giving me the second cylon card.  I was all on my own against four players who know what they are doing, on a ship where *everything* was going the way of the humans, except for the few things I had managed to wreck up.

I revealed myself as a cylon, and hoped to turn another human into a cylon to join me, but they won the game before I even got another turn.  I believe I got five turns in total in the game, which seems ludicrously low given the way the game plays.  It was the fastest game any of them had even played, and the biggest shellacking of the cylons they could remember.

Partly that is because I didn't play correctly.  Partly it is because the cards came out beautifully for the humans, exactly the way they would have wanted.  Four pros against a noob, what do you expect?

But I don't care that I lost.  I am really happy with how I played, given that I was new.  I managed to cause lots of havoc, sow dissent, waste tons of cards, and kept the entire table in the dark about what I was actually doing by pretending to be stupid.  I played the *players* in a way that I am extremely pleased about.  I played the *game* in a fairly mediocre fashion, but that is just how it goes with a new game.

From what I hear the version I played is the worst possible version, the base game.  Lots of problems and holes in it, and huge randomness in terms of card ordering overshadow good play.  Still, I may give it another go with expansions to help fix the issues.

Probably not until next Lounge Day though.

Monday, April 8, 2019

Money *can* buy happiness

Civ 6 has a new patch, and it has a slew of exciting developments.  First off, Canada got a buff because it was mind bogglingly wretched.  Now it is better!  By which I mean it is still so bad that a civ with 'has no abilities' would probably be equally powerful.  Canada does have benefits, certainly, but they come packaged with two crushing penalties - one, the inability to war on city states or declare surprise wars, and a tundra start bias.  Those penalties are more of a detriment that all of its benefits combined as far as I am concerned, so Canada occupies a unique place at the bottom of the power rankings, even directly after a buff.  Ouch.

Also there are tons of other changes, most of which seem great.  Particularly awesome is the new map search feature that allows players to search for anything on the map.  I love it.  I am struggling to avoid saying "How was this not in the game before?"  I guess I failed at silence.  As usual.

However, there is one really weird thing going on with trading.  The AI was supposedly upgraded in terms of its valuation of things, in part to avoid certain exploits that existed where players could sell single bits of resources for huge sums.  Instead of selling 20 Iron for 60 gold, you could sell 1 Iron for 20 gold, for example, and take all of the AI's money.  In theory they closed that exploit, but now the AI just offers enormous, outsized sums for all kinds of things.

The conversation in the trade screen goes something like this:

AI:  Give me your Truffles!  I want that luxury!

Me:  Sure, give me 120 gold to have my Truffles for 30 turns.

AI:  No deal!

Me:  Okay, how about you tell me what you would give me instead?

AI:  I will give you 30 gold every turn for 30 turns.

Me:  ?!??!?!?

This is constant, basically.  The AI is conservative with raw gold, but it has no hesitation in offering huge gold per turn values for basically anything.  It sees no problem in paying me 900 total gold for a luxury.  In the early game this is leading me (and plenty of other players) to be swimming in gold, buying everything I want with the AI's treasury.  Sometimes I can't even find buyers for my stuff because they are already bankrupt paying me.  I don't even have to do anything 'tricky'.  I just put stuff they want in the window, ask them for an offer, and accept it.

This all seems ridiculous and totally broken.  However, when I asked myself how broken it was I was forced to admit that I have no idea what a luxury is actually worth.  How much stuff can I get for a luxury?  What is the correct price?

So I did some counting.

In the early game a simulated size 6 city is making 4 net food, 13 production, 7 science, 5 culture, no faith, and 12 gold.  A luxury gives one amenity to four cities, and each amenity has a 50/50 shot of having no effect (due to rounding) or pushing the city to a new breakpoint.  The breakpoint gives 5% more stuff (10% more food) so it is worth roughly 4 gold per turn, counting 1 gold as .5 other stuff.  A crappy city in the same era is generating about half the stuff, so if you have four cities, you could expect to get 6 gold / turn value from a luxury.  The AI used to offer about that much for a luxury, which seemed reasonable. 

However, this isn't the whole story.  The breakpoints are usually 2 Amenities apart, but there are three in a row at -1, 0, 1.  Also if you are in the negatives the food penalties are larger than the positive benefits of being happy.  This means luxuries are much better if you aren't happy, and are particularly important right around 0.  At a guess this increases the average value of luxuries by 50%, so in the early game when you have four cities with the best one being around size 6 you could ballpark the value of a luxury at 9 gold / turn.

In an endgame save I have I checked what the value of a luxury would be to my best city and my worst, and assumed those two cities hit a breakpoint and the other two cities the luxury affected missed the breakpoint.  Not a perfect model, but not bad.  This new math put the value of a luxury at a whopping 66 gold / turn!

Even with this new crazy valuation of stuff the AI never offered me anything like 66 gold / turn for a luxury, even though that would be a 'fair' offer.  However, it does mean that when it offers up 30 gold / turn I know that this is a fantastic deal for both sides - the best kind of deal!

So in the late game the AI is actually being totally reasonable in terms of valuing luxuries.  There are still serious problems though.  The first is that it is offering these huge sums in early eras when there is no possible way the luxuries are worth that amount.  It bankrupts itself buying stuff from me, and I can't buy luxuries from it because it demands similarly outrageous sums.

The other problem is that the trade deals are just as silly when it comes to strategic resources like Iron and Horses.  Those are useful, certainly, but there is no world in which they are worth hundreds of gold.  You can always just buy weaker units that don't cost strategic resources like archers or spears and have plenty of success.  At no point is a strategic resource worth the amount of money the AI offers for it.

I hope they patch this soon.  I suspect that it is simply a problem with the value of gold / turn, because the AI is hesitant to give out much in the way of up front gold, and when the AIs are giving gold to each other for disaster relief the gold they give is *preposterous*.  I had one AI that got an emergency declared for them because of a flood and they took in 25,000 gold in donations.  I suspect that is based on the other AIs flooding them with gold / turn because of inappropriate valuations of it.

Likely this is the sort of bug that can be fixed by changing a single constant somewhere in the code.  However, knowing that this is the way the math shakes out certainly tells me that I should be buying luxuries from the AI at 5 gold / turn as often as I can as soon as I am in the midgame and beyond.  I didn't realize how powerful luxuries were at that point, but now that I do I am going to use it.

Monday, April 1, 2019

Finding the foolish

In my latest game of Civ 6 I was intending on pursuing an all war strategy.  I picked the Ottomans as my civ of choice, and their special abilities are entirely about killing people and taking their stuff.  Of course I started up on a small continent entirely by myself, and because of the new weird barbarian spawn bug there were no barbarians at all on my continent either, so early combat pretty much wasn't a thing.  I normally play on Immortal difficulty with my mod that substantially buffs the AI and nerfs the most powerful human strategies so it is harder than normal in the late game but the early game is a little easier than Diety difficulty I think.

In any case I figured this would be a good test of the AI's ability to build when I am not killing them in the face, which is my usual strategy.  I sat on my continent, built nine cities, and just went all out on infrastructure.  I ended up needing a military at points to defend my allied city states against those violent Germans, but mostly I was content to build up.  By the end of the game I was a solid 10 techs and 12 civics ahead of the nearest AIs, and I won a cultural victory simply because it was faster than a diplomatic, military, or scientific one.

The early game is a challenge, but the late game is so easy that you can just sit back and let the AI have enormous bonuses and still crush it without trying.

So why is this so?  The AI had a significant starting bonus, production bonuses, and more territory than me.  I set out to examine their empires to see what they were doing wrong.  Some things I already knew about - AIs build navies on small lakes, for example, and I can't do anything about that foolishness.  But some things I hadn't really thought about, like the fact that they build full sets of walls in every city.  There is no point in building more than the cheap, basic set of walls for a skilled human, but the AI is bad at predicting where attacks will come from so it builds all the walls everywhere.  Better than building no walls and getting run over, I guess, but it is a devastating disadvantage to have to devote 530 production in every city to those higher levels of walls.

The idea I have to deal with this is to add +1 Amenity to the 2nd and 3rd level of walls.  Humans probably won't build those walls still, but if they do choose to do so it won't be such a total waste.  AIs will get a ton of passive Amenities, which is good because they aren't skilled at managing their Amenities and often end up with massively unhappy empires that have constant revolts.  This won't affect the early game at all, but will give the AIs a substantial boost throughout the mid and late game, which is exactly the thing they need.  I have already pulled out the free Amenity every city gets so the overall effect will be to have more Amenities in the game for those who build walls to protect their citizens, and reduces Amenities for those who leave their cities vulnerable.  Feels reasonable from an immersion standpoint, and should help balance too.

They also have a huge problem with faith generation because they like faith way too much.  The AIs try to win religious victories but this seems to involve them building holy sites in every city and then staffing those holy sites full of specialists.  They spend all of that faith pointlessly smashing missionaries into other people's empires (who defend effortlessly with Inquisitors) and lacking food and production because of that faith generation leaves their infrastructure otherwise terribly lacking.  Every AI who has a religion is locked into this mutual annihilation pact where they all throw themselves at faith generation as hard as possible and because all of them do this nobody gets anywhere.  All the civs who ignore religion get to build up powerful empires.

I think I just have to accept that AIs will build a lot of Holy Sites for faith generation.  However, I can fix the specialist problem.  It is as simple as making Holy Site specialists generate a combination of food and faith instead of straight faith.  This will mean that at least those AIs that are dead set on faith will be able to grow their cities, even if their production overall will be low.  I don't know what to say from a immersion standpoint - maybe those prayers are generating manna from heaven....?  But if the theme seems odd, at least the numbers should work out.