Goodvino
Goodvino

Reputation: 1

Asking Agents if their memory contains a minumum Number of a certain value

Hey I am developing a model that should feature a relatively simple memory that updates with this procedure and puts a 1 every time the agent perceives there is something wrong with the environment through the following:

  ifelse fishpop < concern-t-env [
      set memory-env lput 1 memory-env
      if length memory-env >= 6 [set memory-env but-first memory-env]
    ]


The memory is of length 6 and sometimes looks like this:

memory [1 1 0 1 0 1] 

Now i want to ask the agent that owns the memory to check if there are more than 3 ones. Which could be a way to ask this? I am not sure how I could ask the agent to check if the number of 1s is bigger than a threshold?

I tried using n-ofbut was not sure how to follow up. It is probably relatively easy to do but i dont seem to find the solution

Upvotes: 0

Views: 30

Answers (1)

Steve Railsback
Steve Railsback

Reputation: 1736

This one is easy: there are more than 3 ones in your memory list if the sum of the list items is more than 3:

if sum memory-env > 3 [do something]

(If you are modeling how an agent's perception of the environment varies with the size of the fish population, you might eventually be interested in the Bayesian updating algorithm described in sect. 12.5 of Railsback & Grimm www.railsback-grimm-abm-book.com . It updates an estimated probability depending on how many times an event does and does not happen.)

Upvotes: 1

Related Questions