UFO:Alien Invasion

Development => Design => Topic started by: PhilRoi on June 17, 2009, 11:27:27 am

Title: Civilian AI Scripting
Post by: PhilRoi on June 17, 2009, 11:27:27 am
In another post I posed a selection of AI behaviours for Civilians.

I put together an initial flowchart draft of this for a civilian behavior.

I figure most people can follow a flowchart even if they can't follow code.

I already have in mind about a half-dozen ways to simplify this,  keep in mind this is just a first draft.

http://members.toast.net/philroi/ufoai/AI.jpg (http://members.toast.net/philroi/ufoai/AI.jpg)

relies on determining which of 4 behaviors to perform.

Herd: stick close to other humans,  or alternately under dire threat phalanx soldiers
Hysteria:  run around aimlessly
Hide:  get low and stay out of sight, from phalanx and aliens depending on threats
Hero: On the off-hand chance we decide to arm the humans,  under dire threat they just might make a token attempt to fight back.  don't think they will do much since i can't see us giving them more then tiny pistols or knives to carry.  and if we never arm them it'll straight to hysteria.




[attachment deleted by admin]
Title: Re: Civilian AI Scripting
Post by: BTAxis on June 17, 2009, 12:16:07 pm
Actually civilians are expected to carry some weaponry on occasion, but they will never be able to inflict any serious damage on alien units.
Title: Re: Civilian AI Scripting
Post by: MXcom on June 18, 2009, 12:24:39 am
at one point in the lower left of your diagram it says "hide(phalanx)". Is that intended? Or is it a typo and it should mean herd(phalanx)?
Title: Re: Civilian AI Scripting
Post by: Mattn on June 18, 2009, 07:33:18 am
nice job - please make sure to add this to the wiki when you are done with it (maybe create an own ai coding section)
Title: Re: Civilian AI Scripting
Post by: Mattn on June 18, 2009, 07:34:31 am
...oh, keep in mind that different alien races should act a little different, too. i suppose winter and btaxis can tell you more here (or look it up in the alien wiki articles)
Title: Re: Civilian AI Scripting
Post by: TrashMan on June 18, 2009, 01:29:20 pm
Nice job. Makes sense and looks good.

But, given that everyone knows aliens are there and weapons can easily be bought - wouldn't most civilians arm themselves? With the best they could get? I see hunting rifles and shotguns in addition to pistols and knives.
Title: Re: Civilian AI Scripting
Post by: Tantalus on June 19, 2009, 11:06:00 am
Hi,

as far as I can see, there's not much of a difference between Civ injured or not. In my oppinion, an injured civ should never go hero, except he/she is traped somewhere without any way out (or is this ment by "danger close"?). The default for injured:yes and alien visible:yes should alway be hide (IMHO).

Regards
Tantalus
Title: Re: Civilian AI Scripting
Post by: BTAxis on June 19, 2009, 12:23:35 pm
I'm not sure if injured civilians are relevant. Especially later on in the game it's unlikely a civilian will survive a shot from an alien weapon.
Title: Re: Civilian AI Scripting
Post by: Tantalus on June 19, 2009, 01:19:07 pm
Considering a direct hit - sure. But what about splash damage?

Regards
Tantalus
Title: Re: Civilian AI Scripting
Post by: BTAxis on June 19, 2009, 01:20:39 pm
I'm not saying it's not possible, just that it's not going to happen often enough to warrant different behaviour. Especially since the player isn't going to be able to tell if the civilian is hurt or not.
Title: Re: Civilian AI Scripting
Post by: Tantalus on June 19, 2009, 01:28:28 pm
Well, in that case, you could drop the entire "injured:yes"-branch, or lets say reduce it to "hide" (injured civs always try to hide).

Regards
Tantalus

EDIT: What about limited ammo for armed civs? Do they count as "armed", when out of ammo? If no, I'd recommend to limit ammo very strictly.
Title: Re: Civilian AI Scripting
Post by: PhilRoi on June 20, 2009, 11:19:34 pm
I was torn with the whole INJURED branch since it represents extra CPU cycles to process that extra conditional.  I can also re-arrange the priority of the conditionals so that being injured only makes a diffrence in a few specific cases.  reducing its impact on AI think time.

The Hide(Phalanx) behaviour is there to represent a very real human behaviour I have witnessed.  People with guns aka army types on the hunt make people very nervous.  They see Phalanx is rolling in and know that there is about to be a rumble and so they try and melt into the shadows in an attempt to avoid getting caught in the crossfire.  so no it isn't a typo.

And yes Danger Close means 2-3 spaces away.  Really awfully close.   I made the initial Script under the impression that Civ's would be rarely armed,  or at least that having them fight back was supposed to be rare.  now having armed neutrals is going to be more common then I thought.

really it sounds less and less like we are looking for an ALIEN AI and CIVILIAN AI as we are a HOSTILE AI that is coded to use aliens and a neutral ai that is coded to use civilians, police, non-phalanx military.  The Alien AI is a HIVE Mind so having a single AI that is flexible enough to recognize and exploit diffrences in alien type is perfect.   Now for the Neutral AI, those 3 groups that I mentioned are going to have very diffrent behaviours.

