检查海龟的x坐标和y坐标是否与补丁相同 [英] Check if turtles have same x-coordinate and y-coordinate as patches

查看:99
本文介绍了检查海龟的x坐标和y坐标是否与补丁相同的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个补丁集subtractset,其中一些补丁上有乌龟.

现在,我希望仅在具有与x-cory-cor不同的补丁程序上创建乌龟.

注意: 这与下面的代码不同:

  distribute-turtles (population * percent) subtractset with[count turtles-here = 0]

,因为这里可能有一只乌龟在贴片上,但贴片的x-cory-cor仍然不同.

谢谢. 如果我的问题有歧义,请让我.

解决方案

补丁具有整数坐标,因此一种方法是检查乌龟坐标是否为整数. 圆形xcor = xcor和圆形ycor = ycor

是真的,只要乌龟以补丁为中心

或者因为海龟可以访问补丁变量

 xcor = pxcor and ycor = pycor

哪个更令我满意,并且可能更快?

您可以将其放在一个过程中.

To-report centered 
    Report xcor = pxcor and ycor = pycor
End

I have a patchset subtractset and some of patches have turtles on it.

Now, I wish to create turtles on only those patches which have different x-cor and y-cor as the patches.

Note: This is different from below code:

  distribute-turtles (population * percent) subtractset with[count turtles-here = 0]

as here a turtle maybe on patch and still have different x-cor and y-cor as the patch.

Thanks. Please let me if there is some ambiguity in my question.

解决方案

Patches have integer coordinates so one way would be to check if the turtles coordinates are integers. round xcor = xcor and round ycor = ycor

Is true iff the turtle is centered on a patch

Or because turtles have access to patch variables

 xcor = pxcor and ycor = pycor

Which is more pleasing to my eye and probably faster.

You could put it in a procedure.

To-report centered 
    Report xcor = pxcor and ycor = pycor
End

这篇关于检查海龟的x坐标和y坐标是否与补丁相同的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