1

I am trying to make an agentset do something, if an agent(of a different agentset) has a particular shape.

Here, if the shape of a particular

  • ghost (say Ghost 1) is circle,

  • then all rabbits are supposed to move forward 1. (<-This is the intended behavior)

where

  • ghosts are agentset A
  • rabbits are agentset B

I have tried along these lines:

ask rabbits
[
 if (shape ghost 1 = "circle")
  [
   forward 1
  ]
]

For this code I get,

"Expected a closing paranthesis here."

with a highlighter on ghost. I'm aware that this code is wrong but I can't think of how else this should be written to get the desired result.

Adam
  • 2,726
  • 1
  • 9
  • 22

1 Answers1

2

This will (I think - can't test) get the syntax correct:

ask rabbits
[
 if ([shape] of ghost 1 = "circle")
  [
   forward 1
  ]
]

but you also have an ordering error and will have every rabbit check the shape of chost 1. I think what you really want is:

if ([shape] of ghost 1 = "circle")
[ ask rabbits
  [ forward 1
  ]
]
JenB
  • 17,620
  • 2
  • 17
  • 45
  • 1
    Perfect! It does the required job. I have "ask rabbits" placed in the beginning as there are many more commands running that lead to this if statement. I tried to ask the question in the most simplified way as I can to avoid irrelevant complexicity. – Akshansh Vaid May 27 '19 at 15:19