project-navigation
Personal tools

Author Topic: Civilians... those little buggers.  (Read 42894 times)

florian

  • Guest
Re: Civilians... those little buggers.
« Reply #30 on: March 04, 2008, 06:15:09 pm »
I wrote down some thoughts I had about a civilian ai system:

Each civilian has a mood, which changes dynamically and which has a value between 0 to 100.
This mood could be roughly divided into panic (<20), afraid (20-60) and cool (>60).

Events happening around the civilian can change his mood:
- If he sees an alien his mood decreases
- If he sees an alien being shot at or killed his mood increases
- If he sees a phalanx member or another civilian his mood increases
- If he sees a phalanx member or another civilian being shot at or killed his mood decreases
- If he gets shot or hears shots or explosions, but doesn't see anything his mood decreases
- If he's at the dropship or a phalanx meber talks to him his mood increases
- Every round the mood increases very slightly (this way the person slowly calms down)

How strongly the mood increases or decreases depends on the civilian itself. Every civilian has an increase factor and a decrease factor which get multiplied with the increase or decrease of that particalur event and added to the characters mood. A high increase factor and low decrease factor means the person stays cool most of the time. A high decrease factor and low increase factor, on the other hand, means that the person panics easily and is hard to calm down. If a civilian has picked up a gun his decrease factor will be even lower.

A soldier at a military base will have a low decrease factor and a high increase factor. A male civilian could have a medium decrease factor and a low increase factor, while a female civilian could have a high decrease and a medium increase factor. Of course these factors differ individually and could also depend on the place. An urban area might have noticeably higher decrease factors than a rural area.

The mood of a civilian influences his behavior. If he panics he will choose a random direction and try to walk that way. If he is afraid he will try to find a good hiding place behind a grate, desk, tree or inside an empty room. Finally, if he is cool he will try to get to the phalanx team or the dropship as quickly as possible (if he knows where that is). If a civilian sees a dropped gun and knows how to use it (all soldiers and a few other civilians should know), then he might pick it up. If he's cool he might use it to shoo at the aliens, but if he panics he might shoot around wildly and even hurt other civilians or phalanx members.

If a civilian panics, a phalanx member could talk to him and thereby increase his mood until he calms down to being afraid and hides somewhere. If a civilian is afraid a phalanx member could talk to him and so make him walk to the dropship.

If a civilian sees something negative (an alien, maybe even a dead civilian, ...) this place will be marked as a fear point. He can remember a small number of those fear points at the same time. If he is afraid he will search a hiding place away from the fear points. If he panics he will ignore those fear points completely. If he is cool and armed he might even go to those fear points and try to shoot the aliens. If he is cool he will try to get away from the fear point and to a phalanx member. If he sees a phalanx member he will try position himself so that the phalanx member is between him and the fear point.

The mood of a civilian also changes his speed. A civilian in panic is faster than an afraid or a cool civilian. This makes sure that a afraid civilian who has been hiding runs away quickly once he has been discovered and panics.

Finally each civilian has a property which indicates if he feels safest where he is right now. An afraid civilian who has found a hiding place won't move more than a step away from a safe place until he has calmed down to being cool or until he is found. A cool civilian, on the other hand, stays roughly where he is once he has found a quiet place behind a phalanx member, but he will search for a better hiding place once he has been discovered, gets afraid and doesn't feel save anymore. This last property is supposed to make sure that civilians don't run around unnecessarily and get in the way of the phalanx team.

The initial mood is influenced by the civilian's character and the distance to the aliens and should be either cool or afraid, but not panic. Additionally a first fear point for every civilian should be place over the initial position of the aliens. The distance is included because civilians who are far away from the aliens should be relatively cool and walk towards the phalanx team, while civilians close to the aliens should better hide somewhere and wait for the phalanx team.

With some fine tuning this could result in quite believable civilian behavior.

Panthera Leo

  • Guest
Re: Civilians... those little buggers.
« Reply #31 on: March 04, 2008, 11:26:03 pm »
Great ideas. Anyone up for coding it?

