Found this Soren Civ AI video…

Bibor, that´s a great find! Thank you very much for posting it. :)

As I think, this is very interesting for the players and modders of Civ 3, too (especially those who are rewriting Civ 3 at present) I made a post about your find in the Civ 3 forums, that can be found here.
 
Yeah, in civ4 essential source code was released to the community half a year after the vanilla game, because Soren wanted that really.

Screenshot from 2022-01-13 10-35-06-.png

Screenshot from 2022-01-13 10-36-38-.png



NDA. Civ6 saw the highlight of a lead designer "accidentally" opening a civilopedia submenu ...

3, 4, 5, 6, 7, the trend is clear and intact.

 
Last edited:
helped me a lot to understand how and why the civ AI works


I remember this being posted on this forum before.... Think it was in the AI topic? Good video indeed. Some good questions and answers too as I recall.
 
I was shocked to know that only 3% of the code of Civ4 was dedicated to AI behaviour. If they didn't dedicate more than that in Civ6, it's no surprise that the AI performs so poorly.

Maybe that's the challenge for Civ7: invest a lot in AI development instead of coming up with new systems or fancy artwork.
 
That is more like a trivia piece, the amount of code doesn't say much about the effort it took to write, nor about how well the code does whatever it does.

Design and AI are closely intertwined of course, but artwork is a separate thing altogether. Art doesn't conflict with AI except at the highest level of both being part of a game's budget.
 
That is more like a trivia piece, the amount of code doesn't say much about the effort it took to write, nor about how well the code does whatever it does.

Design and AI are closely intertwined of course, but artwork is a separate thing altogether. Art doesn't conflict with AI except at the highest level of both being part of a game's budget.

Yeah, generally speaking, anything dealing with drawing stuff on the screen for all the graphics and menus and whatnot end up taking up a hundred times more space than even the most complex AI. And sometimes when you use other utilities, they can do stuff like auto-generate tons and tons of code fragments just to make life easier for the developers, but it doesn't necessarily mean that that code is more "complex." AI code is kind of like an artist who stares at a painting for an hour, contemplates things, adds one stroke to it, and then calls it a masterpiece.
 
Yeah it's always an interesting vid. To me the good AI vs fun AI tension, and having to limit behaviors the AI can do (even if the player can do them) is always interesting to me. In 6, AI capturing City-States is a good example of that, where behavior that can make the AI a stronger player - capturing neighboring City States and expanding it's empire more quickly - had to be curtailed because too many players complained it wasn't "fun".
 
I was shocked to know that only 3% of the code of Civ4 was dedicated to AI behaviour. If they didn't dedicate more than that in Civ6, it's no surprise that the AI performs so poorly.

.
well also there are a lot more "rules" in six.
 
In 6, AI capturing City-States is a good example of that, where behavior that can make the AI a stronger player - capturing neighboring City States and expanding it's empire more quickly - had to be curtailed because too many players complained it wasn't "fun".

I've been playing NFP and the AI captures city-states very often. On the other hand the AI looses a lot of cities because of loyalty decrease, which makes the game too easy for the human player. Today I'll start a new game with Infixo's Real Strategy Mod and see if there's any improvement.
 
Yeah it's always an interesting vid. To me the good AI vs fun AI tension, and having to limit behaviors the AI can do (even if the player can do them) is always interesting to me. In 6, AI capturing City-States is a good example of that, where behavior that can make the AI a stronger player - capturing neighboring City States and expanding it's empire more quickly - had to be curtailed because too many players complained it wasn't "fun".

Yeah, that's always some of the balance of the game. Civ 4 had a solid balance, but sometimes it was too easy to "game" the system. Like, a few of the leaders all you had to do was share a religion and they would be a puppy dog to you forever. Civ 5 swung things in the other direction, where it felt at times there was nothing you could do and the AI would always turn on you at some point, so I never felt I could really make a lasting friendship. Civ 6 I think is decent overall, with the agenda system, although too often it just gets annoying. Like, I'm sorry I settle ONE city on a hill, is that really going to ruin all the trade we do together? Or at higher difficulty levels where if you don't send a delegation on turn 1 of meeting a civ, they will immediately turn sour on you and it takes 1000 years to get back to neutral.
 
