Waste of Processing?

Redvers

Chieftain
Joined
Nov 4, 2012
Messages
15
Hello internet,

I have recently started playing Civilization 5 and have made an observation I was hoping to get clarified.

I tend to put a few military/scout units on hills at or just beyond my border to keep an eye on things and have noticed that the AI seems to spend 90% of its turn time making pointless moves 'just because'.

First example of this was Sweden who I was at war with (he declared me, the meanie). I beat him to within an inch of his life then just sat a few units on hills outside his borders 'keeping an eye' while I build up for the siege on his capital. He had a melee unit, spear I believe, adjacent to his capital and between turns it would alternate between fortified / unfortified over and over again. Now with the handy new feature showing who is currently taking their turn I noticed that Sweden took about 5 seconds, not long at all. Fast forward ten turns and he now how 2 more units around his capital and again every turn he would alternate between fortifying them and unfortified them, and the time taken for his turn increased ever so marginally.

Second example is two city states on my borders going about their business, and a French warrior unit. Now the city state units, along with the French warrior unit, were just going back and forth between two hexes, be it between plains and a hill, forest and a hill, whatever - just back and forth, back and forth over and over and over again. Now for the City States I can attribute this to a sort of pseudo patrol but I wonder...

Time for clarification and thoughts:

Would the time taken for AI turns be decreased, marginally or dramatically, if the AI didn't make useless moves? At war? Stay fortified by your city.
City state needs to patrol? Why doesn't it fortify on a hill to see everywhere instead of moving between a plains where it has no los and a hill where it has plenty?

To me it is beginning to look more and more like the AI has to move every unit, just because it can move them, and I wonder if this is one (of many) factors that steadily makes for long as sin turn times. Late in the game a dozen city states moving a dozen units back and forward for no reason, or another major AI doing meaningless back-forward, fortify-unfortified movements seems to me like a massive waste of whatever fuel powers this engine.

Anyone else have similar observations? Ideas to combat useless moves for the sake of moving? Perhaps an addon that scripts the AI to like having X% of X-Range of its territory known so to help with defense, I dunno.
 
I've noticed before how that if I was playing on LAN with my brother, sometimes the game would mess up and the AI would end up taking one of our turns.After that was when the AI seems to have moved possibly every unit we had.

Who knows what they do when we're not looking?...

Edit:Oh and welcome to Civfanatics!
 
ive noticed they do this as well, a great tendency to move units regularly, though they also will keep some units stationary, fortified against you etc. my theory is that they shift their units to avoid you being able to line up your units in perfect order to attack, by shifting units every single turn it makes it more challenging to attack them.
 
my theory is that they shift their units to avoid you being able to line up your units in perfect order to attack, by shifting units every single turn it makes it more challenging to attack them.

I think you're giving the AI more credit than it deserves.:)
 
I'm back with more observations.

Fast-forward 200 turns (I play marathon) and the world is very populated. While exploring the second continent with a scout I saw several units (3-4) belonging to another AI and all the units were again going back and forth. I sat there for about 20 turns and watched as 2 units went between jungle tiles, surrounded by jungle with a hill beside each that was never climbed.

So what the AI was doing with these two units makes me think that something in the AI script ticked a box for "explore" but because it went into a jungle it couldn't see (more jungle ahead) so it did a retreat back to home territory, where immediately the box for "explore" got ticked again.

The third unit, a warrior, was going back and forth over a river, from a forest plains to a grassland, back to the forest plains. The forth was bouncing between two grasslands, and archer this time.

So for this one small patch of land on a standard map, 4 units were eating my computer's resources just going back and forward with no rhyme or reason. I seriously doubt this was tactical as the AI was at war with no-one. Though I have only been playing a short while it looks to me that there is some serious defect with the AI that is making it loop action until something major (War!) supersedes its otherwise benign behavior.
 
The AI have always done the meaningless back and forth dancing (or whatever it is doing when it has nothing better to do), regardless of civ version. Sure this can be anoying, especially when you have fighters and can see further out.
 
They have been doing this back-and-forth thing as far as back as Civ2. Civ4 was notorious for this since there were a lot more units in play. Just the nature of turn-based unit programming, I guess.
 
I'm not privy to the design decisions for this but I think there are 2 fairly good candidates for this and one already mentioned

1) Shuffling units at their borders prevents the player from sending in an attack force on a preset vector. Instead of attacking a static defence the players would need to adjust their frontlines to account for the moving units