Form orderly queues, please...

 LOL, An appeal to my dark side!  ;D

 I think that's my new favored quote! Do we have a FAQ or chart laying out how the source code is built. I don't have the time now, or in the foreseeable future, but it's definitely on my list of things that "might be fun". After finishing my bloody NWN Mod to get units to march in formation. It's almost done, just classes take too much time for me to sit down and get the work done.(Damnable script restrictions! The project is nearing it's err another birthday.)

The wiki on the subject is not directly useful, but branches out to all manner of useful links.

The approach I would use?  First, in either method, make the absolutely huge data file. Running though every map, I would have each side (PHALANX, VXI, and Civi) have side move though every possible unit combination in every valid place to stand.

Then maybe make a second data file. Give every unit the ability to use any valid item available to it's side, move one square, or be shot at from any given enemy unit able to see it in a given senario. Seeing this is the AI I'll ignore PHALANX for the most part, and assume that the AI's stats are not totally random. I'll then automate some process to either make a formula, or do another loop for each set of stats. What this will do is give a expected outcome for any of the actions the unit does or has done to it(get shot at).

We'd then make a list. This list would look at the above, being just single actions, and string them together based on the expected outcome of that action. For example, I need to move up to enemies position to fire at "them". The above list would just have the 'move up'  or 'fire at "them"' actions, but they wouldn't be directly connected. It would just have a entrie saying, given this goal this is the most desirable action to meet that goal. In this case(not being able to desirable to fire at them now.) the entry for the current unit deployment to fire at "them" would list "move up" as the desired action.

So what this pass would do is string like entries together by looking at the above data file and following each entries, from entry to entry, of desired actions until it found a action that directly met it's goal(SHOOT THEM!). In this case it would link move left, move left, and FIRE! into a list. Each list would then be given a set of goals it was design to meet("I want to shoot this guy!") So the AI could then see what it wanted to do and have the actions need to meet that goal already laid out for it. Of course, we'd only make lists of actions that where longer then one action long :)  However, this too would be a massive, maybe even bigger, file and only marginally useful, thankfully it just happens to be useful, it's not the end goal!

Plan A:

Also, thankfully I happen to know a trick that should cut that down to size, and layer that into a easy to use format tied into the map file.  Each square on the map a unit can occupy is given a blank node(class object) containing a list of all possible actions. Then use the above file and list to populate each action in the node with how well each action will work to the desired goal. This node could also be altered to each AI unit on the map, with each AI keeping a list of the last it use from the last turn or two, then update the weight on each action based on what really happened to the AI. This way the AI could "learn" as the game progresses. Making each install, if not game, unique the more it's played. If you do that though I suggest a short term, that degrades over time, and long term weights. The AI using the sum of both, and only affecting the short term weight. Then a fraction of the short term changing the long term to keep freak accidents from wrecking the AI.

Plan B:

Each square on the would have a node(read as class object). This node would then be given a list of goals you can accomplish here, and actions that accomplish that goal, taken directly from the first data file. Not very useful for much. This is where the lists we just made comes into play, and gets narrowed down.

We'd go though the above lists starting with the first action of each list. We'd start at the node the first action was based off off. Then instead of giving a single action to do, we'd give a pointer to the first action in this list, and tell the AI to "hop to buddy!". We'd then move down to the second action in the list, and add a pointer from the node the first action leads us to to the second action in the list. and so forth. Associating each pointer we make with the outcome the list is to accomplish.

To keep the from accessing the map nodes every time it so much as moved, could be made to only look at the node network when it needs to. Looking ahead from node to node, storing a list of each action each node stores. Then either only accessing the network again when it's done or something changes enough it needs new instructions.

A CO:

Up to now the AI has been basically "every (man) for himself!" The CO would be a script that doesn't look at each unit as a single unit, but looks at each unit as one single "unit". Then looks what action(s) would most benefit the squad or best meet the squads goals. Then enforces those actions on the squad. So each unit doesn't have a AI per say. The "CO" script in the background is the one calling the shots, the units just look at the best way to follow the given orders. It also has the advantage of off loading the work into a central point that only has to be run once each turn, instead of over and over by each unit in turn.

