A Better AI.

In my present game, I did notice a large stack of longbowmen with city defense upgrades accompanying a huge attack stack of the AI. The total number of units used in the attack must have been something like 60-80 (split in several stacks). But there were about 20 city defense upgraded longbowmen units in the attack stacks and also about 10 pikemen (who are also better used defensively in general with a few to defend the attack stack). I'm happy to say that artillery (hwacha's and trebuchets) and macemen were the largest part of the stack.

You cannot tell what the longbowmen are meant to be doing just by looking at their upgrades. You need to be using chipotle mode (or go into worldbuilder and check each unit individually with edit unit). What you are looking for is the unit's "UnitAI".

The main unit AI used for defending cities is "UNITAI_CITY_DEFENSE", or "city defense" in shorthand. Most display areas under chipotle will display the full unit AI name, but I shortened the names some in the ctrl-key hover over stacks display, so that it would fit all on one line.

This spoiler shows all the UnitAIs (and the shorthand I used for the ctrl hover case).
Spoiler :

case UNITAI_UNKNOWN: szString = L"unknown"; break;
case UNITAI_ANIMAL: szString = L"animal"; break;
case UNITAI_SETTLE: szString = L"settle"; break;
case UNITAI_WORKER: szString = L"worker"; break;
case UNITAI_ATTACK: szString = L"attack"; break;
case UNITAI_ATTACK_CITY: szString = L"attack city"; break;
case UNITAI_COLLATERAL: szString = L"collateral"; break;
case UNITAI_PILLAGE: szString = L"pillage"; break;
case UNITAI_RESERVE: szString = L"reserve"; break;
case UNITAI_COUNTER: szString = L"counter"; break;
case UNITAI_CITY_DEFENSE: szString = L"city defense"; break;
case UNITAI_CITY_COUNTER: szString = L"city counter"; break;
case UNITAI_CITY_SPECIAL: szString = L"city special"; break;
case UNITAI_EXPLORE: szString = L"explore"; break;
case UNITAI_MISSIONARY: szString = L"missionary"; break;
case UNITAI_PROPHET: szString = L"prophet"; break;
case UNITAI_ARTIST: szString = L"artist"; break;
case UNITAI_SCIENTIST: szString = L"scientist"; break;
case UNITAI_GENERAL: szString = L"general"; break;
case UNITAI_MERCHANT: szString = L"merchant"; break;
case UNITAI_ENGINEER: szString = L"engineer"; break;
case UNITAI_SPY: szString = L"spy"; break;
case UNITAI_ICBM: szString = L"icbm"; break;
case UNITAI_WORKER_SEA: szString = L"worker sea"; break;
case UNITAI_ATTACK_SEA: szString = L"attack sea"; break;
case UNITAI_RESERVE_SEA: szString = L"reserve sea"; break;
case UNITAI_ESCORT_SEA: szString = L"escort sea"; break;
case UNITAI_EXPLORE_SEA: szString = L"explore sea"; break;
case UNITAI_ASSAULT_SEA: szString = L"assault sea"; break;
case UNITAI_SETTLER_SEA: szString = L"settler sea"; break;
case UNITAI_MISSIONARY_SEA: szString = L"missionary sea"; break;
case UNITAI_SPY_SEA: szString = L"spy sea"; break;
case UNITAI_CARRIER_SEA: szString = L"carrier sea"; break;
case UNITAI_ATTACK_AIR: szString = L"attack air"; break;
case UNITAI_DEFENSE_AIR: szString = L"defense air"; break;
case UNITAI_CARRIER_AIR: szString = L"carrier air"; break;


The UnitAI for a unit is the single most important thing to determining what actions the unit will take. With a few exceptions, once built, a unit never changes its unit ai. So a warrior built with an AI of explorer, will always remain an explorer, always doing exploring actions. Now, a warrior built with a unit ai of attack (the default for a warrior), may also perform exploring actions, when it has nothing better to do, but it is still primarily an attack unit. Each unit ai has its own set of orders of what to do.

