且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何改善NetLogo中的跟踪功能?

更新时间:2023-02-18 11:55:46

我很确定您的问题在这里:

I'm pretty sure your problem is here:

member? Picking_Agent agents in-cone vision  100

这是一种确定一种药剂是否在另一种药剂的视锥中的极其缓慢的方法.为什么?因为它包含此子表达式:

This is an extraordinarily slow means of determining whether one agent is in another agent's vision cone. Why? Because it includes this subexpression:

agents in-cone vision 100

计算圆锥体中所有 all 代理的集合.这样做非常昂贵; in-cone进行大量的距离和角度计算.但是您不必知道锥中所有这些特工是谁!您已经有一个特工,您只需要知道一个单独的特工是否在圆锥体中即可.

which computes the set of all agents in the cone. Doing that is very expensive; in-cone does tons of distance and angle calculations. But you don't need to know who all of those agents in the cone are! You already have an agent, and you just need to know if that one single agent is in the cone or not.

您应该避免使用in-cone,并使用诸如distancetowards之类的原语直接计算是或否答案.我建议将计算结果放在一个单独的过程中,并在继续进行之前单独测试该过程,以确保您设置正确.它不需要非常多的代码,但所需的代码很难正确. (可能是该语言应该包括一个能做到这一点的原语,而不是让您自己编写它.)

You should avoid in-cone and compute your yes-or-no answer directly using such primitives as distance and towards. I'd suggest putting that computation in a separate procedure, and testing that procedure thoroughly in isolation to make sure you've got it right, before moving on. It doesn't take very much code, but the code it requires is tricky to get right. (Probably the language ought to include a primitive that does it, instead of making you write it yourself.)