Fight or Flight

Colonists are fickle creatures. You must take good care of them or they’ll starve to death. Or join a cult and start murdering for Quag’garoth (as one typically does when left without supervision).

What I’m getting at is that we’ve got quite a challenge in making colonists act like little virtual people. Part of how colonists end up acting is up to how the player manages then, as it should be in this business of interactive media. But the larger part of the iceberg (to our perspective) is making this possible to say nothing of engaging in the first place, and that’s up to how we hook up the pipes behind the scenes to enable colonists to express varied, interesting behaviour based on stimuli which can be observed and often manipulated by the player.

Fishpeople hate landmines.

Fishpeople hate landmines.

A sprawling example I’ve been dealing with lately is how to make colonists respond to danger. Fight or flight, easy, right? Well …

 

If the answer is “fight”, how long do you fight before flight starts looking like a good idea? We don’t want everyone to fight to the death like a classical RTS meatgrinder. We do expect trained soldiers to fight more diligently than militia, and we expect very little from civilians, though one with the proper personality should indeed fight back if threatened and, in extreme cases, certain traits and emotions may cause a particular colonist to make a last stand.

In the latest update we switched away from a system in which a melee attacker would, in code, essentially turn off the attack target’s brain and run attack/counterattack queries through the attacker.  Now we’ve switched to a system in which it’s up the the target of the attack whether to, at any time, make a melee attack. It’s good not to turn off people’s brains, and this avoids a lot of messy scripting errors, but the whole melee attack/counter-attack system needs to be rebalanced. We can’t just say “50% chance of counterattack” now; instead, we have to ask “what variables would make this character fight back? What traits, what state of mind, what level of injury lie between the decision to fight and to flee?

Militia soldiers employ the bayonet.

Militia troopers employ the bayonet in mêlée.

And then, if a colonist chooses flight, where do they flee to? If they flee entirely randomly, then they may well run right back into the attacker (this used to happen). If they only flee directly away from the attack, then we have colonists running off into the woods being chased by fishpeople, away from any hope of assistance and to inevitable death (this happens now). So, clearly, we need to introduce a little more sophistication here.

(Tangent: I will note for the record that the fact that everything else works well enough that we’re tackling the details of how people run away from enemies is a good thing. Once systems start to work fairly smoothly, we can focus on cleaning up unwanted outlier or  aberrant behaviours.)

Fight

punch

Bali Mangthi Kali Ma!

To provide an example of the gameplay logic going on here, I’ll break down what makes civilian colonists choose to fight back against an enemy in melee combat.

Melee counterattack absolutely requires:

  • a target enemy within one tile
  • not being a soldier or militia (they have a unique job definition with values balanced for the military).

Given those conditions, the subjective importance of engaging in a melee counterattack is affected by:

  • how many afflictions (permanent injuries with particular effects) do I have?
  • how healthy am I?
  • what’s my morale level? (a stat derived from a characters levels of Shock, Fear, and Sadness)
  • how mad am I? (In the sense of insanity; this is working with the assumption that CE’s concept of madness is associated with lack of interest in self-preservation)
  • how angry am I? (An especially angry person is more likely to fight)
  • is the enemy running away? (Currently this makes melee attacking more likely, though I may reverse this – why fight an enemy that’s running? A vengeful or brutal person might attack a fleeing enemy, and that is covered by traits.)
  • do I have various traits, including: “Foolishly Brave”, “Of Criminal Element” (assumed to be more interested in brawling), “Brutish”, “Military Training” (it’s possible to have military training but not be an active soldier)

If the above values exceed the value of running away, then our colonist will fight in melee combat. Most civilians will choose to run rather than fight, though we’re encountering cases where colonists are chased across the map and killed by ‘a thousand feeble fishperson punches’ when said colonist could probably very well take out the fishperson if they turned around and fought back, so this will likely see some re-adjustment.

(Edit: I just realized I should increase the utility of counterattack if a person is holding a tool with the tag “makeshift_melee_weapon”. Neat! And now done.)

Flight

