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
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:
the faction determines its strategy:
c11 :1/r*(ns+nc+nw)/(ns+nc+nw+0,1)
c12 : (ns+nc+nw)+1/d
c13 : (nw+m +a-c)*(m/(m+0,1))
c14: 1/(ns+nc+nw+0,1)
the faction begin she has few resources no asset, no military affinity, strong trade affinity
to determine the principal strategy you :
in our example :
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 :
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
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
(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
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
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