How to prevent agents' ability to 'jump' barriers in NetLogo?

萝らか妹 提交于 2019-12-13 03:52:40

问题


I'm asking this question in reference to a previous question answered here: Is there a way to create impassable barriers in NetLogo?

A user helpfully suggested a way to generate off-limits patches (i.e. barriers) in NetLogo. However, as he mentioned, agents will still possess the ability to occasionally 'jump' over these barriers if they approach from particular angles. This is an undesirable behavior for my model, as I'm modeling fences and movement, so jumping barriers is unrealistic.

I have attempted to alter this code:

ask patches in-radius 1
[if f = 1
[ask myself

  [set heading towards min-one-of patches [distance myself] + 180 - random 10 + random 10 ]

]
]

by decreasing the "in-radius" to less than one, in hopes that it would prevent the agent from seeing far enough to move across barriers, but this does not work. The "f = 1" is just a patch variable used to denote which patches are fences.

Is there any method of preventing this behavior?

Here is the behavior I want - navigation around barriers

Here is the behavior I don't want - jumping barriers if approached from certain angles

The actual movement procedure that agents are following is as follows:

ask turtles[
let moveset patches in-radius 30 with [f = 0 and n > 0]

 pen-down

 let target max-one-of moveset [n]

 ifelse patch-here != target
 [set heading towards target]
 []

 ask patches in-radius 1
 [if f = 1
 [ask myself
  [set heading towards min-one-of patches [distance myself] + 180 - random 10 + random 10]

 fd 1]

来源:https://stackoverflow.com/questions/55835397/how-to-prevent-agents-ability-to-jump-barriers-in-netlogo

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!