解决一个难题&继续下一个

时间:2017-03-21 06:47:10

标签: netlogo puzzle

此代码直接来自Move Towards Target Example中的NetLogo Models Library,但我无法让我的代理人解决难题并继续前进。

谜题是补丁(而不是Move Towards Target Example中的海龟),难度级别在1到5之间,并且代理人具有基于代理属性和谜题难度解决谜题的个体概率。我希望补丁从黄色变为黑色,以说明它何时解决。

这个错误可能源于乌龟和补丁上下文之间的混淆,但如果是这样,我无法纠正它。提前感谢您提供的任何帮助。

set target-puzzle min-one-of patches with [ pcolor = yellow ] [ distance myself ]  
face target-puzzle  

    to go 
    if not any? patches with [pcolor = yellow] [
        stop
      ]

    ask people [
          if distance target-puzzle = 0
          [ solve-puzzle
            set target-puzzle min-one-of patches with [ pcolor = yellow ] [ distance myself ]
            face target-puzzle ]
        ;; Once the distance is less than 1, use 'move-to' to land exactly on the target.
          ifelse distance target-puzzle < 1
          [ move-to target-puzzle ]
          [ fd 1 ]
       ]

    tick

    end

    to solve-puzzle
          ask patch-here [  
            set progress [psolve] of myself
            set difficulty difficulty - progress  
          if difficulty <= 0
           [ set pcolor black ]
        ]
    end 

0 个答案:

没有答案