Wendy said:
Umm, has the AI gotten advanced enough to even try this?
I don't see why not. As outlined above, it checks the type and alignment of all units nearby (checking the alignment at least must already be in the code or the AI wouldn't have any idea who to attack), then does some number crunching based on some pretty simple criteria, then generates a random number and compares that to the number it crunched out through the criteria listed. Simple, no?
It seems to me, that you might be inviting a hang or stall while the code runs before battle and the AI sorts the odds.
You're inviting a hang or stall by editing the code at all. Trust me on this one. Besides, finding such errors is the point of releasing beta versions, is it not?
And even then there are other uncertainties that have to be taken into consideration. Is the pilot an ace?
I'd thought about several other criteria that I decided to omit (including the "ace" rating) for simplicity. I'll go ahead and put them here in case others think they're a good idea, but the whole system should be perfectly workable with the criteria in the first post.
4. "Morale failure" If a pilot sees friendly units being destroyed, the "flee" rating gets a few points added to it, more if the friendlies are in the same flight group. This would account for pilot panic when he sees all his buddies get blown away, even if his side is still winning and he's personally taken no damage.
5. "Veteran quality" Pilots with a higher skill rating accumulate "flee" points more slowly, due to their increased confidence and experience. This makes ace pilots more likely to pick a fight with a larger force since the firepower difference would mean less. This would only reflect the skill levels of the pilot's own flightgroup, not those of his opponent (how can you tell the other guy's an ace until he's already shot you, right?).
6. "I *might* be able to outrun 'em..." Same as #1 but with looser tolerances for max speed differences, to reflect the pilot's potential willingness on taking a gamble at being able to outdistance a faster foe.
7. "Massed Fire" Based on certain criteria (probably a unit being unable to flee due to the speed restriction in spite of a very high flee level) flightgroups will pick and swarm either the fastest enemy ( to clear their retreat) or the most powerful enemy (to try and swing the battle their way). Possibly if they've taken a lot of damage but the power ratings are very close for the latter, or possibly if the power ratings are heavily against them but the faster ships are only a small part of that for the former.
8. "Can't run, friendlies wil die" If a nearby allied unit fails the speed restriction check, the pilot will be less likely to flee and leave it to its doom. ie, if militia fighters are dealing with pilots that are harassing transports, they will tend to stick around even if the battle goes against them. This would be even more true of confed units defending their carrier. This woulud probably not be true at all of pirates who will leave their command Drayman to its doom if they think they'll die protecting it. This could probably heavily relate to the alignment modifiers I mentioned in my first post.
As a small aside, I've decided it would be a better idea to generate a single "flee tolerance" for each ship when they are created rather than re-generating new "dice rolls" all the time. In addition to saving a small amount of cpu juice, it will tend to cut down on situations where stunning heroism and abject cowardice come from the same unit(ie, the unit's flee rating is 99% but privateer generates a 100 for its flee tolerance and the unit sticks around, then the battle turns in their favor and drops the flee rating to about 10% but priv generates a 5 for the flee tolerance and it runs away squealing).
And let us not forget the old ego trip, too.
I KNOW I'm better than you, even when I'm not. How dare you even think about returning my fire?
That was my reasoning behing the randomly generated "flee" tolerance: some units would randomly be huge cowards and would flee even token resistance, where others would be suicidal and would gladly charge six paradigms, 29 broadswords, and Blair in a vampire with nothing but a half-destroyed Tarsus.
So, unless I've missed something vital, I do not see a huge problem with implementing this particular algorithm. Just have a function that recalculates the flee rating based on the above criteria, a function that generates a flee tolerance, and a function that compares the two and puts the unit into "flee" mode as necessary, then have it recalculate and recheck the flee rating whenever it takes internal damage or sees a ship explode. The big problem I see is with balancing, and coming up with specific numbers for specific force ratings. Damage should be easy enough, though.