AI All-terrain transport development

cephalo

Deity
Joined
Jul 26, 2007
Messages
2,058
Location
Missouri, USA
Ok, I'm taking a first look through the code and I see that Koma13 made it so you can build transport units in any city. I hear this code comes from Maniac.

What I'm not seeing is any modifications to the unit AI. Therefore, I assume that the AI might build transports in any city, but it will only actually load them on a coastal city.

Theres a boolean all over the unit AI code called bLandWar. This variable is set by the AI state of the area that the unit is in. As far as units loading onto transports, I might be able to change this from an area analysis to a distance-to-target analysis. The difficulty is that I don't think the target is known by the AI at this stage, I may have to do a separate calculation.
 
While I know absolutely nothing about AI or code details, my understanding was that there is no longer such a thing as a coastal city in the mod.
 
Ahriman is correct, isCoastal always returns true in DW.

I support the general goal of this thread, but you may need to draw attention to it from the BBAI forum and also the folks following TheLadiesOgre's thread.

The canonical goal of "Land Transport" is that on a pangaea or solid earth map like greatplains, a slow infantry unit should be carried by the land transport to a target city. Presumably the land transport is fast, but vulnerable, and therefore the AI should build an appropriate number of fast, strong (but not cargo-carrying) escorts.

If you can do this, you will become rich and famous. Or at least famous. At least at civfanatics. ... But could you also work on the starting location problem in the existing mapscript?
 
If you can do this, you will become rich and famous. Or at least famous. At least at civfanatics. ... But could you also work on the starting location problem in the existing mapscript?

Well, this solution might not work in a mod that needs land transport and sea transport. I'm purely focusing on the needs of this mod.

The problem with fixing the starting plots on Arrakis.py is that I need to control the size of continents. That is impossible under the current implimentation and will require a nearly gound up rewrite. That is going to be alot of work, and the results will not look very nice.

Before I do all that, I want to find out whats involved in AI all terrain transport. If I'm in for alot of work, I would prefer a large complicated solution to a large complicated work-around.
 
Another issue that concerns me is that if I can get the AI to load up for land wars, it may simply cause them to unwisely split their forces if they are low on transports, while the understrengh transport speeds ahead without the main body.
 
Well, I pumped up Arrakis.py to give me a pangaea, and I did a few tweaks to see if I could cause the AI to always use available transport no matter the distance. Probably because I'm on a pangaea, the AI is not building any transports at all. Tommorow I will investigate the production choice.
 
After some more investigation, I'm going to scrap my original experiment. I think I found the heart of the issue. There's a function called CvTeamAI::AI_calculateAreaAIType that decides for each team how to treat the different areas(continents).

For example, if you have cities in an area, and your enemies are more powerful than you in that area. The areaAIType is set to AREAAI_DEFENSIVE.

In order for an amphibious assault to happen, the continent you are on must be set to AREAAI_ASSAULT, which only happens when there are no enemies in this area. If there are enemies in an area, that area is generally set to AREAAI_OFFENSIVE. In a normal amphibious assault, the staging area will be set to AREAAI_ASSAULT and the destination area would be set to AREAAI_OFFENSIVE.

Unfortunately, a continent can only be one or the other. I don't know what would happen if you set an area to AREAAI_ASSAULT while there are enemy cities on that area. Transports would be built and loaded, but I'm not sure if they would attack those enemies on the area. If you switch to AREAAI_OFFENSIVE when everyone's ready to go, they may simply unload the transports and travel on foot.

I don't think this is insurmountable, but it is a bit complicated.

On a side note, I think I found a bug in this function. The function has been fairly chopped up by the better AI guys, so this may be due to something they did.
Code:
CvPlayerAI& kPlayer = GET_PLAYER((PlayerTypes)iI);
I think the index "iI" is a garbage value left over from a team loop. It is uninitialized. Not sure what this will break exactly, but it might prevent the proper massing of troops in the intended case.
 
I've read about these AREAAIs before in this post diagnosing a Planetfall issue.

It does sound like you've got to the heart of the issue. Good luck with finding a solution.
 
I've read about these AREAAIs before in this post diagnosing a Planetfall issue.

It does sound like you've got to the heart of the issue. Good luck with finding a solution.

Interesting thread. Do we have any units that are expected to cross water and attack on their own? If so they probably don't work so well. While I'm here maybe I could look at that as well. Apologies for not being aquainted with all our units, life keeps me busy.

That brings up some more questions regarding our units. Are all our attack units able to be transported? I assume from my investigation that suspensor gunships are sea units that can move on land and not attack units. Otherwise they would lose their brains on entering the ocean.
 
Do we have any units that are expected to cross water and attack on their own? If so they probably don't work so well.

Yes, thopters and suspensor gunships/frigates/destroyers are combat units that can cross desert.
But they are weaker than land units, so its actually a good thing if the AI doesn't try to attack you a lot with those by themself, they'll just get them destroyed.
Half the role of these units is as transport escorts.
 
Ok, after some more investigation I have a plan for the next experiment. I am going to set an area to the land war settings (AREAAI_OFFENSIVE, AREAAI_MASSING) if the proximity to the enemy cities is close, and set it to the sea war settings (AREAAI_ASSAULT, AREAAI_ASSAULT_MASSING) if the distance is long. This will cause the AI to build and load transports and such.

Transports moving to the drop zone(coast adjacent to a fairly weak city) do not appear to use the areaAI settings, so I should be ok there.