For example, a city defense unit does this:
Spoiler :

  1. check to see if it should attack out of city
  2. check to see if it is needed to stay in the city for defense
  3. check to see if a settler group needs it for protection
  4. check to see if a settler on a transport that needs it for protection
  5. check to see if it can airlift to a city that needs it for protection
  6. check to see if there is a city we can path to that needs us to guard it
  7. check to see if there is an attack city group we can join (with less than 3 city defenders in it)
  8. retreat to the nearest city
  9. retreat to safe location
  10. skip turn


while a city attack unit does this
Spoiler :

  1. if it is solo, in its city, and has damage, heal
  2. if it is in city it just captured, remove all non-city attack units from the group (dropping them off in the captured city potentially)
  3. check to see if any city within one turn needs this stack for defense
  4. combine groups with any other city attack groups on the same plot
  5. attack any enemy city one turn away if power threshold is 250%
  6. bombard any enemy city in range
  7. attack any enemy city one turn away if power threshold is 100%
  8. combine with any city attack groups up to 2 turns away
  9. heal (possibly splitting group) any units at least 70% damaged
  10. if in local territory, load assault force on transport if one exists
  11. if in local territory, and enough units are headed to combine with this group (comparing the sizes of the two), and there is danger about, wait for those units
  12. attack adjacent city if odds are 30% or better
  13. if does collateral damage, attack any adjacent stacks of at least 3 units if odds are 45% or better
  14. attack any adjacent unit if odds are 60% or better
  15. heal any units that are at least 50% damaged
  16. if not at war with owner of current plot, heal if any damage at all
  17. if not at war with owner of current plot, and group is size 1, retreat to our closest city
  18. if this unit has a defensive bonus, check to see if there is a city in danger we need to guard
  19. if we are size one, check any city attack group within 10 turns, to see if we can join it
  20. if this stack is large enough, attempt to target an enemy city and send this stack to it
  21. heal if any units are damaged
  22. move to a staging city
  23. target a barbarian city
  24. airlift to a forward area
  25. retreat to closest city
  26. retreat to safety
  27. skip turn


Each UnitAI has its own list of actions it attempts. Once it is succesful finding something to do, it does not check lower down on the list.

Note, it is entirely possible to have, say, two longbows, both with city defense promotions, but one with a UnitAI of City Defense, and a second with a UnitAI of City Attack. These UnitAIs will determine the course of action those units take, more than anything else.

This is why I display the UnitAI under chipotle when you ctrl hover over a group. It is the UnitAI of the group leader that determines what the whole group will do (for the most part). An example of an exception of this, is when a city attack group captures a city, then it splits all the units off of its group which do not have the city attack AI. Note however, that its entirely possible that those units will immediately decide to rejoin the group, that is acceptible, but they are first given the chance to decide to defend a city.

It is groups, not individual units, that are counted to determine how many defenders a city has. This is why city defenders are never grouped when they are on city defense.

As far as when the build will be posted, the answer is when it is ready. I know that is not what you want to hear, but that is the best answer I can give you. No point in posting the build until that fix is in. :)

-Iustus
 
Question does the AI know how to properly use their UUs?

Short answer, yes and no.

Like the French Musketeer Instead of just defending cities like normal muskets, their better off used in pillaging raids when in war.

See my previous post about UnitAIs. When a city defense unit is built, in the Musketeer era, those are the units that will be chosen for that task, and a city defense musketeer is going to behave like any other city defense unit. On the other hand, when it wants to build a pilliage unit, it might very well choose to build a musketeer for that task, I have not checked it. (An easy way to test is to wait until the AI has learned gunpowder, or give it gunpowder with worldbuilder), then delete all its units will the UNITAI_PILLAGE unit ai (using worldbuilder), and see what type of unit it decides to build to replace them (if it has no pillage units, it will build some). It prefers 2 move units for pillaging, but I do not know if it will pick musketeers over, say knights.

or the Inca Quencha, When your near HC... You know he's gonna come with a SOD or his UUs and rush you, Same for the Aztecs Jaguars.

An AI picks the best unit for the task. If it wants a city attack unit, it looks at all its choices and picks the best one. In these cases, very often the best choice is its UU.

How about the Cho-ku-nu? Does the AI know that their UU Crossbowmen is capable of collateral Damage?

