2
我有一個搜索功能的海龜搜索'首選補丁'在自己面前的直線設置的距離。我使用循環創建了他們搜索的補丁數組。代碼經常卡在循環中(我想!)。我不知道爲什麼會發生這種情況......我想編碼告訴海龜通過補丁搜索一個首選補丁,如果不是在隨機補丁上着陸,有70%的機率着陸在其中一個補丁上搜索區域。如果在搜索區域中的任何補丁上都不存在首選補丁。netlogo烏龜搜索功能陷入循環Netlogo
海龜並不總是移動,所以我的代碼顯然是非常錯誤的。
let move-distance random 20
loop [set search-area (patch-set patch-ahead move-distance)
set move-distance move-distance - 1
if move-distance = 1 [stop]]
let preferred-patches search-area with [flight-tendency = 0.05]
ifelse any? preferred-patches [
ifelse random-float 1 < 0.7 [
set target one-of top-patches move-to target]
[set target one-of other-patch move-to target]]
[set target one-of other-patch move-to target]