Well, I'd say this behavior still hints to something systemic being wrong with the AI.
Their positioning-code still thinks it can attack them with melee and tries to reposition to do it.
The question is how this should be handled. I see 2 possibilities.
One is to teach the positioning-code about the hit-chance-reduction too, so it doesn't even try.
The other is to ignore the circumstance that they can't hit by internally limiting what they think the dodge chance reduces their accuracy too.
With armor-mitigation the AI does attack anyways, even if it calculates that their attacks will be fully mitigated by the armor.
So should they attack anyways or should they not even try and do something else instead?
First I want to say thank you... your work is great... I appreciate your time and don't want you to think I'm 'expecting' anything other than 'gladly thankful'
I'm not sure how much effort it would be, but here's some thoughts / suggestions:
1.) Maybe something that the AI would 'learn' where if AI controlled units attack at first don't know that they will miss or if it's a 'dumb' actions then ignore learned behavior. After x# of tries (how ever you decide) then the AI stops that behavior, i.e. melee against a target where melee doesn't work like attacking a tank with a knife and low stats that will never hit or do dmg. 'Learned' actions could reset across battlescape sessions, especially for enemies, or be retained for player AI or not. Also, I think it would be helpful to warn the player if their isn't a good action to take and pause auto player AI... for example all player agents only have melee weapons equipped and there is an enemy like swarmoids. Or should the AI recognize they can't melee a target and go 'looking' for a capable range weapon... and what if the battlescape was started with only melee weapons and the only enemy is something like swarmoids and no civilians of any other npc that contains a usable weapon to kill or incapacitate the swarmoid like enemy.
2.) or just do the calc to hit and if it's a 'smart' action then don't attack, and if no sufficient actions could be taken, then pause autoplay player ai and prompt with message about not being able to take a successful actions?
Also not sure if you have looked at the keyboard short cut for entering and exiting auto-play player AI (default ctrl+a) but I've noticed a 'significant' difference between pressing excape to goto the menu which works almost always under heavy cpu load of the auto AI, and when trying to press ctrl+a to stop the auto AI under heavy cpu load it doesn't pickup the command. I'm guessing it's how it polling and looking for the keyboard shortcut during each iteration of computing the ai actions or possibly not storing the keyboard command until a specific iteration is completed to decide to exit the auto ai. Sorry for bring this up again, not trying to be annoying but this has been a significant issue for me trying to exit auto ai player action in the middle of a battle. And which I thought it was interesting that pressing escape to menu didn't have the same issue.
On another thought about the hang with the keyboard shortcut, is there a way no matter how much the cpu is taxed with the AI calc, to give priority to the GUI, mouse and keyboard shortcuts or even moving the battlescape position?
Again, thank you!