turtles-own [ t-culture-tags ]
to setup
ca
reset-ticks
crt 10 [
set t-culture-tags n-values 11 [ random 2 ]
setxy random-xcor random-ycor
set color sum t-culture-tags + 50
]
end
該設置創建了10個海龜,使用t-culture-tags
,如上例所示。現在,既然你說改變只發生在代理烏龜和它的朋友之間的標籤不同的情況下,那麼總是傳播烏龜的文化可能是最簡單的(因爲實際上,這不會導致烏龜的t-culture-tags
變化朋友)。
因此,您可以從0到10中選取一個隨機數並將其用作索引,然後讓請求的龜在該索引位置將其標記擴展到所有您想要的「朋友」。在下面的例子中,每個刻度一個隨機海龜傳播其文化,所有其他龜類的5半徑範圍內:
to spread-culture
ask one-of turtles [
let tag-index random 11
let my-tag-at-index item tag-index t-culture-tags
if any? other turtles in-radius 10 [
ask other turtles in-radius 10 [
set t-culture-tags replace-item tag-index t-culture-tags my-tag-at-index
set color sum t-culture-tags + 50
]
]
]
tick
end
如果運行了一段時間,你會看到,是半徑內的所有海龜另一個將最終具有相同的t文化標籤,在這個例子中由它們的顏色表示。