Aseel hussein
Aseel hussein

Reputation: 1

How can i apply a specific equation to all turtles?

when i applied an equation to all turtles (the nodes is taken from a database), the first value is calculated only and it is repeated over the rest? There are different values for each node(a,b,c,d) is there another way instead of ask turtles ?? i do not know what the wrong ?

  ask turtles [ set total  (a+b)*w +(d+c)* w1 / 4] 

This is code execution (turtle 14): 0.0018243243243243246 (turtle 21): 0.0018243243243243246 (turtle 35): 0.0018243243243243246 (turtle 19): 0.0018243243243243246 (turtle 24): 0.0018243243243243246 (turtle 39): 0.0018243243243243246 (turtle 15): 0.0018243243243243246 (turtle 54): 0.0018243243243243246 (turtle 40): 0.0018243243243243246 (turtle 47): 0.0018243243243243246 (turtle 36): 0.0018243243243243246 (turtle 60): 0.0018243243243243246 (turtle 41): 0.0018243243243243246 (turtle 20): 0.0018243243243243246 (turtle 31): 0.0018243243243243246

Upvotes: 0

Views: 60

Answers (2)

Ktass99
Ktass99

Reputation: 73

As someone has already stated there doesn't seem to be enough information provided. From what I can see you may want to create a turtles own variable. This gives each turtle its own variable to hold. For example if you give turtles a health variable of 100 each turtle can individually change their health value independently. I'm not sure if this what you are looking for though

Upvotes: 0

JenB
JenB

Reputation: 17678

There is nowhere near enough information to answer your question since you haven't provided the values of any of the variables. As I suggested on your previous (now deleted) question, you need to check that the variables going into the equation are what you think they are. For example:

ask turtles
[ type "a is " print a
  type "b is " print b
  type "c is " print c
  type "d is " print d
  type "w is " print w
  type "w1 is " print w1
  set total  (a+b)*w +(d+c)* w1 / 4
  print total
] 

Upvotes: 2

Related Questions