Yes, it knows the unit has collateral damage, and changes the behavior accordingly. If anything, it might make some mistakes because the collateral damage of these units is lower than that of a regular collateral unit, so it might be throwing these units away more often than it should. It never does attack calculations based on the number of hammers it takes to build a unit. For the most part, it only looks at combat odds and is it a collateral unit or not. I am not even sure if it is smart enough to use the highest collateral unit first, I think it may use the strongest unit first, regardless of how much collateral damage it does. (It will use all collateral units before all regular units, for the most part).

-Iustus
 
You cannot tell what the longbowmen are meant to be doing just by looking at their upgrades. You need to be using chipotle mode (or go into worldbuilder and check each unit individually with edit unit). What you are looking for is the unit's "UnitAI".

Thanks again for the information Iustus. It's always good to hear a bit about how the AI 'thinks'.
In this game the AI moved something like 4 or 5 big stacks towards another AI to attack him. (I had bought the first AI into the war after the second AI had declared war on me.) One of the stacks was almost completely made up out of city garrison II longbowmen, something like 20 of them. I thought that was rather strange and since you were talking about a (possible) bug with continuously spamming city defenders and then adding them to the attack stack, I thought this might be interesting.

I usually don't use the chipotle code as it provides you with spoiler information and that would devalue the game for me. However, if you are interested in this situation, then I can activate the chipotle cheat code and see if I can find a savegame close to when the AI moved its big attack stacks. Just let me know if you're interested and whether you want a savegame or chipotle information.

As far as when the build will be posted, the answer is when it is ready. I know that is not what you want to hear, but that is the best answer I can give you. No point in posting the build until that fix is in. :)

-Iustus

Yes, don't rush a build. Make it available when it's ready.
 
I usually don't use the chipotle code as it provides you with spoiler information and that would devalue the game for me.

The AI-AI trade information is moved in the next build so that you now only see that if you are actually in debug mode (ctrl-z) on top of being in chipotle. I think this may be the last case of information you gain under chipotle that you do not normally, assuming you can keep yourself from holding down the ctrl, alt, and shift keys when mousing over plots. ;)

However, if you are interested in this situation, then I can activate the chipotle cheat code and see if I can find a savegame close to when the AI moved its big attack stacks. Just let me know if you're interested and whether you want a savegame or chipotle information.

A screenshot, under chipotle, with the ctrl key down would be useful to take a look at those stacks. All I need is the textual area that you get in the lower left side when you hover over the stack, you can crop the screenshot down to just that.

-Iustus
 
The AI-AI trade information is moved in the next build so that you now only see that if you are actually in debug mode (ctrl-z) on top of being in chipotle. I think this may be the last case of information you gain under chipotle that you do not normally, assuming you can keep yourself from holding down the ctrl, alt, and shift keys when mousing over plots. ;)

I think, I will not tempt myself. I can always enable chipotle when needed.

A screenshot, under chipotle, with the ctrl key down would be useful to take a look at those stacks. All I need is the textual area that you get in the lower left side when you hover over the stack, you can crop the screenshot down to just that.

-Iustus

I am sorry. It is too many turns ago. I have 50 autosaves (one per turn), but it is more than 50 turns ago, so I don't have a save anymore. If I find another instance where I think the attack AI is doing something strange, then I'll enable chipotle and make a screenshot.
 
I also suspect an old bug may have resurfaced where an AI never thinks it has enough defenders so it continually spams them. If a defender is built, but then is attached to an attack stack, it is no longer counted as a defender. The code that decides what to build does one check to see if a defender is needed, if so, it builds one. Then once its built, that unit checks to see if it needs to be a defender, if not, then it joins an attack stack. Because of the way these things are set up, its really easy to get out of sync here, and constantly build defenders, think you dont need them, set them off on other things, and build more defenders. If you are running chipotle, you can hold down the ctrl key and hover over a city to take a look at the situation. You are looking to count the number of groups on city defense.

Hopefully this should be resolved in the next build.

-Iustus

Hopefully that's the source of most of these varied lines of complaints. Sounds like it might be.

As an aside, I think its really interesting to read this thread, even though I haven't had much time to keep up with the group testing of the various builds. Watching this collaborative effort come along has been a very interesting experience.

Ditto for the occasional strident poster coming in with their view on how this SHOULD be done... and I understand you wouldn't have time to read 80 pages to hear exactly what Blake, Iustus et al intend with every aspect of their refinements, but in many cases they've stated their aims, which in some cases are irreconcilable for what you want, in others just shades away.

