Coding frustrations with AI

Coding frustrations with AI

Since the beginning of Fallen Enchantress, people have claimed that the AI monsters will sit next to any enemy city and not attack. They concluded that the monsters were giving AI players a pass.

I have responded that I have looked at the code over and over and the monsters do not treat computer players any differently.

Well, tonight I’m seeing the behavior very starkly.

These ogres should be wiping out this AI city.

The code says that the ogres want to wipe out the AI city.

They are explicitly targeting it.

..

And yet..

The attack never happens.

As a result, the monsters are just standing there, stuck outside the city. Now, I’ve got a few thousand hours of game time on this and this is the first time I’ve seen it where I knew it should be attacking (i.e. I’ve seen well defended cities with monsters outside). So it’s not that common. But based on forum feedback, it’s definitely something others have seen.

Now, I have to find out why they are being prevented from attacking.

Stay tuned..

Update 1: Seems to be path finding related. This is going to take some digging.

Update 2:

New check in.

+ AI Removed conflicting code that caused monsters to behave outside the control of the AI+ AI Monsters more careful about leaving their lairs unguarded.+ AI Updated the area threat evaluation to include stationed units.+ AI champions significantly better about taking out enemy outposts and grabbing goodie huts on the way to another destination+ AI better at building more lethal armies+ AI much better at protecting its cities+ AI fixed a bug where certain AI personalities had a chance of not building units when they should depending on the type of city+ AI more aggressive about training units when it feels that city is vulnerable+ AI no longer has a "auto patrol" system. Instead, the monster AI directly controls monsters and not the mobileobject system.+ Fixed a pathfinding bug that caused monsters that were calculating a destination to not be able to set a destination IF the target was 1 tile away and it is a city.

Im glad you are checking into this, because in my games Ive seen this alot. I tend to play with lots of monsters running around, and watching them just ignore the AI players, and yet come for me is very aggravating. GL and thanks for starting this post to keep us in the loop!

If it is pathfinding, I would guess that it's trying to pathfind to the other side of the city. It can't do that because the city takes up the tiles between the ocean and the gorge. So the monsters just stand there scratching their butts.

Hmm, could it be that AI improvements are somehow blocking monsters from pathfinding into cities? So when the player takes the city over the improvements are destroyed and then the pathfinding succeeds and the monster beelines to the city.

Actually the bug affects everyone equally. It just seems like it only affects you because you see cases where there are monsters sitting right outside a city unable to attack. Monsters DO attack cities very often. But there is a case (which I think I've tracked down) where the pathfinding gets stuck. It would happen to a human too but humans tend to deal with monsters before they get to their front door.

The frustrating thing is that it's 1 tile away. How hard is that to find path for?

I feel and see the pain. When the AI targets the city, is it trying to target the closest city tile or is it targeting another tile within the city that it cannot reach? From your screenshot it may be that the Ogre is trying to target the part on the other side of the city that it cannot reach since there is a chasm in the way. The center of that city, if I put a tack in it would be on that small building on the other side.

If it is pathfinding, I would guess that it's trying to pathfind to the other side of the city. It can't do that because the city takes up the tiles between the ocean and the gorge. So the monsters just stand there scratching their butts.

Hmm, could it be that AI improvements are somehow blocking monsters from pathfinding into cities? So when the player takes the city over the improvements are destroyed and then the pathfinding succeeds and the monster beelines to the city.

Dont make it hard on yourself. finally got to put 8 hrs in this weekend and loved it. You guys finally nailed it.

Thanks frog!

Edit-

If they already are moving (left the lair or a city) put in a check to make sure they dont sit in one spot for more than 2 turns or something. Even if its 8 turns till they can re-pathfind (they try each direction). Just make a movement in one of the directions and let the path finding work. That would scare the crap out of me also. NE didnt work, well try SE kinda thing.

just a thought. I pay you guys to make games. lol. If I could do what your doing I wouldnt have to.

The AI factions will do the same thing as speculated at here. I had Kulan and his army camping outside a city of mine for at least 20 turns as the whole city occupied the passable terrain between a mountain range and the sea. I think he moved again when the Night of Haunted Dreams event was launched...

AI updates look good. Will be nice to play a game where you actually feel threatened in the early stages. I rarely see the need to garrison my cities until an A.I. declares war in current games. Is there an ETA for these?

+ AI Removed conflicting code that caused monsters to behave outside the control of the AI+ AI Monsters more careful about leaving their lairs unguarded.+ AI Updated the area threat evaluation to include stationed units.+ AI champions significantly better about taking out enemy outposts and grabbing goodie huts on the way to another destination+ AI better at building more lethal armies+ AI much better at protecting its cities+ AI fixed a bug where certain AI personalities had a chance of not building units when they should depending on the type of city+ AI more aggressive about training units when it feels that city is vulnerable+ AI no longer has a "auto patrol" system. Instead, the monster AI directly controls monsters and not the mobileobject system.+ Fixed a pathfinding bug that caused monsters that were calculating a destination to not be able to set a destination IF the target was 1 tile away and it is a city.

Awesome job. Looks like a great improvement to the comfort factor when playing. I always had great "fun" with mobs killing my newly captured AI cities a couple of turns after I left coming from nowhere ^^