Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/variables/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Performance netlogo,如果设置变量,则滴答声较慢_Performance_Variables_Netlogo - Fatal编程技术网

Performance netlogo,如果设置变量,则滴答声较慢

Performance netlogo,如果设置变量,则滴答声较慢,performance,variables,netlogo,Performance,Variables,Netlogo,正常滴答声速度: ask turtles with [seated? = 0] [ fd speed if (pxcor > -5 and pxcor < 10) and (pycor > 5 and pycor < 10) [facexy (87 + random 4) (6 + random 4) fd speed] if (pxcor > 25 and pxcor < 28) and (pycor >

正常滴答声速度:

ask turtles with [seated? = 0] [
        fd speed
        if (pxcor > -5 and pxcor < 10) and (pycor > 5 and pycor < 10) [facexy (87 + random 4) (6 + random 4) fd speed]
        if (pxcor > 25 and pxcor < 28) and (pycor > 5 and pycor < 12) [
          let choice random 2
          fd speed
          if choice = 0 [leftbench]
          if choice = 1 [facexy 75 (6 + random 5)]
        ]
        if (pxcor > 73 and pxcor < 79) and (pycor > 5 and pycor < 15) [rightbench fd speed]
        if pcolor = brown and not any? other turtles-here
        [ move-to patch-here
          set seated? true
          set pcolor orange
          ]
      ]
ask turtles with [seated? = 0] [
        let gate patches with [(pxcor >= 88 and pxcor  <= 90) and (pycor >= 5)] 
        fd speed
        if (pxcor > -5 and pxcor < 10) and (pycor > 5 and pycor < 10) [face one-of gate fd speed]
        if (pxcor > 25 and pxcor < 28) and (pycor > 5 and pycor < 12) [
          let choice random 2
          fd speed
          if choice = 0 [leftbench]
          if choice = 1 [facexy 75 (6 + random 5)]
        ]
        if (pxcor > 73 and pxcor < 79) and (pycor > 5 and pycor < 15) [rightbench fd speed]
        if pcolor = brown and not any? other turtles-here
        [ move-to patch-here
          set seated? true
          set pcolor orange
          ]
      ]
向海龟询问[坐姿?=0][
fd速度
如果(pxcor>-5和pxcor<10)和(pycor>5和pycor<10)[facexy(87+随机4)(6+随机4)fd速度]
如果(pxcor>25和pxcor<28)和(pycor>5和pycor<12)[
让选择随机2
fd速度
如果选项=0[左板凳]
如果选择=1[facexy 75(6+随机5)]
]
如果(pxcor>73和pxcor<79)和(pycor>5和pycor<15)[右试验台fd速度]
如果pcolor=棕色,而不是任何其他海龟
[移动到此处修补
坐好了吗
设置颜色为橙色
]
]
慢滴答声速度:

ask turtles with [seated? = 0] [
        fd speed
        if (pxcor > -5 and pxcor < 10) and (pycor > 5 and pycor < 10) [facexy (87 + random 4) (6 + random 4) fd speed]
        if (pxcor > 25 and pxcor < 28) and (pycor > 5 and pycor < 12) [
          let choice random 2
          fd speed
          if choice = 0 [leftbench]
          if choice = 1 [facexy 75 (6 + random 5)]
        ]
        if (pxcor > 73 and pxcor < 79) and (pycor > 5 and pycor < 15) [rightbench fd speed]
        if pcolor = brown and not any? other turtles-here
        [ move-to patch-here
          set seated? true
          set pcolor orange
          ]
      ]
ask turtles with [seated? = 0] [
        let gate patches with [(pxcor >= 88 and pxcor  <= 90) and (pycor >= 5)] 
        fd speed
        if (pxcor > -5 and pxcor < 10) and (pycor > 5 and pycor < 10) [face one-of gate fd speed]
        if (pxcor > 25 and pxcor < 28) and (pycor > 5 and pycor < 12) [
          let choice random 2
          fd speed
          if choice = 0 [leftbench]
          if choice = 1 [facexy 75 (6 + random 5)]
        ]
        if (pxcor > 73 and pxcor < 79) and (pycor > 5 and pycor < 15) [rightbench fd speed]
        if pcolor = brown and not any? other turtles-here
        [ move-to patch-here
          set seated? true
          set pcolor orange
          ]
      ]
向海龟询问[坐姿?=0][
用[(pxcor>=88和pxcor=5)]设置栅极贴片
fd速度
如果(pxcor>-5和pxcor<10)和(pycor>5和pycor<10)[面对门fd速度之一]
如果(pxcor>25和pxcor<28)和(pycor>5和pycor<12)[
让选择随机2
fd速度
如果选项=0[左板凳]
如果选择=1[facexy 75(6+随机5)]
]
如果(pxcor>73和pxcor<79)和(pycor>5和pycor<15)[右试验台fd速度]
如果pcolor=棕色,而不是任何其他海龟
[移动到此处修补
坐好了吗
设置颜色为橙色
]
]

问题是,每次我设置一个变量时,我都想让速度正常,这样编码就更容易、更有条理了。。请提供帮助

如果有一段代码要使用两次,请将其放入过程中

然后,每当你需要那块代码时,你不必使用复制粘贴来重复它;你只需要调用程序

如果该过程需要能够表现出稍微不同的行为,这取决于它的使用位置,那么您可以让该过程获取输入,然后让它检查这些输入以决定要做什么


我希望这有帮助?我不完全确定我是否在回答你的问题,但如果我没有回答,也许你可以澄清一下你想做什么。

感谢赛斯的这篇文章,它确实帮助了我:)不过我现在才回答