Question on Faction Relation

Users who are viewing this thread

saxondragon

Sergeant Knight at Arms
Hey guys,

I have a question and I cannot find reference to it.  I am hoping that you guys who are more versed in programming than I am, may happen to know the answer.  .

How do we store factional inter-relationships?

Based upon how we define and retrieve this information there are two approaches with very different rammifications.

Is it a 2-D Matrix, like a simple table, meaning that we cross index faction 1 with faction 2 and we get a number that represents hostility level.  This is supported by one view of the store relationship command:
(store_relation,<destination>",<faction_id_1>,<faction_id_2>),

Or

Is it a three Dimensional matrix, where there can be a different hostility level where Faction 1 hates faction 2, but faction 2 is neutral to faction 1.  This will have the effects of faction 1 chasing after faction 2 to engage in combat, but faction 2 will not chase faction 1.  This approach is supported by the faction declaration command:
Code:
("kingdom_1_rebels",  "Swadian rebels", 0, 0.9, [("outlaws",-0.05),("peasant_rebels", -0.1),("deserters", -0.02),("mountain_bandits", -0.05),("forest_bandits", -0.05)], [], 0xCC2211),

("outlaws","Outlaws", max_player_rating(-30), 0.5,[("commoners",-0.6),("player_faction",-0.15)], [], 0xE0FFFF),

If the former is true, then how is the variable stored when given conflicting values?

If the latter is true.. then does this command  (store_relation,<destination>",<faction_id_1>,<faction_id_2>), work as storing from faction1 get the relationship to faction 2?  Or is it From faction 2, get the relationship to faction 1?


Thank you kindly for the insight..

Best,

Saxondragon


 
I had guessed that it was the 3D case but I hate guessing so I wrote some code to test:
      (set_relation, "fac_kingdom_1", "fac_kingdom_2", -51),
      (set_relation, "fac_kingdom_2", "fac_kingdom_1", 49),
      (store_relation, reg0, "fac_kingdom_1", "fac_kingdom_2"),
      (store_relation, reg1, "fac_kingdom_2", "fac_kingdom_1"),
      (display_message, "@post k1 to k2:  {reg0}, k2 to k1:  {reg1}"),

As it turns out, it's the 2D case and seems to be the same for bandits and kingdoms.  It's the same for initial state as specified in module_factions.py; it just takes the last one. 

Hope that helps.
 
kt0 said:
I had guessed that it was the 3D case but I hate guessing so I wrote some code to test:
      (set_relation, "fac_kingdom_1", "fac_kingdom_2", -51),
      (set_relation, "fac_kingdom_2", "fac_kingdom_1", 49),
      (store_relation, reg0, "fac_kingdom_1", "fac_kingdom_2"),
      (store_relation, reg1, "fac_kingdom_2", "fac_kingdom_1"),
      (display_message, "@post k1 to k2:  {reg0}, k2 to k1:  {reg1}"),

As it turns out, it's the 2D case and seems to be the same for bandits and kingdoms.  It's the same for initial state as specified in module_factions.py; it just takes the last one. 

Hope that helps.

Yes, that is extremely helpful.. not the answer I was looking for, but your help was invaluable.

Thank you!

Best,

Saxondragon

 
A fun error in one of my ai scripts made me learn that a kingdom can be at war with itself, so I guess the table is complete including a "relations with self" value.

Using this may allow to make a kingdom AI make difference between itself and allies, without checking the kingdom_id everywhere, or to make a kingdom collapse in a chaotic civil war by event.
 
Twan said:
A fun error in one of my ai scripts made me learn that a kingdom can be at war with itself, so I guess the table is complete including a "relations with self" value.

Niiiiice...  :shock:  :mrgreen:  Thanks for sharing that info..

Saxondragon
 
Back
Top Bottom