2) Line of sight/border scouting. If the AI is not omniscient, and follow line of sight rules to find out about enemy troops at their borders, it pays to have 2 units move around their borders to spot a certain territory, rarther than 4 static units to spot the same area.

It is however worth noting that in Civ3, the units did shuffle around but in that game, the AI was omniscient (the game knows where all the units are on the map, although this information is possibly not shared with the lower level military AI) and the shuffling was turned off in later patches to speed up performance.

I'm less clear on what the purpose is for shuffling in Civ4, but I assume for the same reasons as 5.

But Civ5 in particular, with its more limited unit support and 'smaller scale' games would tend to benefit the most from shuffling to maximize line of sight.
 
1) Shuffling units at their borders prevents the player from sending in an attack force on a preset vector. Instead of attacking a static defence the players would need to adjust their frontlines to account for the moving units.


yes, you state it better than i did, this is exactly what im thinking in terms of the devs decision in making the ai behave as it does in this. a static defense would be too easy for the human player to outsmart, so the constantly shifting units ensure a level of unpredictability every turn.
 
At higher levels (Immortal/Deity) the AI has so many units though. They should use a combination of static fortified units on rough terrain (if available) and shuffling "patrol" units, especially when defending a static object, this being their cities. They even have enough units to ALWAYS attach a ranged unit behind said fortified unit. One of their free workers could be assigned to build a fort under the fortified unit.

I don't have much in modding skills so I am wondering if this type of procedure would be possible with the code they opened up in the patch. Anybody know?
 
I'm not privy to the design decisions for this but I think there are 2 fairly good candidates for this and one already mentioned

1) Shuffling units at their borders prevents the player from sending in an attack force on a preset vector. Instead of attacking a static defence the players would need to adjust their frontlines to account for the moving units

2) Line of sight/border scouting. If the AI is not omniscient, and follow line of sight rules to find out about enemy troops at their borders, it pays to have 2 units move around their borders to spot a certain territory, rarther than 4 static units to spot the same area.

Let me add a third option.

3. It is there to actually make turns faster, since forcing a move (in Civ5) gives the AI 6 options to process but allowing them to stay in place (for reasons other than healing or defending a city) gives every unit a 7th option every turn. That's a 14% reduction in choice the AI has, which, I imagine, should actually speed up turns.
 
Let me add a third option.

3. It is there to actually make turns faster, since forcing a move (in Civ5) gives the AI 6 options to process but allowing them to stay in place (for reasons other than healing or defending a city) gives every unit a 7th option every turn. That's a 14% reduction in choice the AI has, which, I imagine, should actually speed up turns.

Mind blown. Good stuff.
 
For people actually giving the developers the benefit of the doubt and trying to provide a logical reason for the constant unit shuffling there are two big holes in the two basic trains of logic.

1) If it was for line of sight/scouting purposes then does the AI not get line of sight from its cultural borders like the player does? i.e. shuffling units around in it's own border (as in the majority of the cases you see this happening) is pointless for scouting/gaining line of sight as they can usually see more from their cultural borders or at worst see just as much apart from in a few cases where certain units have added line of sight. If it was isolated to units moving outside their borders and/or units with added sight then this logic would have some weight, as it is this logic is flawed.

2)The other main logic seems to be to provide a harder target for a player to attack but this doesn't really pan out either as for a start, by moving the units lose their fortification bonus and often move between open and rough terrain thus weaken their ability to defend against an attack.
This could be excused if the shuffle was isolated to mounted units for example but it is usually melee units you see doing the shuffle.

If it was actually this poorly designed to provide a harder target there are many more effective ways to provide a better defense and for the most cases out of sight of the enemy which also wouldn't be such a large drain on resources.i.e. by not needed to move the units constantly.
A prime example would be finding a good defensive position and fortifying there, a couple of tiles inside their own border where they are out of sight of anyone not inside their own borders.

The most logical reason i have ever seen for this large drain on resources is to do with the AI blocking the path of player units, this mainly applies to city states which can often be placed in central areas or bottlenecks which means the AI can easily block access for units (civilian units in particular) from one part of an empire to another. This also applies in a smaller degree to open borders agreements although this is usually a short term problem of units passing through your territory and blocking road access to civilian units which can't pass through units not belonging to you even when they are not an enemy and particularly in your own territory.

If this is the logic behind it then there is one simple solution which like many aspects that need improvement were in previous versions and that is simply to allow civilian units to pass through units of other nations.

Overall though there can't be any real understanding or solution to this larger drain on resources without a explanation of the reasoning from the developers. If we knew the actual reason for this happening then we could properly discuss ways to improve the system so the unit shuffle is not needed or can at least be reduced.
 