As discussed, running directly away from an enemy is better than running in a completely random direction, but could be better still because we’re seeing colonist behaviour that’s frustrating players. So we talked a bit on the question of different types of running away, different goals that may be sought, and what might affect these. So how about we use these:

  • Flee to civilization (Aka the “center of town” where, one hopes, safety can be found. This is often not the case but it would be a good idea to at least try to head toward town if you’re a colonist out in the middle of the woods and have run into trouble.)
  • Flee toward a soldier (Presumably for protection; may want to make sure the soldier isn’t fleeing as well. Or maybe it’s still valid?)
  • If you’re a soldier, flee to rally point, if any (That’s sort of what it’s for, right? To rally! To expand on this point it’d probably be worthwhile to make some morale-boosting effect when near an officer and rally point so that these would function as actual rally points.)
  • Just run away from danger! (Our current job, and a good fallback behaviour. Perhaps being really upset/injured will override the specific fleeing goals outlined above.)
  • Fight to the death! (Not really fleeing, but it’s a valid subset of these choices. Certain personality traits could cause a character to conclude that fleeing isn’t desirable and they ought to just fight it out. Edit: And Daniel has pointed out to me that this choice is just the natural conclusion of the utility for “fight” always being greater than “flee”, so it doesn’t have to be a discrete subsection of fleeing. … the system works!)

Over to you: Can you think of any more types of running away?

(I know a certain clever modder who keeps doing a great job of rebalancing our combat system for us made a “Flee Indoors” job, but I don’t want to mess with that until we give enemies some kind of ability to break down doors.)

Battle of the Sausage Basket: note fishperson fleeing, fishperson attacking civilian, civilian ... trying to figure out what to do, and soldier performing ranged attack.

Battle of the Sausage Basket: note one fishperson fleeing, two fishpeople attacking a civilian, the civilian … trying to figure out what to do?, and one NCO performing a ranged attack.

… And that’s just one subset of character behaviour. Similar thought needs to go into just about everything that people can get to. Herding colonists, I tell you.

Posted in Clockwork Empires | Tagged , , , , , , , , ,
34 Comments

