Keeping particular units alive

notque

Artificially Intelligent
Joined
Nov 13, 2005
Messages
2,174
I've been playing with the code trying to keep high experience units alive. I'm using Better AI, and I see it's set to value experience so as to not sacrifice the unit.

But that isn't helping when the unit runs off alone.

What options do I have to keep particular units alive with high experience? Can we always send units out in groups? What is the value in ever sending a unit off alone aside from UNITAI_EXPLORE?

Also, I've noticed that high experience units will sometimes get stuck as City Defense after capturing a city.

I've tried setting NounitAI for City Defense for the unit in XML, but that isn't stopping it.

What options do I have to keep high experience units from becoming stuck in City defense away from the battles, and keeping them alive.

They aren't being chosen to suicide themselves if they are in a group, but if they run off alone.

Thanks.
 
What i'm doing now is, if a unit has over x experience, and they have unitai city defense, change their unitai to counter.

I've made high experience units counter which is helping to keep them grouped together.

I've also increased the suicide units threshold, and the attack threshold, and i'm getting higher units with experience lasting much longer.
 
If you want to do a test of your changes, keep track of them, and have them apply only to odd-numbered players who are AIs. :)

Run a few dozen game fully automated, and see if your changes result in the changed AI beats the normal AIs.
 
I have run many autoplay tests, and the AI is developing units with much higher experience. And succeeding in attacks much more often.

I don't know if it's actually a better strategy, which your tests may help me with, but it is giving me the desired result with the changes.

I also am considering a way to get a high experience unit out of there. Not attack if the percentages are too great, and maybe run away with a shadow back to safety. If it was another island, would he be considered stranded, and a boat try to get him before death?

Interesting questions, but I'm getting some excellent result in a variety of ways with Dynamically changing unitais based on situations.
 
Wow, sounds like this is coming along well. Nice work. Don't forget to share your source code when you think you've got a good working build going ;)
 
One of the bigger threats to highly experienced units is that they eventually grow strong enough to be the best defender in their stack even though they aren't supposed to be defenders. This happens easily when the unit gets combat promotions.

Preventing this is tricky though. Personally, I try to make sure that a unit which I don't want to die is always accompanied by other units which are better in defense. Exceptions are when a) there is no threat around which is dangerous enough to have a realistic chance to kill my unit, or b ) the gains of keeping the unit in the stack are high enough to justify the risk. If neither of these conditions is met, then I'll retreat a valuable unit in order to not put it at risk. The whole thing is difficult for an AI to calculate though.

Another tactic, which might be easier top implement, is to not always attack with the unit that has the highest chance of winning, but factor in the value of this unit to me. Example: If my medic3 spearman has a 10% higher chance of success than a second unit which has no experience at all, then I will *not* attack with the spearman. I'm not sure how the AI currently handles such situations.
 
It takes human brain power to treat a highly experienced unit with the respect it deserves. I think it would be too difficult to program the computer to treat these units the way a human would. This is why the AI shouldn't use its Great Generals to create Warlord units, the AI would waste these units. (Even I'm not very good at keeping them alive!)
 
One of the bigger threats to highly experienced units is that they eventually grow strong enough to be the best defender in their stack even though they aren't supposed to be defenders. This happens easily when the unit gets combat promotions.

Preventing this is tricky though. Personally, I try to make sure that a unit which I don't want to die is always accompanied by other units which are better in defense. Exceptions are when a) there is no threat around which is dangerous enough to have a realistic chance to kill my unit, or b ) the gains of keeping the unit in the stack are high enough to justify the risk. If neither of these conditions is met, then I'll retreat a valuable unit in order to not put it at risk. The whole thing is difficult for an AI to calculate though.

This is a problem. I'm looking to ways to solve it.

Another tactic, which might be easier top implement, is to not always attack with the unit that has the highest chance of winning, but factor in the value of this unit to me. Example: If my medic3 spearman has a 10% higher chance of success than a second unit which has no experience at all, then I will *not* attack with the spearman. I'm not sure how the AI currently handles such situations.

This is not a problem, the AI currently looks at other units to suicide on the stack based on several variables. One of which is XP. Better AI currently makes this XP value stronger, but I need something more complicated.

There are several options. Run to safety if there's a path to safety. Bring a shadow everywhere the unit goes.

I'm considering a few things. I've tried out several to varying results.

The unit is most vulnerable alone, and I think always bringing a shadow is going to be a prereq to making this work at all.

Once the unit is in a stack, it's significantly less likely to die an inconsequential death.
 
It takes human brain power to treat a highly experienced unit with the respect it deserves. I think it would be too difficult to program the computer to treat these units the way a human would. This is why the AI shouldn't use its Great Generals to create Warlord units, the AI would waste these units. (Even I'm not very good at keeping them alive!)

Well Better BTS AI does includes Dresden & Solver's unofficial 3.17 patch version 0.21, which causes the AI to use warlords to made super-medics, and better AI makes the AI reluctant to sacrifice units with medic promotions.
 
He's saying that the AI is actually pretty good about not sacrificing high level units. The problem is the AI abandons them, or sends them off on tasks alone, rather then keeping them protected in the stack. So the work has been focused on that end.

At least that's how I read it.
 
He's saying that the AI is actually pretty good about not sacrificing high level units. The problem is the AI abandons them, or sends them off on tasks alone, rather then keeping them protected in the stack. So the work has been focused on that end.

At least that's how I read it.

This is exactly what I am trying to say.
 
If you want to do a test of your changes, keep track of them, and have them apply only to odd-numbered players who are AIs. :)

Run a few dozen game fully automated, and see if your changes result in the changed AI beats the normal AIs.

So, how exactly would 1 make changes apply to only some AI players? Make all changes a check on player id, and keep track of it for that dll only?
 
Sure. Have it say "if player id is even, then follow new code. If player id is odd, follow old code".
 
Hey any chance you could release what you have so far? I just added in hero units in my mod, and the AI is terrible about protecting them, I'd like to see if this code would improve their survivability when built by the AI.
 
Back
Top Bottom