Netlogo:[ifelse]命令/预期命令

时间:2018-12-08 14:06:22

标签: netlogo

我是netlogo的初学者。在代码下面,似乎在括号中有错误,但是我没有发现我的错误... 谢谢您的帮助。

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

1 个答案:

答案 0 :(得分:1)

当您无法计算出包围曝光错误时,适当缩进是您的朋友。这是您的代码:

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

但是您的问题是,您从ask turtles [ [ [开始-三个括号应在其中。