34 Responses to “Fight or Flight”

  1. Headjack says:

    Hide in a building?

    { reply }
  2. JJ says:

    Could certain objects, characters or locations be given a potential_safe_spot tag, and depending on what’s closer, the colonist will choose a place to flee to. If no where is close enough, they desperately fight for their life. You could use the colonist’s attributes to decide if s/he was likely to be so cowardly that s/he’d run forever.

    { reply }
    • AdminDavid Baumgart says:

      Hmm, this could be cool.

      Unfortunately no where is particularly safe right now. Will probably set the middle of the colony as a generic place to run to, but have a “just run away” that can override “run to center of town” if a fishperson is encountered there.

      As for buildings, once we get the inside of buildings as valid spots for people to run to and for fishpeople to batter the doors of, this’ll really shine.

      { reply }
  3. JoeyHeadset says:

    Run to get a weapon to fight with? Run to alert friends to danger? Run to facility/person that treats injuries? Run to seek sage leadership from that glowing obelisk you’ve hidden in your workshop?

    { reply }
  4. Ghostwoods says:

    How about “Flee randomly in a 150-degree cone away from the threat”, or “Flee towards the dorms and hide under the bed”, or “Climb the nearest tall tree”, or “Flee in a zig-zagging line to confuse pursuit”, or “Go insane and flee straight into deep water and drown/straight off nearest tall cliff” or, for Cultists, “Flee towards the Hideous Blasphemy In The Woods”?

    { reply }
  5. Ghin says:

    I think far more people would choose to defend their homes, bunkhouses, despotic hovels, or whatever than run aimlessly into the wilderness whenever a cabbage rustles. It seems like the colonists don’t consider the size and severity of threats when making decisions. One drunk fishman wandering into town is a different sized threat than a raiding party, which is also a different level of threat than a giant rampaging murder beast.

    { reply }
  6. JR says:

    Off the top of my head, I might choose to flee toward high ground, tall trees, *thick* trees, thick underbrush, a ditch that provides a crawling opportunity out of sight of the terrors, toward anything that provides cover (cornfields?), toward a light source, toward defensible cover, toward a basement or barn that can be barricaded, toward a known cache of weapons… or away from the sea, away from the fighting, away from burning buildings…

    I’d try to deduce what the person values — a communist might feel that collective action would be a solution and might try to run for help and weapons; a royalist would react according to his or her class; low classes might brawl initially but be quickly rebuffed.

    { reply }
  7. Rob Rendell says:

    “Panic and flee in circles”?

    JJ’s suggestion of tagging certain structures as a source of safety is a good one. Gabions, for example 🙂

    I presume that even during the same activity (such as flight), different goals will change in utility so a civilian might initially flee directly away from enemies (especially if the enemies are between them and the centre of town, say), but then change to the “flee to civilization” goal and circle around to the town centre once they have enough distance between them and the enemies, or if they start to get too far from town?

    { reply }
  8. Shtong says:

    I was thinking that an exhaustion system could break the monotony of the endless purchases that we currently have. If a colonist (or fishpeople) runs for too long, depending on its physical condition, it will eventually have to stop to catch some breath.

    { reply }
  9. Bropocalypse says:

    How about fleeing to a designated ‘safe zone?’ Abstractly, the idea is that the citizens have a plan where to evacuate to in the even of an emergency. Of course, in a panic they may forget about it.

    { reply }
  10. Wootah says:

    This Blogpost REALLY needs a video or at least a gif of a fishperson running over a landmine!

    As for combat engagement if you look at ANY sort of aggressor, the the aggressor ALWAYS believes they are going to get more out of the engagement than the party they are engaging…. ie you never see a little tiny guy trying to pick a fistfight with trio of huge policemen. Short of insanity, the aggressor has ‘run the numbers’ and felt that there is something in their favor, such as a weapon(gun), superior numbers(mobs vs riot police), stealth(who poisoned the well?), range(ICBM) or potential to retreat(kids throwing eggs at passing cop cars).

    Even suicide bombers feel that they are inflicting more damage than they themselves are taking.

    What I am getting at is that in every conflict the CE citizens should behave somewhat similarly. If a single, sickly, old fish person that moves around on his fish walker is able to kill multiple people because they fear him for no reason other than he is attacking, something is flawed.

    Part of Heroics in literature/media (is literature media?) is when heroes acts without regard to self… they have effectively set their regard for outcome to self is Zero in favor of cause. The cause is more valuable than self, or my remaining moments in life are forfeit, so why not help the enemy forfeit a little more as well, thus benefiting those who have a chance.

    { reply }
  11. Boberts314 says:

    Maybe chance to flee should be modified by proximity to “help/civilization” and “number of times recently fled”? That would make people more likely to stand together, and less likely to flee infinitely. Especially into the wilderness.

    { reply }
  12. Brandenfascher says:

    I had an interesting idea come to mind, although it may end up just over complicating things. I’ll share it anyways.

    The idea is that each character has a “tolerance gauge”, invisible (or not? maybe only visible in debug mode?) to the player, that after stressful events/actions occur, fill the gauge by an amount depending on severity. At a certain threshold, the character panics and flees. Maybe have another higher threshold for insanity? Over time (before or after the threshold), there will be a slow “drain” of the gauge, representing the character “calming down”, allowing the character to stop panicking.

    How fast a gauge fills (or drains), and how big the thresholds of the gauge are, is determined by many of the character’s traits and experiences. A seasoned soldier will have a high threshold, but may have some traits that fill the gauge faster (if they’re a coward, for example). Certain temporary effects might keep the gauge from filling as fast or at all (such as anger or ale). Certain stressful events might effect others more than others, such as characters who fear being alone, will fill the gauge faster while under those circumstances.

    In my mind, this seems like it would allow the complexities of each character automatically develop their potential to flee, and at what limit, in a variety of circumstances. Anyways, just wanted to throw that out there.

    { reply }
  13. Leonhart says:

    What about swords? What type of melee weapons can we expect aside from the bayonetta?

    { reply }
    • AdminDavid Baumgart says:

      I’d like to give officers some nice sabres – we have models for them, just need a stronger concept of having and then intentionally using melee weapons as a primary weapon.

      Character combat job logic generally treats melee as a secondary attack for bayonets, but this’ll get better as we flesh out some more abilities.

      { reply }
  14. Jabberwok says:

    I like the flee to rally point thing, but if a soldier flees to a rally point, and he’s the only one there, this would probably freak him out instead of boosting his morale. I suppose his personality and rank might affect how long he’s willing to wait around for backup.

    Other considerations for whether to counterattack would be ‘how many enemies vs. friends are close by?’ and ‘how many friendly corpses vs. enemy corpses can I see?’

    I like the idea of some of the less sensible colonists fleeing into the woods. Or even into the ocean…

    { reply }
  15. Rod says:

    Maybe those prone to flight could just run away from the threat in a random direction (obviously not toward the enemy) before making up their minds on where they should go.

    { reply }
  16. Mageous says:

    Neato! I am, Incredibly impressed at the level of depth inside these systems! i have nothing of value to add but i would love to see more “Stuff” IE: new buildings, maybe noble hierachy system in which nobles will fight each other with private guards that don’t do anything for the player which in turn makes for more “FUN” and bla bla bla … on second thought ill take my case to the forums! eitherway good show!

    { reply }
  17. Athisus says:

    Would it be outside the scope of the game to have religious colonists (diabolical and otherwise) try to pray/chant/babble for aid in the face of danger? I can see things spiral hilariously out of control if cultists start summoning things to drive off other things, and then summon worse things to drive off the previously summoned things.

    { reply }
  18. mrclint says:

    If a person is a ‘coward’ and a ‘moron’, he or she might just run straight from the danger.

    If the person is a ‘coward’ but ‘smart’, the safest route to survive would be to run for the town or nearest soldier.

    But what if the ‘moron’ survived and heard that a better way of surviving is to run to the soldiers, or were told by the ‘brave’ that he stayed and fought and won the fight.

    With a function to lose or gain a trait (or higher fear threshold or whatever) it could be learning by doing and learning by watching other fail or not fail.

    It could be fun to see a disorganized group of settlers slowly and painfully become a group of people who have learned from their experiences.

    { reply }
  19. Mini Reddish says:

    Loving the sound of all this so far, it’s really got my interest. As for the topic of fleeing when I was reading this, I was wondering on the possibility of the tiles being able to store a value which represents its own safety. And units/buildings have various AoE effects on the grid when they are made/moved.

    From this, I would then assume that since each tile has it’s own safety value, it could be used within a pathing algorithm for the fleeing subject to try and find a relatively safe path.

    { reply }
  20. Shaun says:

    Could you make it so we can build bunkers/some kind of hard to get into (for none ally units) place that they can hide in until someone or the user declares it as safe to do so?

    { reply }
  21. DelicateTask says:

    I want citizens to fight back if in groups. If one fishperson without any sort of armaments walks up to five foragers, then they should realize they have the advantage and beat the fish-flavored stuffing out of the oversized, bipedal tuna.

    Maybe have a group morale level for people in a small area, so that one solitary fish isn’t enough to tip the scale towards flee. Additionally, that would mean that we can have fun things where if a group is fighting, and a bunch of panicking pansies runs into the middle of it, everyone freaks out together and disperses. Fear is contagious. People do stuff like that all the time.

    I always loved how dwarves in DF would usually run away from enemies, but a few would launch themselves at the enemy face first and batter them with anything they happened to be holding. (Always with hilarious amounts of severed parts sailing off in an arc.)

    { reply }
  22. Foolish Folly says:

    Concerning the technical side of it all, some years ago I had to do with a technique called harmonic potential fields, that were used in navigation.

    Here you go with a slideshow, look on slide 7 for a diagram, unfortunately the thing is in german, dear me.

    I imagine this approach to be quite fun approaching your current problem. A villager would be modeled as a drop of water, always “sliding downwards” in the potential field.

    The various threats and safe harbors can be modelled using just one numeric value. Say, a fortress has a value of -100 (very deep hole, drop wants to slide down into it) and an enemy has a value of +30 (a hill, drop wants to go around it). Considering the point where a villager is located, a direction vector can then be calculated using all influences.

    Upsides: you always get an answer in the form of a direction vector.

    Downside: may be too logical (its totally not random, although it can be randomized later), and characters can get stuck in a local minimum (for example if surrounded by enemies, they would stay in their little hole surrounded by hills).

    Cheers!

    { reply }
  23. Zleeping says:

    In terms of how injuries affect “fight or flee” behavior, I think someone with no injuries would be bolder than, say, someone with light or medium injuries, with the reasoning that they are in a more fit condition to fight back. But if their injuries start to enter from medium into heavy, they will always fight back, the reasoning being if they don’t, they are goners. Sort of a “last gasp” if you will. Also, in dwarf fortress, I recall being able to throw a fluffy wamblers at bronze colossus’ and watch their heads fly off in a shower of gore. I recommend a similar mechanic be implemented.

    { reply }
  24. Thomas Henderson says:

    One thing that struck me when reading your blog is that all of your failure cases – people fleeing into the arms of danger, people not fighting back when they actually could win, people fleeing off into the woods and then getting slaughtered etc. are all things that actually happen in the chaos of combat. I understand that you want each of your sim actors to act in their own self interest but when people are in flight mode they often don’t.

    Perhaps you could find a way to keep some of these behaviors as outliers ?

    { reply }
  25. Blue Footed Booby says:

    What about a “fighting retreat”? I’m thinking the logic would basically be flee, but if more than X feet away interrupt fleeing long enough to fire a shot. This may fall naturally out of a threat that falls right on the border between fight/flight, but it seems like the sort of thing that martial training should make more likely.

    { reply }

Leave a Reply to DelicateTask { cancel }

Your email address will not be published. Required fields are marked *