In order for the attack units to attack in an area designated for sea war, instead of walking back home, I'm going to treat the sea war settings as land settings in the unit AI when the unit is on or near enemy territory. Hopefully I can do that efficiently as the unit AI's appear to be a performance bottleneck.

Anyone see a problem with that?
 
Are there any major AI issues that I need to know about while I'm testing? So far I'm not seeing the AI declare war on each other, even with aggressive AI. Is that uh... my fault?

When I force a war with random declarations, I'm not seeing any stack of doom on transports. I think I broke something. The AI is building transports now and even driving around with a unit on board once in a while, but to no purpose. No cities have been taken except for barbarian ones.

I need to start at the beginning and hand execute the whole AI process. I'm still a little fuzzy on some things. I'm sure that with the proper knowlege this is doable.
 
Several people have observed that the AI is not declaring war often. I have not obtained any statistics on this yet. I recommend you do a run of vanilla archipelago and compare the number of DOW's. Although we do not need to exactly match archipelago, there are substantial gameplay differences between archipelago and everything else. So if you see that vanilla archipelago and DW are similar, the problem is with vanilla AI, not specifically with DW.
 
I tested 1.5 without my changes and I definately saw cities changing hands. I must of just disabled city attacks with my changes.

That's kinda the nature of this AI code, you can't just tweak things really without the possibility of cascading consequences. It's not object oriented at all it's just a big long ai function. If you make something happen in one place and another place was not expecting that to happen there, you will break something unrelated to what you wanted to change.

I am in the process of reading through all the AI code. The only way to control it is to fully understand it.
 
I'm getting more familiar with the code, and it's alot of work but I have to say it's an interesting read. I have some thoughts I wanted to bring up.

The idea of transport in Civ4 was always rooted on the need to get from one land mass to another. This is slightly different than real life, where there is the additional motivation of travel time. Sea travel historically had this advantage over land travel, but in Civ4, the AI would not load up a settler on to a boat just because it's faster to get to a different part of the same continent by boat. (across the mouth of a large bay for example)

Land transport actually does exist in Civ4 but it is abstracted. Mechanized Infantry for example is really just a bunch of soldiers loaded into a faster moving vehicle. Some games actually abstract sea travel this way also, where the land unit just becomes a boat when it enters the water.

By abandoning the notion of transporting for speed purposes, it allows the AI to bypass many important decisions by simply setting an AI state for each continent. Otherwise, you have to decide for every move whether it would be faster to take any available transport. Easy for the player, expensive for the AI.

I think I can rig the continent system to distinguish between a distant war on the same continent and a land war between close neighbors to preserve that computational efficiency, but then there is another problem for the AI in regard to large continents.

Let's say you have a large empire on a large continent which is shared with another power you are at war with. The player can load up transports in cities that are far from the front lines and go on foot from production centers near the front without waiting for transports. The AI has to choose either transports or walking. It can't do both with the current continent based decision making. In civ4, this is not an issue because the road and rail networks largely negate the need for explicitly using fast transport units on land.

In order for the AI to intelligently use transports for speed, I might need to generate alot more paths. That could slow things down.

So there are two ways I could go about this, but they each have potential drawbacks. The easier method might leave the AI at a disadvantage, but the more thorough method would need alot of significant changes and may slow the turns down considerably.
 
cephalo said:
Let's say you have a large empire on a large continent which is shared with another power you are at war with. The player can load up transports in cities that are far from the front lines and go on foot from production centers near the front without waiting for transports. The AI has to choose either transports or walking. It can't do both with the current continent based decision making.

I would think in this circumstance it would be better choose transports over walking so that when the force arrives it arrives at speed.

I'm wondering how all this will affect the units we have that can walk on ocean and coast. In particular, the Fremen units that get double movement on ocean/coast. I suppose it is going to get too complex to have the AI use these effectively as well as Land Transport. I've advocated removing the ability to build vehicles from the Fremen. Would that help?

I think slowing down turns too much is obviously bad, but if a little slowdown is the price of improved AI I could live with it. The AI is already at a disadvantage - anything that puts it at less of a disadvantage is going to be an improvement.
 
I'm wondering how all this will affect the units we have that can walk on ocean and coast. In particular, the Fremen units that get double movement on ocean/coast. I suppose it is going to get too complex to have the AI use these effectively as well as Land Transport. I've advocated removing the ability to build vehicles from the Fremen. Would that help?

After looking at the AI, I would be surprised if the Fremen could attack another continent without transports. If you take away their transports I don't think they would try to invade without some extra AI logic in place to utilize their ability to cross the desert.
 
Well, I've been whacking away at my keys for about 8 hours straight. It's not very often you program for that long and have no bugs in the first test, but I have good news and a screenshot.

This is on a version of Arrakis.py with a very high land percent making it a pangaea. All the land except for a few small islands is connected.

Spoiler :
attachment.php


What you are seeing is a floating stack o' doom travelling over land and sea to attack mr. orange on the left. Mr. green already did the same from the south and took a city in the process!

My eyes are burning and I need sleep. So I have to go to bed now. Tommorow I'm going to do some more testing to make sure I'm not just delerious. My luck can't be this good. Anyway when I'm confident of success I'll turn over the goods.
 

Attachments

  • StackOfDune.jpg
    StackOfDune.jpg
    270.7 KB · Views: 206
Back
Top Bottom