Akari Tsukada
Akari Tsukada

Reputation: 27

Netlogo: [ifelse] command / expected command

I'm a beginner of netlogo. Below the code, It seems like there is error in brackets, but i have not found my mistake... thank you for your help.

to exit
ask turtles [[
[ifelse patch-here = goal ; option A
[ifelse pcolor = gray ; option B (option A1)
[ifelse income = 0 ;option C (option B1)
  [die] ;option C1
  [ifelse count products >= 3 ;option B2
    [die][set turtles continue]]] ;option C2 
[set turtles continue]
] ; option B2
  [set turtles continue]]
 ; option A2
]]end

Upvotes: 0

Views: 681

Answers (1)

JenB
JenB

Reputation: 17678

When you can't work out a bracketing error, proper indenting is your friend. Here is your code:

to exit
ask turtles
[
  [
    [ ifelse patch-here = goal ; option A
      [ ifelse pcolor = gray ; option B (option A1)
        [ ifelse income = 0 ;option C (option B1)
          [die] ;option C1
          [ ifelse count products >= 3 ;option B2
            [die]
            [set turtles continue]
          ]
        ] ;option C2 
        [ set turtles continue
        ]
      ] ; option B2
     [ set turtles continue
     ]
   ]
 ; option A2

But your problem is that you start with ask turtles [ [ [ - three opening brackets where there should be one.

Upvotes: 1

Related Questions