comparison - NetLogo: Create random array for global variable -
I am trying to create a model in which a question is in front of the tortoise. Each turtle represents a unique domain of knowledge (1, 2, 3, 4, 5 ...) and in each question there is a random subset of the domain, e.g., (3 5 8).
Then I want to ask the turtle with the IDs that are included in the answer to the question. I'm hoping to get some advice on this:
- How to create a random array for the question (global variable) and;
- Ways to Compare against Turtle ID
This is my first time using NetLogo, so I apologize for the ignorance. And I'm definitely not requesting you to do this work for me, but how do I use some advice / orders in the right direction?
2. For comparison, I have written the following but I am sure this will work. My concern is that if he is looking for an exact match of the query array with the kurtl id, then a match will never be found. What is my intention, if a turtle id is anywhere in the array, then [set the expert? 2]:
To answer an answer Agarwal question [If Question = Who sets expert? 2]] End
Most appreciate what you can give me!
If you use agents instead of an agent, use agents Generally there is a good style in netlogo and is usually easier than alternate methods.
You can do your question with n-of
:
set Question n - Turtle 10
And then a turtle can check whether it is in question with the member?
:
If a member? Self Questions [Set Expert? 2]
Although you want all the tortoises that are part of the question to set up the expert
, then it is easy to do everything at once From:
Ask questions [set expert? 2]
Done! if
or member?
or no need for a loop.
Some other bit of advice:
-
In netlogo, it is only idiotic that to eliminate a variable with a question mark if it is correct or If there is a wrong value, then
set expert? 2
Why weirdly readset expert? True
? If you really need to use an integer, you should remove the question mark by the variable name. -
It's best to avoid using the number at all. Using which number in NetLogo almost always makes your code more difficult to write - hardly easy.
Comments
Post a Comment