0

My model has two breeds of agents, police officers and sex workers, and intends to model the effects of different policies on trust creation (vs. fear) between police and sex workers. It includes a variety of other aspects, but I based it on a mix of the Biology/Virus model and a diffusion network.

As the model is currently, sex workers change their property [trust?] based on one-time interactions with police officers (depending on the policy, these act controllingly or trust-inducing, or a mix), while sex workers are also connected among each other on a preferential-attachment network that affects [trust?] based on the majority of their neighbors.

Now, I want to make it more complex by adding a counter so that property is changed only after a certain amount of police interactions, not after the first one.

How can I include such a counter?

Thank you so much!

Upon request, here the sample code of the behaviors that affect trust:

    ;; determines officers' behavior based on policy and friendliness 
  ask officers [ 
    move 
    if friendly? = true [ ask officers [comfort] ] 
    if malicious? = true [ ask officers [control] ] 
    if policy = "criminalize" AND friendly? = false [ ask officers [control] ] 
    if policy = "regulate" AND friendly? = false AND malicious? = false [ ask officers [regulate] ] 
    if policy = "decriminalize" AND friendly? = false AND malicious? = false [ ask officers [comfort] ] 
  ] 

;; asks sex workers next to officers to trust 
to comfort 
  ask other sexworkers-here with [ trust? = false ] [ trust ] 
end 

;; asks sex workers next to officers to be scared 
to control 
  ask other sexworkers-here with [ trust? = true ] [ fear ] 
end 

;; asks sex workers next to officers to be scared if they are young 
;; or have less than two links 
;; asks sex workers next to officers to trust if they are older 
to regulate 
  ask other sexworkers-here with [ age < 10 ] [ fear ] 
  if network = "preferential-attachment" [ 
    ask other sexworkers-here with [ count link-neighbors < 3 ] [ fear ] ] 
  ask other sexworkers-here with [ age < 30 AND count link-neighbors > 3 ] [ trust ] 
end
Mira Fey
  • 49
  • 5
  • 2
    I think we'd need to see some sample code to really help you out. You can create counters in NetLogo as a variable and update them when some condition is met e.g. `if condition = TRUE [set trust trust + 1]` – adkane Feb 14 '19 at 16:23
  • Thanks, I didn't add code because honestly I am not sure which part of the code would be most useful here. I will add the rules that change trust. – Mira Fey Feb 14 '19 at 16:46
  • Oh yeah, and I set [trust?] as a binary property of the breed sex workers, not as a continuous variable, thus it wouldn't really work to set trust + 1, but that would be easily adapted to change trust? = TRUE when a certain treshold is reached, I assume? – Mira Fey Feb 14 '19 at 16:59
  • Check out the answer here https://stackoverflow.com/questions/4296818/how-can-one-create-a-countdown-timer-in-netlogo You could make it a count-up timer and swap out the minuses for pluses – adkane Feb 14 '19 at 17:03
  • Thank you for this, but sadly it would not work for what I intend as it is based on counting down ticks. What I intend to count is iterations of police officer-sex worker interaction, not ticks. I already have a tick counter included in the model. – Mira Fey Feb 14 '19 at 19:25
  • Thank you for adding code as per @ManassaMauler. However, it would be more useful if you could provide a [Minimum, Complete, and Verifiable Example](https://stackoverflow.com/help/mcve) that would allow users here to just copy and paste to run your code. As is, your code is not something that users can use, so the best we can do is give general advice (as Manassa mentioned, a counter would work) or point you to other answers, such as JenB's answer [here](https://stackoverflow.com/questions/47365862/netlogo-how-to-stop-a-turtle-for-a-certain-ticks-with-a-specific-patch-in-the-m). – Luke C Feb 14 '19 at 22:55
  • Thanks. This would potentially mean to post really most of the code of the model which seemed really excessive given that in most answers, people hint to the fact that too much code was provided :) Essentially, I just look for a way to count interactions between turtles. So maybe switching trust to a counter might be the best option. – Mira Fey Feb 15 '19 at 08:56

0 Answers0