我有一个问题,跟随最近的念珠菌(品种)由另一只龟 - 中性粒细胞(品种)。 Candidas不能移动,中性粒细胞寻找该地区最近的念珠菌,面对他并前进。当世界被允许包裹时,一切都很好。然后中性粒细胞通过“墙壁”并追逐念珠菌。 但重点是世界无法包装。 因此,我创建了condidion,帮助另一个模型,当它们达到最大坐标之一时反弹中性粒细胞。但是现在他们不断从墙上弹跳而不寻找另一个目标。
我将非常感谢您的帮助。
to lookfor ;;if meet candida in near area - chase, if not - continue looking for
ifelse any? candidas [ chase ] [ move ]
end
to chase ;;set the target on the nearest candida, face to them and move one step to him
set nearest-candidas min-one-of candidas [ distance myself ]
face nearest-candidas
bounce fd 1
end
to move
bounce
fd 2
end
to bounce
if abs pxcor = max-pxcor [ set heading (- heading) ] ;; bounce off top and bottom walls
if abs pycor = max-pycor [ set heading (180 - heading) ]
if abs pzcor = max-pzcor [ set heading (- heading) ]
set nearest-candidas max-one-of candidas [ distance myself ]
end
答案 0 :(得分:1)
编辑:哦,你在NetLogo 3D中。不幸的是,这改变了一切。如果不能阻止世界进行包装,就没有 easy 这样做的方法。如果你喜欢冒险,你可以尝试找到一种方法,通过与世界上其他海龟的三角测量,确保最近的海龟在“墙的右侧”。虽然这并不容易,但我可以看到它正在发挥作用。祝你好运。
过时的回复:
我认为问题可能出在你的def scoreBoard(text):
text = text.upper()
frequencies = {}
for letter in text:
if letter in frequencies:
frequencies[letter] += 1.
else:
frequencies[letter] = 1.
total = sum(frequencies.values())
for letter in frequencies.keys():
frequencies[letter] /= total
score = 0.0
for l in freqs.keys():
if l not in frequencies:
frequencies[l] = 0.0
score += math.sqrt(frequencies[l] * freqs[l])
return score
程序中,你有
bounce
使用set nearest-candidas max-one-of candidas [ distance myself ]
将候选人设置为离中性粒细胞最远的一个人。您可以在max-one-of
过程中正确地将其设置为chase
( min 之一,而不是 max 之一)。更改是否会为您提供您期望的行为?