NPC faction strategy and behaviour proposition

    Joined
    Jun 26, 2013
    Messages
    161
    Reaction score
    192
    • Purchased!
    This idea concern npc faction . It is a proposition of a way to implement a form of behaviours and strategies


    tl,dr : use a number of arithmetic value to determine faction characteristics (traders salvagers warrior, …) and use them in decisions tree to determine objectives and in decision tree to determine actions


    now for the in depth explanation:


    The faction have different data:

    known space, possessed space

    assets: resources, warship, cargo ship, salvage ship,...

    The factions have a set of values representing their affinity in different domains (trade, military, etc)

    they have"character" traits
    • aggressiveness
    • defensiveness
    • cooperativeness

    for instance a faction with strong military but mostly aggressive will tend to dominate other, in the contrary.

    the same faction but mostly cooperative will tend to offer/sell protection to others.

    all these data are stored in a config files so they can be altered by admin to customise faction.



    The different characteristics are used in behaviour threes.
    (See Behavior tree (artificial intelligence, robotics and control) - Wikipedia, the free encyclopedia)


    a behaviour three to determine the strategy (a primary and secondary objective) the faction will follow to narrow its possible actions.


    a big behaviour tree (or multiple behaviour tree, one for each strategy) to determine the action the faction will choose


    and behaviour tree to determine reaction

    for instance the faction would choose a strategy, make 20 actions and/or reactions, then choose again a strategy, then make actions,...etc


    I will now explain how it work by an example (the value are just to illustrate):

    let say the faction have these value:
    • net: number of explored territories
    • npt: number of possessed territories
    • nw: number of warships
    • nc: number of cargos
    • ns: number of salvagers
    • r: resources
    • trait
      • m: military
      • t: trade
      • e: extraction
      • a : aggressive
      • d: defence
      • c: cooperative

    the faction determines its strategy:


    c11 :1/r*(ns+nc+nw)/(ns+nc+nw+0,1)

    1/r: the less you have resources the more you will want to gather them

    (ns+nc+nw)/(ns+nc+nw+0,1): if you don't have assets to gather resources you can't​

    c12 : (ns+nc+nw)+1/d

    (ns+nc+nw) the more you have asset, the more you will tend to expand

    1/d: the more you are defensively careful the less you will try to expand​

    c13 : (nw+m +a-c)*(m/(m+0,1))

    nw+m : the more you have warship and are a military faction the more you will tend to conquer

    a-c: the more you are aggressive and less cooperative you are the more you will tend to conquer​

    c14: 1/(ns+nc+nw+0,1)

    the less you have assets the more you will tend to build some​



    the faction begin she has few resources no asset, no military affinity, strong trade affinity


    to determine the principal strategy you :
    • calculate c11,c12,c13,c14
    • choose randomly a number k between 1 and (c11+c12+c13+c14)
    • if k is between 1 and c11 you choose “gather resources”
    • if k is between c11+1 and c11+c12 you choose “expand”
    • .....
    • etc

    in our example :
    • c11 = 0 because the faction have no asset
    • c12 is a little number
    • c13 = 0 because the faction have no military affinity
    • c14 is big number because the faction have no asset

    so build is the option that would almost certainly be selected.

    To select the secondary objective it will be the same thing. In our example because the faction have few resources it will more likely choose gather resources

    now we have the strategy the faction will follow we will choose among the available action one to execute.


    Following our example the faction will build and gather resources.

    This is the same principle as before

    Because the faction has no military affinity it will never build warship or try to pillage.


    Turn 1
    Because it has no asset it won't trade or salvage but will build most likely cargo ship because it has a great trade affinity but there is chance it build salvager. It finally choose to build cargo fleet

    Turn 2
    it as few cargo asset and great trade affinity so there is a chance it will trade but still a great chance to build assets.

    ...
    etc




    implementation.

    In term of coding it is easy but fastidious to implement. It is just some arithmetical calculus, number comparison and switch case.


    The difficulty comes beforehand during the conception :

    • determine all the actions factions can accomplish
    • determine all the reactions factions can have to actions to build the reactions tree
    • then define the strategies faction could have and construct the strategy tree
    • use the strategy tree to make the big/different actions trees
    • determine all the parameter (number of ship, military affinity, trade affinity, ...etc) needed
    • elaborate the formula determining each tree branch probabilities.

    I think in term of performance it should be light except if the formulas uses complex arithmetical operations.

    (optional) Positive retro action.

    It could be possible that the faction ai evolve depending on its previous actions (if it follow aggressive decision and it work then the faction will tend to do more aggressive actions)each action would be linked to a characteristic and a trait ( propose a trade alliance , would be linked to trade trait and cooperative behaviour for instance ) and if the action succeed it would increase the concerned value or decrease if it fails .So the more a faction will make successful aggressive military action the more is aggressive tendency and military affinity will increase and so it will choose more often aggressive military actions.

    What do you think of this idea ?
    do you think of any way to
     

    NeonSturm

    StormMaker
    Joined
    Dec 31, 2013
    Messages
    5,110
    Reaction score
    617
    • Wired for Logic
    • Thinking Positive
    • Legacy Citizen 5
    Neufeld Institute | Gordon Neufeld PhD
    How human biology works - we totally get trashed by Kindergärten!

    Humans need a safe-harbour / safe-port which are their parents.
    One of these safe-ports, which are usually close relatives or close friends of parents, should ALWAYS be with the child.
    But Kindergärten and Schools exchange trust-persons every 2-3 years and swaps them every 2 hours or every day (different teachers).

    We humans are hard-wired to learn faster from those we trust, but by swapping persons of trust … we actually LOSE trust.

    Instead of trusting peoples vertically by trusting adults and older brothers, we trust horizontally these with similar age.
    Can a 2-year old learn language from other 2-year old?

    I can only suggest you reading through this and figure out if it matches your observations in real life.

    Figure out how humans work and then you have it easier with designing NPCs and Aliens.
    Maybe we humans are violent because we get stuck in early brain development.
     

    Lone_Puppy

    Me, myself and I.
    Joined
    Mar 12, 2015
    Messages
    1,274
    Reaction score
    529
    • Purchased!
    • Community Content - Bronze 2
    • Legacy Citizen 8
    Maybe we humans are violent because we get stuck in early brain development.
    I wonder if our violent impulses/responses are initially born from frustration in early life, and then become an embedded reflex due to a lack of not knowing an alternative to problem solving and resolution. If we never learned this behavior and only learned alternatives to violence, I wonder if the outcome or prioritization within our brains might be different.
    As for learning an alternative after violence, it could become a matter of reaffirmation or some kind of reinforcement process in our brains I guess to avoid it.

    Either that or we just like bashing and blowing up stuff. Ooooh.. pretty lights.... ! ;)
     
    • Like
    Reactions: NeonSturm
    Joined
    Jan 25, 2015
    Messages
    964
    Reaction score
    225
    • Wired for Logic
    • Councillor 2 Gold
    • Legacy Citizen 5
    What do people think of this suggestion?


    I wonder if our violent impulses/responses are initially born from frustration in early life, and then become an embedded reflex due to a lack of not knowing an alternative to problem solving and resolution. If we never learned this behavior and only learned alternatives to violence, I wonder if the outcome or prioritization within our brains might be different.
    As for learning an alternative after violence, it could become a matter of reaffirmation or some kind of reinforcement process in our brains I guess to avoid it.

    Either that or we just like bashing and blowing up stuff. Ooooh.. pretty lights.... ! ;)

    Wait it is normal to have violent impulses? What happens if you learn alternatives to violence? Being a person that does that and having a friend that is awesome at not using violence I can tell you, You are right, you avoid problems and if the problem follows you, you become its friend until you find a way to get rid of it (e.g. a bully/group of drunk people) a simple joke and they might already leave.
    It's actually a lot like politics (the nasty kind). They avoid problems and if there are problems they avoid recognising them openly as a problem unless they gain something in recognising the problem.
     
    • Like
    Reactions: Lone_Puppy