• Welcome to Freedom Reborn Archive.
 

AI delays question

Started by stumpy, April 20, 2008, 04:29:27 AM

Previous topic - Next topic

stumpy

I have a drone character called Gnat that I am trying to set up for use as a minion (it has no hero point). The character is a fast flyer and it has one ranged attack that uses 2/3 of its energy, so it can attack and then has to wait before it has enough EP to attack again.

When enemies are present, here's how I want it to behave:
       

When it has 2/3 or more of it's EP
  • Move in close and attack

When it has less than 2/3 of it's EP, split its time between
  • Flee past long distance from enemies
  • Make quick, random moves, which might bring it into range again

The idea is that it attacks and then zips around, no waiting, no standing still until it has the EP to attack again.

Here's what I have thus far, tweaking M25's AI generator's file as a base.
[/list][/list]['gnat',
["target enemy",
'weakness_ranged_energy',
],
["timer", 'auto',
"TRanged('stunners',time=1.0,energy=66,situation='higherenergy 66')",
'TMoveTo(movetype="fly",mindist="short",situation="higherenergy 66",time=0.50)',
'TFleeMelee(movetype="fly",mindist=500,situation="lowerenergy 66",time=0.88)',
"TRandMove(movetype='fly',pct=100,time=0.40,mindist=50,maxdist=200,situation='lowerenergy 66')",
],
]


It's working okay, but not quite the feel I want. It seems like there is a delay of a second or two between everything. In other words, it will move up to an enemy and then stand still for a second, then attack, then sit there for another second, then flee, then be still for a second, then make a few random moves, but pause for a second between each of them. Can I get rid of (or shorten) that delay between everything?

TaskMasterX

In FFX 3.2.2 I decreased the AI timer, mainly because characters that were knocked down waited for a second or two before doing anything after getting up. They'd keep getting pummeled and knocked down again. Have you tried using the FFX 3.2.2 m25ai.py file to see if that improves the performance?

I had been trying to get some of my fliers and speedsters to move around alot to make for harder targets and I noticed that TRandMove never worked that well. Instead, I relied on soley TFleeMelee and I used it the same way you are with the situation='lowerenergy 66'. They move around quite a bit, so maybe remove the TRandMove tactic and see what happens? Take a look at my Quicksilver AI or my Alpha Flight Aurora and Northstar AI's. I really wanted to capture their speed and maneuverabilty and they zip around all over the place and don't stay in once spot very long.

stumpy

Thanks, I was thinking there might be something settable in the character's AI file, in case the general timer was set that high to avoid some other problem.