Edit: Maybe even preloading plans of attack, or save passed successful actions.
« Last Edit: March 04, 2008, 11:33:54 pm by Panthera Leo »

NQue

  • Guest
Re: Civilians... those little buggers.
« Reply #32 on: March 21, 2008, 12:59:09 am »
Hey all,

Wouldnt something simpler like the following work better? (And easier to code.):

When a civilian sees an alien, have it remember the square where the alien was seen, and move away from the block, towards an enclosed space (like a room in a house for example) for x turns, or until it (being dumb, that's all they deserve) sees another alien, in which case it moves as far away from the two aliens as possible, once again for x turns. That way, the civilians won't all end up in the corners of maps, but rather in, well, rooms. Also, if seeing a second alien reminds it of the first (i.e. the x turn count resets for both alien 1 and 2), then it wont just run back to the 1st alien. Unless of course, the alien has moved...

I like the earlier post about moving so that a PHALANX soldier is between the civilian and alien as well. It would make sense to me if I somehow found myself amidst alien-soldier gunfire.

This way, it wont be as easy for aliens to kill civilians (as is the case currently), but it is still not impossible.

In the case of self-arming and attacking civilians, it might be great to see happen, but I'm thinking it'll end up as a negative outcome. (Maybe that's a good thing for the game?)

Offline Silveressa

  • Rookie
  • ***
  • Posts: 40
    • View Profile
Re: Civilians... those little buggers.
« Reply #33 on: March 28, 2008, 03:39:22 pm »
Greats so far, but I'm sure I like the ideas of regular civvies arming themselves, since they're already terribly vulnerable, having them try and stand and fight is very likely to just rack up more civ deaths than them retreating.

However, maybe having a few extra civs thrown into the mix that don't count towards the civs lost limit (randomly appearing on some maps, not on every single one) that are capable of rudimentary defense and have a fair amount of armor/weapons. (Such as police officers with body armor and smg's or national guards men with rifles) After all, among the ones left alive by the time phalanx gets there, attrition should have killed off all but the most sneaky, capable, or plain lucky.

This would help add diversity to a maps a little, and maybe slow down the aliens a hair on exterminating the meat bags, since it would take them a few turns to nail the ones with guns and armor.

For now though just a simple alteration for the civvies to move away from sighted aliens would be helpful, until something more complex can be coded.

Offline Robb77

  • Cannon Fodder
  • **
  • Posts: 6
    • View Profile
Re: Civilians... those little buggers.
« Reply #34 on: April 05, 2008, 02:48:00 am »
About that, version 2.2.1, which will mainly be a bugfix release, will have the civilian death limit removed. Instead you will lose if you make too many nations unhappy, which happens if you let too many civilians die.

thank god ;D

Offline Doctor J

  • Squad Leader
  • ****
  • Posts: 265
    • View Profile
Re: Civilians... those little buggers.
« Reply #35 on: April 05, 2008, 06:18:37 am »
I just recently tried a multiplayer against the AI, which also included civvies.  These guys seem to behave different from those in the campaign game: rather than wandering towards danger they tend to stay in the corners of the map and crouch down a lot.  Am i just imagining this, or can somebody familiar with the AI code clue us in?

Offline blondandy

  • Sergeant
  • *****
  • Posts: 391
    • View Profile
Re: Civilians... those little buggers.
« Reply #36 on: April 05, 2008, 06:52:05 pm »
In trunk?

I think it is only very recently (ie not 2.2) that the AI made anyone crouch.

Offline Doctor J

  • Squad Leader
  • ****
  • Posts: 265
    • View Profile
Re: Civilians... those little buggers.
« Reply #37 on: April 06, 2008, 02:06:29 am »
I just saw it again on 2.2-Jan 15-OSX build: started a non-public coop2 multiplay, and forced start.  After the bodies start hitting the floor, the remaining civvies cower down with their hands over their heads.  If there is anything else i can do to get to the bottom of this mystery, let me know.

Offline mutant

  • Cannon Fodder
  • **
  • Posts: 9
    • View Profile
Re: Civilians... those little buggers.
« Reply #38 on: April 06, 2008, 05:15:12 am »
Civilians have always done this since the first released demo as far as I'm aware.
(Once saw a civilian crouch and pickup a kerrblade as well!)

Offline BTAxis

  • Administrator
  • PHALANX Commander
  • *******
  • Posts: 2607
    • View Profile
Re: Civilians... those little buggers.
« Reply #39 on: April 06, 2008, 12:41:01 pm »
I'm not sure how useful it would be to investigate this in detail. bobbens is working on a complete rewrite of the AI. It's anyone's guess when it'll be done, though.

Offline Doctor J

  • Squad Leader
  • ****
  • Posts: 265
    • View Profile
Re: Civilians... those little buggers.
« Reply #40 on: April 06, 2008, 06:01:23 pm »
Civilians have always done this since the first released demo as far as I'm aware.
(Once saw a civilian crouch and pickup a kerrblade as well!)

This whole thread got started because civilians in the campaign game make absolutely no effort to hide, but instead are magnetically attracted [animal magnetism?] towards the aliens.  It seems weird that civilians in multiplay are so much smarter.  Maybe they can set up some classes for the others?

Offline mutant

  • Cannon Fodder
  • **
  • Posts: 9
    • View Profile
Re: Civilians... those little buggers.
« Reply #41 on: April 06, 2008, 11:05:01 pm »
I haven't tried the multiplayer so I wouldn't know but I don't see why they should act any differently.

Offline Falion

  • Rookie
  • ***
  • Posts: 70
    • View Profile
Re: Civilians... those little buggers.
« Reply #42 on: April 17, 2008, 10:05:58 pm »
Now that I've played for a bit, I can say the Civies are morons much of the time as well :) They either go right towards the aliens to be slaughtered like lemmings, or they somehow attach themselves to one of my soldiers hips and follow him/her around like a puppy...quite irritating little guys they can be at times.

I can somewhat understand the second one...if big bad aliens were looking to give "me" a dirt nap, I'd be hanging close to the guy with the big gun as well. But honestly...if I had the choice...I'd be making tracks for places unknown and getting out of dodge and away from the firefights if at all possible.

Now as to the first...and why they just seem at times to march towards their own destruction...that kind of baffles me...have they been drinking some type of AI adult beverages or something? ;D

The game itself is really on it's way to being something really great IMO once it's finished, so not really moaning about the civilians, but in all they could stand a little "awareness" improvement :)
« Last Edit: April 18, 2008, 03:59:42 am by Falion »

Offline Silveressa

  • Rookie
  • ***
  • Posts: 40
    • View Profile
Re: Civilians... those little buggers.
« Reply #43 on: April 17, 2008, 11:05:48 pm »
Hmm, I can think of one reason why they're so stupid. Usually Phalanx responds  after a good 12 hours  (or more) have passed right? By then all the smart ones have probably already left and the aliens are experimenting with the left overs to see if they make good pets or not.  ;)

Perhaps the simplest "hot fix' for them is to make a civilian move in the opposite direction their being shot at from for 2-3 turns? It would alleviate the lemming syndrome and them aimlessly wandering back and forth in the same path like a tin duck at a shooting gallery.

Offline Doctor J

  • Squad Leader
  • ****
  • Posts: 265
    • View Profile
Re: Civilians... those little buggers.
« Reply #44 on: April 18, 2008, 08:40:10 am »
Hmm, I can think of one reason why they're so stupid. Usually Phalanx responds  after a good 12 hours  (or more) have passed right? By then all the smart ones have probably already left and the aliens are experimenting with the left overs to see if they make good pets or not.  ;)

ROTFL!