All in all, a very entertaining and enlightening experience. Thanks for all the strong contributors, idea generators, robust testers, and of course the programmers for their roles in the thread. :)

I'm hoping to actually have some time to play later this week! And right now staring at potentially a LOT of time next weekend.
 
I'm just curious on the multiplayer aspect, if those saved games and asserts have helped the Better AI team track down what is causing the desync to occur?

I haven't had the chance to play any multiplayer games since the new build came out, so I have nothing to report. :(
 
Another Assert for you to look at...

File: .\CvSelectionGroupAI.cpp
Line: 412
Expression: iValue > 0
Message: iValue is expected to be greater than 0

Save game included. Just end the turn. Happens right after the Barbs move

Huge, Custom_Continents, marathon, Noble
 
Well, it's been a while since I posted about one of my games, so I figured maybe this would be a good time. Unfortunately, I don't have any visual aids, as I completely forgot about the PrtScrn button. This time, I played a vanilla (not Warlords) game with good ol' Washington (Fin/Org). I really miss the old Washington, even if he was quite cheap. I played a standard Continents game, with no options set, with the new Monarch handicaps. Since I couldn't use the assertive build, I used the 8 Jan build for vanilla.

Nothing really striking to report, except that I was consistantly between second and fourth for most demographics (and score-wise), except when I finally took first place (and generally held it) in the Industrial Age and Modern Age. My main competitor was Mao, who, surprisingly, jump-frogged me a few times, even during the Modern Age. I wasn't expecting this, being the cheap-assed SOB I was (Fin/Org is nice. Really nice.). Mao, in vanilla, has better traits (Phi/Org), so it makes some sense that he'd handle a large empire well, but I still had some trouble accepting that he could keep up economically. The AI seems to handle very large empire quite well now.

Tokugawa founded two religions, which pissed off Louis and Julius Caesar, both of whom were my religion (Confucian). Unfortunately, the 2000 year war between Julias Caesar and Tokugawa basically took them both out of the running. Thanks to Caesar massively weakening Tokugawa's defenses for me, I took two holy cities, absorbed half of the Japanese empire (Louis got the other half), and zoomed ahead in score. I experienced no significant war weariness, again thanks to Caesar. I merely cleaned up the wounded stragglers that he left in Tokugawa's cities.

On the other continent, Catherine seemed poised for a cultural victory, while Mao and Bismark were going for a space race victory. I bribed Mao into first killing Catherine, then attacking Bismark. When Mao became a threat, I brought up a vote for Environmentalism. Whether the other civs voted strategically or randomly, my tactic worked, and Mao's empire was crushed under the weight of its size (and standing army).

As the game wrapped up, I finished the Manhattan Project and decided to drop a nuke on Bismark's capital, which was yet still standing. Between my nukes and Mao's tanks, Bismark's dreams of a SS victory went nowhere. Mao and Bismark were originally quite close, but a vote for Free Religion changed that quickly enough. Maybe they should have opposed that and signed a defensive pact, rather than allowing me to play them off each other. Similarly, if Caesar and Louis hadn't committed to eradicating Tokugawa, at any cost, they might have stayed relevant. In any case, Caesar probably should have been pretty annoyed with me, seeing as how I used him to weaken his worst enemy, then stole half of Tokugawa's cities from his grasp. I think maybe I should have gotten worse than a -3 penalty for close borders from Caesar. Based on how obnoxious I was, I probably deserved a -5.

I can't think of anything else to say, really, except that war was a bit tedious and the tech pace was a bit slow. Neither was a big problem. I'd hate to go to war against someone on my own, though. Those defensive stacks are huge!
 
You know, I wonder how Aggressive-AI works on Noble with Better AI. Has anyone out there been testing this on Noble?

I have not been playing with it and, so far, I have NOT noticed any significant defender spam going on in AI cities (except in the capitals, which always seem to have ~10-15 units.) I have not had much trouble keeping ahead of the AI in terms of tech lately, but then until my first game after 2.08, I never really had trouble with that on Noble (and, honestly, I have had some very lucky starting positions in my last couple of games.)