But, I set it to a quarter second and got just the results I was looking for. My little drone (JIK's walker scaled to 0.20 size) zipping around was quite fun to watch. And, the random moves had the effect I was looking for when pit against some grenade-wielders (I was using the FFvT3R nazi grenadiers): By zipping back and forth over them (as I do manually when I play a flier), he is essentially out of range of their attacks and they end up dropping grenades on themselves and their allies. Highly amusing to watch.  :lol:

Anyway, that did the trick. Thanks again.

stumpy

This change could make Patriot City considerably more challenging. Heh.  :cool:

Epimethee

Quote from: stumpy on April 21, 2008, 03:45:27 AM
This change could make Patriot City considerably more challenging. Heh.  :cool:
If so, the last difficulty setting should be renamed to "We're looking for a word meaning more difficult than 'impossible'". :blink:

M25

The AI delay is of course there for performance reasons.  If it isn't causing the game to slow to a crawl when there are a large number of characters, then by all means, let's lower the delay to make the AI more responsive (and more dangerous).

The delay was scaled to the number of characters in the mission at one point, which might make sense again.  So a few characters would have very responsive AI, but large mobs would be somewhat less responsive.







Epimethee

Maybe we could also have some sort of very approximative machine performance index to determine the best setting. The performance gap between various user configs is probably quite large by now.

TaskMasterX

Quote from: stumpy on April 20, 2008, 10:33:47 AM
But, I set it to a quarter second and got just the results I was looking for.

Are you saying you set the time=0.25 in the TRandMove tactic line?


Quote from: M25 on April 22, 2008, 11:05:39 AM
The AI delay is of course there for performance reasons.  If it isn't causing the game to slow to a crawl when there are a large number of characters, then by all means, let's lower the delay to make the AI more responsive (and more dangerous).

The delay was scaled to the number of characters in the mission at one point, which might make sense again.  So a few characters would have very responsive AI, but large mobs would be somewhat less responsive.

I did notice the AI become more responsive with everything it did. There was a lot less standing and hovering but I also noticed it ran slower on my older PC. I was mainly looking to improve the response of characters when finishing a getup animation. If there's a way to do this without changing the timing of the whole AI, then that'd be the ultimate solution for me. If not, maybe a way to change the AI timer on the fly? -like a command typed in the console?

I have a couple of topic-related questions:
After turning on the AI Reporting (:doh: thanks, M25!), I saw these:
AI: custom_vil_2_3 no tactic chosen this cycle.
and
AI: custom_vil_1_2: ('adversary') random move on inability to act.
Does the first line mean the character will stand still or hover because it couldn't find a tactic that fits the situation? And how is it different from what generates the 2nd line?

stumpy

Quote from: TaskMasterX on April 23, 2008, 06:48:17 AM
Quote from: stumpy on April 20, 2008, 10:33:47 AM
But, I set it to a quarter second and got just the results I was looking for.

Are you saying you set the time=0.25 in the TRandMove tactic line?

No, I left that at 0.4. I assumed you meant that there wasn't a way to change the time between moves for an individual character, so I changed the AI_AUTOTIMER to 0.25.

BTW, inasmuch as it impacts performance for slower machines (which might include mine; I haven't been testing with more than 10-12 characters), I like the approaches mentioned of scaling the timer inversely with the number of characters and maybe allowing a performance calibration specific to each machine. The latter might even be possible as a special Rumble Room mission that runs a stress test while comparing the change in real time versus the change in game time. Obviously, the player would have to not hit pause during the test...

Another (non-exclusive) idea might be one AI_AUTOTIMER settings for villains and another for minions. Or one scaled inversely to a character's effective speed (e.g. speed + 3 for flying).

M25

No tactic chosen means just that.  The AI didn't find a tactic to perform, either due to the random nature of the AI or, more likely, because none of the conditions were met (such as not having enough energy to attack).

Inability to act occurs when the AI tells the game to do something, and the game doesn't do it for whatever reason.  The character gets stuck, so a random move is issued to try and unstick them.



The AI delay value could be setup to be different for each character, and a tag added to the AI definition if you want to customize the delay value.  There could be different delays for different types of actions, though that would take more work.  The minions/villains split is a good idea, though aren't all custom characters imported into the rumble room as minions?

It may also be possible to time the loop that builds target lists for each AI as it tends to take a consistent amount of time and varies according to the number of combatants, and then use that to set the global delay.  It should/might give a rough estimate of the speed of the machine the game is running on.  It would work for the AI, though from a design standpoint, it would be better to have a standalone module that determines the performance index and said index could then be used for any other module.





stumpy

Quote from: M25 on April 23, 2008, 03:48:29 PMThe minions/villains split is a good idea, though aren't all custom characters imported into the rumble room as minions?

Very true. I guess that would not be as valuable for the Rumble Room, though it might still make for sharper and quicker villains for a campaign. But, jeez, how many times has an idea been derailed (or at least sidetracked) by the oddball Rumble/Danger Room behavior related to those dratted "custom_template"s? Oi!

TaskMasterX

Quote from: M25 on April 23, 2008, 03:48:29 PM
The AI delay value could be setup to be different for each character, and a tag added to the AI definition if you want to customize the delay value.  There could be different delays for different types of actions, though that would take more work.  The minions/villains split is a good idea, though aren't all custom characters imported into the rumble room as minions?

It may also be possible to time the loop that builds target lists for each AI as it tends to take a consistent amount of time and varies according to the number of combatants, and then use that to set the global delay.  It should/might give a rough estimate of the speed of the machine the game is running on.  It would work for the AI, though from a design standpoint, it would be better to have a standalone module that determines the performance index and said index could then be used for any other module.

An AI Timer value for each character would be nice. Would it be like the original FFX 2.x AI timer? I tried using a number instead of the 'auto' using the current system, but it gives an error. If we use a system that counts the amount of characters in a mission, it'd also probably have to take into account Private Army, Summoner, Nemesis, and any other attribute that spawns extra characters during the mission.

M25

The original AI timer was meant to mesh custom AI with the built-in AI.  In other words, wait 4 seconds before checking the custom AI so that the built-in AI has time to do something.  It turns the built-in AI on and off, so it isn't quite what we want for this issue.

I'll look at adding an AI delay value for individual characters.






Xenolith

I'm very much in favor of Emp's idea to have the timer set to the Speed of the character.  That makes a tremendous amount of sense.  Not only would it further define the boundary between quick and clumsy characters, but it would also help keep a balance for computer resources, right?

Could you use an inverse (1/SPD) relationship (e.g., speed 10 = 0.1, speed 7 = 0.14, speed 4 = 0.25 speed 2 = 0.5, etc.) or would that be too much of a timing gap?  Can the AI even calculate at 0.1?

thanks

M25

The inverse relationship is a good idea, and it would alleviate the need to set the AI delay in each AI definition file under most circumstances.  However, since the majority of characters are likely to be in the speed 10 to speed 4 range, and there isn't much difference between 0.1 and 0.25, I think I'd make it more along the lines of (11-SPD)*0.1.

An AI can run on a delay of 0.1, yes.