To further Fluff's reply...

I had another game last night (continents) and found myself settling at a sort of bottle-neck. It was 4 tiles wide and to the south was 2 city states and about 10% of the landmass.

When I placed my capital, and after it first grew, there was a 1 tile sliver of coastal land left outside my borders that the AI could access the southern portion of the map. After doing my exploring I return my now archer-scout to my capital, along with a warrior one of the southern CS's gifted me. Knowing none of the AI on my continent had passed by I set these two units up along the coast (my border was yet to go clear across the bottle-neck) so that the AI could not access the south and meet the CS's.

What resulted was two scouts (England and Monty) reaching my units, seeing there was no way passed, then turning back the way they had come. Obviously my units then fell out of LOS and they must have thought to themselves "OH there's some unexplored land nearby", so for about 150 turns (again, marathon) these two scouts went back and forth.

At first it was amusing, locking these two players out from the 2 CS's meant they couldn't meet them, influence them as they were mine uncontested. But it grew so infuriating having these units back and forth because now I had to watch them move every time (I don't like quick movement).

So to agree with Fluff, I don't think there is any strategic intention to why the AI shuffles. It seems like a simple loop in their AI.

The cultural border reason is the best, furthered by why move between two jungle/forests and not a hill and /stay? You gain 1 hex los when surrounded by jungle.

To me it just seems like there's no 'memory' for the AI, that is something to tell itself it has moved to X location X time ago and there was a roadblock, or bad terrain, or nothing there worth exploring. As a result it gets caught in these cycles until, like I surmised in the first post, a war hits them and then they hunker down or run away or run towards, depending on unit.

I'd happily have the 7th AI option if it was "Not at war? Let me find a tasty hill and every 10 moves go between it and another hill".

Not a Sam-Frodo "This looks familiar."
"It's because we've been here before. We're going in circles Sam."
"I don't think Gandalf meant for us to be coded this way."
"Gandalf didn't mean for a lot of things to happen, but they did.
 
Endless circeling migth not be reasonable in all situations. But it might be the "prize" you have to pay for an usually desirable AI behavior:

- Imagine an allied AI you have "open borders" with. If it's units will sit idle at one place (be it in your territory or even more in his own), you might *never* be able to pass through those units. Crossing it's realm might be impossible. Circling units do prevent this.

- Imagine a foreign scout sitting forever on a tile you want to found a new city on. How frustrating! Always moving units do prevent this.

- Also, moving units around *might* create new tactical situations, allowing the AI to free itself form an "evaluation stalemate". (Of course, if state A leads to state B which leads to state A again, a never ending movement circle is created.)

Taking all this into account, moving units around might be the better solution than static units. Pointless circeling every now and then might be the smaller prize to pay than the alternative.
 
I still think static fortified units inside a civs territory when defending will make for a better tactical game.

I agree though that static units outside a civs own territory will create problems for pathing and city settling.
 
static units would make missionaries and great people very challenging to use, that's for sure. as it is, on Immortal or Deity the AI/city states have so many units in their territory that it's a maze trying to navigate through to reach their cities.
 
I guess it`s just too much to expect the AI to figure things out like a Human does.

It`s bit like the old Cylons; instead of having two eyes to look about and pinpoint something, it`s easy just to do a constant `radar` sweep` even if it`s less efficient.
 
I think the problem is if they stayed stagnant they would easily be defeated, they have to reassess every turn. It is a shame the ai can't skip the moving phase tho.
 
Units don't always have to move, they'll stay still in cities at the very least.

It seems to me like the AI doesn't try to calculate what movements would lead to the best overall position for all of its units each turn. That's probably for the best since I imagine that would take an immense amount of processing (It would have to find every combination of possible moves and quantify each one. Those kinds of numbers get out of hand very fast.) Instead it seems to cycle through the units and try to find a better position for each one individually. In that situation it might make sense for them to move around if it scores the two positions equally so that the units don't get stuck when there are better positions more than one turn away or to keep units well distributed if war or expansion are depleting units in one part of the empire.

I kind of doubt it would save much processing to keep them from moving. They would still have to decide if moving or not was a good idea, executing the actual move is just a quick rewrite of the RAM where it is storing the unit positions, the actual processing lies in deciding whether or not to move.

P.S. What is the reason for preventing civilian units from moving through units of peaceful civs? I'm assuming there must be some exploitative behavior that was once popular until this fixed it but, much like basing policy costs on the most cities you have ever owned instead of current cities, I just can not imagine what that behavior is.
 
Top Bottom