That is more like a trivia piece, the amount of code doesn't say much about the effort it took to write, nor about how well the code does whatever it does.

Design and AI are closely intertwined of course, but artwork is a separate thing altogether. Art doesn't conflict with AI except at the highest level of both being part of a game's budget.

I was interested in Soren's comment about automated testing, including but not limited to running AI vs. AI games overnight. He noted that was different from his work on 3 to his work on 4. I *assume* that is much more common in the past 10 years and was used in the development of Civ5 and Civ6.

What criteria might be used to evaluate success from a set of automated tests? Setting up a game on a standard size map, letting 7 or 8 AIs play against each other, run overnight ... should they be making progress towards victory? Some combination of empire size and era score? Would the concerns of us (as players) be reflected in those testing criteria?
 
  • Like
Reactions: uhu
With the Civ4 AI tests, Soren would look at things like, have wars been declared? Did some AI conquer others? Did anyone win or get close to victory? There's also plenty of issues that can come up and you'd instantly recognize by looking at the state of the game. Like maybe you see that there's tons of unimproved tiles because the AIs don't rebuild lost Workers, or maybe you notice that every city has negative health, indicating the AI isn't able to deal with this. I don't recall many specific issues the tests found, but there were several instances where the overnight tests would show the AI was too willing, or too reluctant, to declare war.

Many of Civ4's lessons have been taken further in development of Old World. For OW, we have tests running round the clock where the AI just plays the base game and the official scenarios. These tests have caught many bugs with the game ending up in a state that should be impossible. We can also use them to get a broad view of what the AI likes to do, for example we've had to tune the AI's naval preferences a few times. At one point it built way too many ships, then we overdid it in the opposite direction so the AI would almost never have a ship, then we got to a much better place.

It's important to note that technology has advanced here. In 2004, it was pretty much Soren leaving the game on autoplay overnight and then looking at the map the next day. It took many hours to run the match. Now, in the case of Old World (but the same would go for other similar games), autoplay is much quicker, it's easy to dedicate a machine to just doing that over and over, and automatically log a variety of statistics.
 
for example we've had to tune the AI's naval preferences a few times. At one point it built way too many ships, then we overdid it in the opposite direction so the AI would almost never have a ship, then we got to a much better place.

In Civ 3 one of the key factors for building much more ships is to give ships an irrational low cost factor, another one is of course the seafaring trait. What are the additional factors in Civ IV and in OW ?
 
For Civ4, I just remember that we ended up with transport capacity as the guiding factor of the navy size. The AI would get serious about building a navy if it wanted to move troops to another landmass, and then it'd estimate how many transport ships were needed, and assign some ratio of combat ships to protect those. That's why with BtS, the AI can build large navies - if it needs 5-6 transports and builds another 10 ships to protect those, that's quite a navy.

In Old World, the issue with building too many ships was that ships look good "on paper" as a military investment. They have decent strength, so the AI would figure they're a good way to have a stronger military. That's of course incorrect, as ships have limited usefulness, so the AI ended up with a rule saying ships are worth less than land units for military purposes.

A lot of the AI boils down to getting the weights right. If it builds too little or too much of a thing, it's often over/undervaluing something. Often an easy fix by changing some numbers, you just need to have enough playtesting and iterative development.
 
The Civ4 AI does build decent invasion fleets in Civ4 in terms of transport vs combat shops but then it has a habit of landing 11 siege units and a crossbow. :D This is a pretty consistent outcome, surprisingly. AI naval invasion forces also tend to be too small which can be explained by the additional logistic challenges but the unit distribution mismatch is odd. AI land armies are usually constructed properly.
 
Solver and civac, thank you very much for your answers. :) For Civ 3, Flintlock has created an additional code, that allows a proper adjustable mixture of artillery and normal land units and should work with the next version of his patch even for amphibious operations.
 
I was shocked to know that only 3% of the code of Civ4 was dedicated to AI behaviour. If they didn't dedicate more than that in Civ6, it's no surprise that the AI performs so poorly.

From my experience, 3% is a significant chunk of any (complex) system. Just imagine how much "code" it takes my body to run the background tasks for me to be able to type this message.

In Old World, the issue with building too many ships was that ships look good "on paper" as a military investment.

Also true for IRL navies :lol:
 
Top Bottom