Civ's will be much like i described above, with some editing.
police forces are going to be focused on "rescuing" people and protecting Civilians.
Military types are going to group up and go hunting....
And not co-ordinating there actions between the 3 groups...

   Something for me to brain storm and work out.    Still very easy and do-able,  Just a case of working out how we want it to be.  Coding it is the easy part..

Title: Re: Civilian AI Scripting
Post by: BTAxis on June 20, 2009, 11:27:26 pm
And yes Danger Close means 2-3 spaces away.  Really awfully close.   I made the initial Script under the impression that Civ's would be rarely armed,  or at least that having them fight back was supposed to be rare.  now having armed neutrals is going to be more common then I thought.

What gave you that idea? Your original assessment was correct.

Quote
Civ's will be much like i described above, with some editing.
police forces are going to be focused on "rescuing" people and protecting Civilians.
Military types are going to group up and go hunting....
And not co-ordinating there actions between the 3 groups...

Mind you, police and military NPCs are NOT going to be a big part of any combat engagement. It's fine if you want to create an AI for that anyway, but you might want to give it a low priority.
Title: Re: Civilian AI Scripting
Post by: Mattn on June 21, 2009, 09:20:26 am
Mind you, police and military NPCs are NOT going to be a big part of any combat engagement. It's fine if you want to create an AI for that anyway, but you might want to give it a low priority.

yes - it should be a seperate ai script - not included in the civilian script. only very few maps needs this btw. (at least at the moment)
Title: Re: Civilian AI Scripting
Post by: odie on June 28, 2009, 09:13:08 pm
In another post I posed a selection of AI behaviours for Civilians.

I put together an initial flowchart draft of this for a civilian behavior.

I figure most people can follow a flowchart even if they can't follow code.

I already have in mind about a half-dozen ways to simplify this,  keep in mind this is just a first draft.

http://members.toast.net/philroi/ufoai/AI.jpg (http://members.toast.net/philroi/ufoai/AI.jpg)

relies on determining which of 4 behaviors to perform.

Herd: stick close to other humans,  or alternately under dire threat phalanx soldiers
Hysteria:  run around aimlessly
Hide:  get low and stay out of sight, from phalanx and aliens depending on threats
Hero: On the off-hand chance we decide to arm the humans,  under dire threat they just might make a token attempt to fight back.  don't think they will do much since i can't see us giving them more then tiny pistols or knives to carry.  and if we never arm them it'll straight to hysteria.

Oooo, very logical and nice! Good work!

I thnk it might be a very good idea to get this scripted. :D
Title: Re: Civilian AI Scripting
Post by: PhilRoi on June 30, 2009, 10:15:15 am
I'm currently looking into developing a sense of fuzzy logic for the AI.  as someone pointed out in my research into ai coding techniques,  hard rules lead to exploitable behaviors in the AI.  However,  having the AI capable of doing diffrent things in the same situation can lead to save/reload exploits.
decisions, decisions, decisions......
Title: Re: Civilian AI Scripting
Post by: MXcom on June 30, 2009, 11:34:49 am
[...] can lead to save/reload exploits.
[...]

Not if the player cannot save during tactical missions.
Title: Re: Civilian AI Scripting
Post by: odie on June 30, 2009, 12:28:02 pm
Not if the player cannot save during tactical missions.

Actually, they still can save/load, but at geoscape level.

But at least it wont end up like the XCOM series of save/load WITHIN battle.....

Still, its a good idea, and makes the Civi more predictable...... (and logical).

Aliens on the other hand, can be more 'varied', maybe. Like they may berserk and go kamikaze?
Title: Re: Civilian AI Scripting
Post by: PhilRoi on July 02, 2009, 02:27:23 pm
well with the tactical save put to rest. and not a concern i'll go ahead and look deeper into fuzzy-fieing the logic.  Look for a V2 by monday,
Title: Re: Civilian AI Scripting
Post by: Mattn on July 02, 2009, 04:59:26 pm
this reminds me: if you are improving the lua ai - be sure to activate the server threads (sv_threads cvars set to 1)
and do a set g_ailua 1 (maybe add that to your autoexec.cfg)
Title: Re: Civilian AI Scripting
Post by: Hank on December 28, 2009, 08:06:12 pm

Is the herd(phalanx) behavior intended to be a pain in the ass? I've frequently had issues in combat with civilians standing in my line of fire and obstructing doorways between me and the aliens. Obviously my soldiers are going to be in the heat of combat, so herd(phalanx) is equivalent to 'run toward gunfire'.

I would much prefer: herd(phalanx) --> herd(dropship/insertion).  That is, the civis see the soldiers, run to them, and the soldiers tell them to go to the ship (usually the safest direction).

There should definitely be a panic mode for civis, where they freak out and do counter-productive things, and having them stick to my soldiers like glue would be a great example of that sort of behavior. The default though should be something like the above, a simple, rational, evacuation.

As things are now, civilians are essentially suicidal. The only way to save them is to kill the aliens as rapidly as possible (hence preventing the civis from getting themselves killed). I effectively ignore the civilians when they're not in my way. 
If I could count on the civis to act logically it would improve game play. I might actively seek them out (in order to send them to the ship) and maintain secure routes of egress for them. That would be a significant tactical addition to the game.