How to create dynamic links in Netlogo? - Global variables change values for agents, agents interact and then change their type accordingly

I have a system where the two global/systemic variables economic-output-x and environmental-damage-y depend on the distribution of four types of worldviews (utility-assumptions) of the agents in the model. These two state variables get distributed as internal values among all agents as income and exposure. These two marginal or individual distributed valus determine power to persuade (P2P) and susceptibility for persuasion (S4P). Each agent therefore has P2P-x and P2P-y as well as S4P-x and S4P-y.

When two agents meet (Compare former related question) they exchange their internal values of P2P and S4P, which could be conceptualised as a debate, a discussion or a clash of opinions. If the substraction of these values results in a number above a particular threshold, i.e. the range between the two values is high, the 'losing' agent changes his worldview to the other one's worldview (transition), which in turn has an impact on the global variables.

Therefore we have quite a nested network of interrelationships and feedback loops. I am having problems putting this into practice. I have also looked at quite some opinion-influence-models but none quite grasps it the way I am approaching it.

My first attempt looked like this:

     ask turtles [        ; Agents are doing their thing
  [if occupied = "yes" [
    ifelse count-down > 0 
      [set count-down (count-down - 1)]
     [; get the hell out of here
       rt 180
       fd 2
       set occupied "no"
       set count-down 3] 

      if occupied = "no" [       ; Wandering around, ignoring occupied agents
     set neighbourhood other turtles in-radius 2]

     ; If someone interesting and unoccupied is near, communicate!
     set nearest-neighbour one-of neighbourhood with-min [distance myself]
     ifelse nearest-neighbour != nobody [    ; In case someone has been set as nearest-neighbour, encounter is set in motion
         if ([ occupied ] of nearest-neighbour = "no") [
            face nearest-neighbour            
            set occupied "yes" 
 [if ([ S4P-x ]  of self < [ P2P-x ] of nearest-neighbour) [

set worldview [ worldview ] of nearest-neighbour ]

            ask nearest-neighbour [ 
              face myself              
              set occupied "yes"

if ([ S4P-x ] of self < [ P2P-x ] of myself) [set worldview [ worldview ] of myself ]


But that did not really work out. Plus, I am not quite sure whether this is the most elegant way. I doubt it. Is there maybe an entry on this topic on Stackoverflow which I overlooked, which is a little easier to grasp? Or another functionality in NETLOGO, which might fit my needs more appropriately?

Thanks in advance.


I think you probably mean just P2P-x instead of [P2P-x] of myself, and I think you mean set worldview [worldview] of myself instead of set worldview [worldview of myself]. Does that fix it?

You probably don't need to use links unless you want to represent a relationship between turtles that persists over time. If the encounters between turtles are fleeting, involving links doesn't buy you anything.

I'd suggest you look at Communication T-T Example in the Code Examples section of the Models Library, and at other models where pairs of turtles meet and interact, such as PD N-Person Iterated.

Need Your Help

What is the preferred way to store different versions of data?


When you're writing an application that needs to read and work with two versions of data in the same way, what is the best way to structure your classes to represent that data. I have come up with ...

Coloring white space in git-diff's output

git colors diff whitespace

Regarding code formatting I'm kind of purist :). I very often remove unnecessary white spaces (lines with only ws, ws at the end of lines etc). I even have set vim to show that kind of lines colore...