I am playing a game on Noble with Aggressive-AI. I am ahead on Tech by quite a few tech's and have the most points. (I'm not usually ahead like this...) Defender unit spam haven't been bad, in fact the number of defensive units seem reasonable. However, the offensive unit spam is crazy as has already been reported. I hope that gets toned down soon. I am done with my attacking until this is fixed. I tried to take an island from the Chinese(sp?), I got one of their cities and then got hit by a stack of 60-80 units. I had newer units (Rifleman vs Swordsman and Maceman) but after 30 or so Chinese catapults and trebuchet's came to visit the advantage didn't much matter.

I think I know why I am ahead on tech, looking at the Chinese, they have approximately 80-100 Galleons sitting idle in their cities. I am playing an Island game so maybe there is a problem with the AI and Islands?

Also, I received this Assert: (I attached the saved game)

Assert Failed

File: .\CvPlayer.cpp
Line: 2668
Expression: getNumSelectionGroups() <= getNumUnits()
Message: The number of Units is expected not to exceed the number of Selection Groups

----------------------------------------------------------

Just hit enter.
 

Attachments

still using 8/1 build
4 human 4 AI each human teamed with one AI
8 way hub map, allways war
Direct IP

Still early game at the moment, the largest stacks we have seen have been about 5 units. No siege units have been researched yet.

all three AI players seem to be making a beeline for 1 of the human citys, where they stand around outside until anyother AI mini-stack shows up and then attack each other. They seem to be fighting for the right to siege the human player. The human in question is enjoying the show. His AI ally does not seem to be attacking anyone.

My team reasearched bronze workin early, and as it is allways war I thought my AI friend (Vikings) would base a city to claim his copper early. But no, his copper went unclaimed until around his 6th city. This may need looking at.

My machine started going OOS the turn I built a settler, and went OOS every turn until I had based him. I then built another settler and we are getting OOS on my machine again every turn. (we saved and ended the night before I formed the city).
 
It would be great if you guys could have a look into the forts issue, no matter how much biased some people might be against this sort of facilities ;). In Warlords the forts have been given additional bonuses and there are circumstances in the game when putting a fort or several forts in a proper location helps a lot. It would be great if the AI knew of several situations when building a fort would be helpful. There have been massive discussions here where people have listed such situations. Or perhaps it would be possible to produce an "optional Fort AI" modification? I would really appreciate it and I believe there are more people who would also use it.

I think this Better AI project is one of the most sensible things anyone here is doing. I also liked the Genetic AI project a lot, even though it seems dead or umm.. temporarily dead now. Thank you for your work, guys.
 
It would be great if you guys could have a look into the forts issue, no matter how much biased some people might be against this sort of facilities ;).

Personally I'd rather see their attention focused on other issues, such as fixing the AI military spam bugs. Seeing arms races everywhere in recent builds has led me to reluctantly abandon Better AI until it gets straightened out. I'm a :hammers:er, not a :strength:er. In the last couple builds, protecting yourself in a war has felt like playing chess with a thousand pieces to keep track of. And there's no chance at all of launching one of those surprise attacks I occasionally enjoy. Even if I throw all my best units at a single weak city, I'll be crushed.

I think the Firaxis developers should be the ones fixing the forts, in the core game so that mods like Better AI would not need to change the ruleset. I would only consider them "fixed" if they are allowed to either co-exist with other improvements (besides roads and forests) or exert a zone of control...

In Warlords the forts have been given additional bonuses and there are circumstances in the game when putting a fort or several forts in a proper location helps a lot. It would be great if the AI knew of several situations when building a fort would be helpful. There have been massive discussions here where people have listed such situations. Or perhaps it would be possible to produce an "optional Fort AI" modification? I would really appreciate it and I believe there are more people who would also use it.

... but I haven't used forts myself or followed these discussions you refer to. Would you be willing to summarize the situations where you use forts (and think the AI should too)? I'm curious. Thanks :).
 
Consider this post by Blake in response to a previous fort question.

"Are you considering adding in Fort AI?"
Blake said:
Short answer: No.
The long answer would still be No.

Forts are useless, end of story.
 
I agree the unit spamming issue is the no. 1 issue at the moment, I agree that the forts should be a secondary goal. A link to a strategy thread dedicated to the use of forts: http://forums.civfanatics.com/showthread.php?t=134339

Note that this discussion concerned the vanilla forts which were almost 100&#37; useless. Now they were given an additional bonus and there mods available which even add them a ZOC which is a huge change. But even without a ZOC (unaltered gameplay) they are useful - mostly in the choke points and as bases for counterattack during enemy invasions. This mostly depends on one's gameplay style. Forts can also be used to disable the enemy from appearing right in front of a city in one turn's time, which is important in active defense strategies (with more mobile defensive forces that need at least one turn to arrive at the endangered location, and even if they're already there, remember thtt every turn of delay equals a 5% bonus to defense). Forts also serve as secure "hospitals" where you can withdraw your units if there are no friendly cities in the area. The AI should know that it's worth it to put a medic unit in a fort and if it has such a "hospital" at hand, it should withdraw there to heal. A fort sometimes also serves as a border base for your forces enabling them to capture enemy cities within 1 turn from the declaration of war if there are no friendly cities that could serve as such bases. A fort put on hills+jungle gives a 100% defense bonus. 100% means double as much. In such a fort a longbowman gets his city defense bonus + a 100% tile bonus. Now think of the amount of enemy forces necessary to take this guy down. And this guy is providing cover for your 8 units that are heavily wounded and escaping fast enemy units. A few turns of construction is not a high price for this.

I'd like to repeat that I don't consider this a #1 issue. But I do consider it one of the 5 most important things that I would really like in this AI project which is a huge step forward in comparison with the Firaxis AI. I think that Blake can do what Firaxis could not do = teach the AI to recognize situations when a fort is useful (there aren't many) + teach the AI to man them and use them for counter-attack purposes.
 
This thread is virtually impossible to follow due to it's immense size and large amount of off-topic chatter. Maybe a sub-forum is in order? New threads for each update etc?

You can always go to the sourceforge site for the latest builds including release notes.

That said, I am not opposed to having a sub-forum, if the consensus is that it is a good idea.

-Iustus
 
You can always go to the sourceforge sitefor the latest builds including release notes.

That said, I am not opposed to having a sub-forum, if the consensus is that it is a good idea.

-Iustus

I think a sub-forum would be great. You could have a stickied thread with stuff like Versions, Design Goals, Installation Instructions, Known Issues, etc. and then separate posts for the topics I've seen a lot of here like Bug Reports, General Feedback, AI Military Spam Problem, Forts, Victory Strategies, Military Strategies, Leader-Specific Strategies, etc.

In particular I'd love to see a summary from the developers of Better AI that explains the design goals and keeps track of progress on all of them. For example, I was thrilled to read about the specific changes in worker and city governer AI in this forum, but I could have easily missed them since I never automate any workers or governors when I play. I guess that means I'm asking for more work on your (Blake/Iustus/etc.?) part, and I don't want to take your time away from development... but that would enable us give you better feedback too if we knew exactly what to look for.

Thanks for your awesome work!
 
Another Assert for you to look at...

File: .\CvSelectionGroupAI.cpp
Line: 412
Expression: iValue > 0
Message: iValue is expected to be greater than 0

Save game included. Just end the turn. Happens right after the Barbs move

Huge, Custom_Continents, marathon, Noble

Also, I received this Assert: (I attached the saved game)

Assert Failed

File: .\CvPlayer.cpp
Line: 2668
Expression: getNumSelectionGroups() <= getNumUnits()
Message: The number of Units is expected not to exceed the number of Selection Groups

Just hit enter.

Please keep up the bug reports like this. Both of these (and several of the others posted earlier in this thread) lead directly to bug fixes that will be in the next build.

The success of this assert build means that the next build we post will have both a regular build and one with asserts in it. I request that you run the assert version if you possibly can, as it will greatly help with tracking down lingering bugs, and will not have a significant speed penalty. People playing in fullscreen mode have to be a bit careful running the assert build, just because of how Windows works. (If you do not dismiss the window before you click anywhere else, you can get wedged).

If you get a recurrant assert, you can always click the always ignore button (this only means during the current session, if you quit the game and run it again, it will give you the assert again).

-Iustus
 
A sub forum is a very good idea. I agree that it's almost impossible to follow most anything here. Plus, we get people asking questions that were answered not even 2-3 days prior, simply because they didn't see it. This thread gets about 2 screens of posts a day.

Wodan
 
Back
Top Bottom