这是我尝试运行的模拟,但我似乎有等待时间(滴答)的问题。
我不能让我的海龟(购物者)等待适量的蜱虫,而且我发现海龟的数量会直接影响等待时间的数量。
等待时间是一个属性,告诉购物者在开始走向下一个目的地之前保持不变。
extensions[gis]
breed [shopper shoppers]
breed [places place]
breed [cityts cityt]
shopper-own [person x y cid route shopper_type destination last-destination waiting_time step starting_point cityx cityy]
turtles-own [std wflag ]
places-own [shopper_type ycoor xcoor locality ]
cityts-own[shopper_type org xc yc]
patches-own[netlogo]
globals [ speed last_place]
to setup
setup_world
setup_color
ask cityts [set hidden? true]
reset-ticks
end
to go
ask shopper with [shopper_type != "rtqq"] [walk-towards]
; ask shopper with [shopper_type = "lvl2" and shopper_type ="lvl2" ] [omw]
if ticks >= 1440 [stop]
tick
end
to loc
ask cityts [
output-show ticks
output-show xcor
output-show ycor
output-show label
output-show who
]
end
to output-locations
output-show self
output-show xcor
output-show ycor
end
to walk-towards
ask shopper [
if shopper_type != "aaa" [
rep
ifelse waiting_time > 0 [
set waiting_time waiting_time - 1
set step step + 1]
[omw]] ]
end
to omw
if destination = false [fd 1]
ifelse distance destination > 0.1
[face destination
forward speed]
[move-to destination
next_place
set step 0]
end
to set_destination [NUM]
set destination min-one-of (turtles with [label = NUM] in-radius (360) )[distance myself]
end
to wt [NUM]
set waiting_time NUM + random 10 - random 10
set waiting_time waiting_time - 1
end
to setup_world
create-places 3
[
setxy random-xcor random-ycor
set label 345
]
create-places 3
[
setxy random-xcor random-ycor
set label 789
]
create-places 3
[
setxy random-xcor random-ycor
set label 3344
]
create-places 3
[
setxy random-xcor random-ycor
set label 3232
]
create-places 3
[
setxy random-xcor random-ycor
set label 1937
]
create-places 3
[
setxy random-xcor random-ycor
set label 951
]
create-places 3
[
setxy random-xcor random-ycor
set label 987
]
create-places 3
[
setxy random-xcor random-ycor
set label 234
]
create-places 3
[
setxy random-xcor random-ycor
set label 912
]
create-places 3
[
setxy random-xcor random-ycor
set label 567
]
create-places 3
[
setxy random-xcor random-ycor
set label 8529
]
create-places 3
[
setxy random-xcor random-ycor
set label 891
]
create-places 3
[
setxy random-xcor random-ycor
set label 1927
]
create-places 3
[
setxy random-xcor random-ycor
set label 1826
]
create-places 3
[
setxy random-xcor random-ycor
set label 1725
]
create-places 3
[
setxy random-xcor random-ycor
set label 456
]
create-places 3
[
setxy random-xcor random-ycor
set label 1013
]
create-places 3
[
setxy random-xcor random-ycor
set label 7891
]
create-places 3
[
setxy random-xcor random-ycor
set label 3322
]
create-places 3
[
setxy random-xcor random-ycor
set label 678
]
create-shopper 3 [
set size 1
set waiting_time 0
set shopper_type "lvl1"
set cid 1
set shape "person"
set starting_point one-of (turtles with [label = 1725])
; set xcor random-float 25
; set ycor random-float 25
; set ctiyx xcor of starting_point
; set cityy ycor of starting_point
set speed 0.1
set route random 6 ]
ask shopper [
set destination min-one-of (turtles with [label = 789 ] in-radius (360) )[distance myself]
set last-destination "boop" ]
; create-shopper 2 [
; set size 1
; set waiting_time 0
; set shopper_type "lvl2"
; set cid 7
; set shape "person"
; set xcor random-float 25
; set ycor random-float 25
; set speed 0.1
; set route random 5 ]
; ask shopper [
; set destination min-one-of (turtles with [label = 789 ] in-radius (360) )[distance myself]
; set last-destination "boop" ]
;
;
; create-ambolansces 1 [
; set size 1
; set waiting_time 0
; set shopper_type "lvl3"
; set shape "car"
; set xcor random-float 25
; set ycor random-float 25
; set speed 0.1
; set route random 3 ]
; ask shopper [
; set destination min-one-of (turtles with [label = 789 ] in-radius (360) )[distance myself]
; set last-destination "boop"]
end
to next_place
if shopper_type = "lvl1"[
if route = 0 [
ifelse last-destination ="boop" [set destination min-one-of (turtles with [label = 345] in-radius (360) )[distance myself] wt 40 walk-towards rep set last-destination "345" ]
[ ifelse last-destination = "345" [set destination min-one-of (turtles with [label = 789] in-radius (360) )[distance myself] wt 70 walk-towards rep set last-destination "789" ]
[ ifelse last-destination = "789" [set destination min-one-of (turtles with [label = 3344] in-radius (360) )[distance myself] wt 20 walk-towards rep set last-destination "3344" ]
[ ifelse last-destination = "3344" [set destination min-one-of (turtles with [label = 3232] in-radius (360) )[distance myself] wt 10 walk-towards set last-destination "3232" ]
[ifelse last-destination = "3232" [set destination min-one-of (turtles with [label = 1937] in-radius (360) )[distance myself] wt 30 walk-towards rep set last-destination "1937" ]
[if last-destination = "1937" [set destination min-one-of (turtles with [label = 951] in-radius (360) )[distance myself] wt 80 walk-towards rep set last-destination "boop" set route random 6 ]]]]]]]]
if shopper_type = "lvl1"[
if route = 1 [
ifelse last-destination ="boop" [set destination min-one-of (turtles with [label = 789] in-radius (360) )[distance myself] wt 100 walk-towards rep set last-destination "789" ]
[ ifelse last-destination = "789" [set destination min-one-of (turtles with [label = 987] in-radius (360) )[distance myself] wt 10 walk-towards rep set last-destination "987" ]
[ ifelse last-destination = "987" [set destination min-one-of (turtles with [label = 345] in-radius (360) )[distance myself] wt 50 walk-towards rep set last-destination "345"]
[ ifelse last-destination = "345" [set destination min-one-of (turtles with [label = 234] in-radius (360) )[distance myself] wt 5 walk-towards rep set last-destination "234"]
[ifelse last-destination = "234" [set destination min-one-of (turtles with [label = 789] in-radius (360) )[distance myself] wt 60 walk-towards rep set last-destination "7891" ]
[if last-destination = "7891" [set destination min-one-of (turtles with [label = 951] in-radius (360) )[distance myself] wt 40 walk-towards rep set last-destination "boop" set route random 6 ]]]]]]]]
if shopper_type = "lvl1"[
if route = 2 [
ifelse last-destination ="boop" [set destination min-one-of (turtles with [label = 912] in-radius (360) )[distance myself] wt 60 walk-towards rep set last-destination "912" ]
[ ifelse last-destination = "912" [set destination min-one-of (turtles with [label = 567] in-radius (360) )[distance myself] wt 50 walk-towards set last-destination "567" ]
[ ifelse last-destination = "567" [set destination min-one-of (turtles with [label = 345] in-radius (360) )[distance myself] wt 30 walk-towards rep set last-destination "345"]
[ ifelse last-destination = "345" [set destination min-one-of (turtles with [label = 987] in-radius (360) )[distance myself] wt 50 walk-towards rep set last-destination "987"]
[ifelse last-destination = "987" [set destination min-one-of (turtles with [label = 789] in-radius (360) )[distance myself] wt 70 walk-towards rep set last-destination "7891" ]
[if last-destination = "7891" [set destination min-one-of (turtles with [label = 8529] in-radius (360) )[distance myself] wt 50 walk-towards rep set last-destination "boop" set route random 6 ]]]]]]]]
if shopper_type = "lvl1"[
if route = 3 [
ifelse last-destination ="boop" [set destination min-one-of (turtles with [label = 987] in-radius (360) )[distance myself] wt 40 walk-towards rep set last-destination "987" ]
[ ifelse last-destination = "987" [set destination min-one-of (turtles with [label = 789] in-radius (360) )[distance myself] wt 70 walk-towards rep set last-destination "789" ]
[ ifelse last-destination = "789" [set destination min-one-of (turtles with [label = 567] in-radius (360) )[distance myself] wt 20 walk-towards set last-destination "678" ]
[ ifelse last-destination = "678" [set destination min-one-of (turtles with [label = 891] in-radius (360) )[distance myself] wt 10 walk-towards set last-destination "891" ]
[ifelse last-destination = "891" [set destination min-one-of (turtles with [label = 1927] in-radius (360) )[distance myself] wt 30 walk-towards rep set last-destination "1927" ]
[if last-destination = "1927" [set destination min-one-of (turtles with [label = 8529] in-radius (360) )[distance myself] wt 80 walk-towards rep set last-destination "boop" set route random 6 ]]]]]]]]
if shopper_type = "lvl1"[
if route = 4 [
ifelse last-destination ="boop" [set destination min-one-of (turtles with [label = 1937] in-radius (360) )[distance myself] wt 100 walk-towards rep set last-destination "1937" ]
[ ifelse last-destination = "1937" [set destination min-one-of (turtles with [label = 1826] in-radius (360) )[distance myself] wt 10 walk-towards rep set last-destination "1826" ]
[ ifelse last-destination = "1826" [set destination min-one-of (turtles with [label = 1725] in-radius (360) )[distance myself] wt 50 walk-towards rep set last-destination "1725"]
[ ifelse last-destination = "1725" [set destination min-one-of (turtles with [label = 345] in-radius (360) )[distance myself] wt 5 walk-towards rep set last-destination "345"]
[ifelse last-destination = "345" [set destination min-one-of (turtles with [label = 789] in-radius (360) )[distance myself] wt 60 walk-towards rep set last-destination "7891" ]
[if last-destination = "7891" [set destination min-one-of (turtles with [label = 3322] in-radius (360) )[distance myself] wt 40 walk-towards rep set last-destination "boop" set route random 6 ]]]]]]]]
if shopper_type = "lvl1"[
if route = 5 [
ifelse last-destination ="boop" [set destination min-one-of (turtles with [label = 912] in-radius (360) )[distance myself] wt 60 walk-towards rep set last-destination "912" ]
[ ifelse last-destination = "912" [set destination min-one-of (turtles with [label = 456] in-radius (360) )[distance myself] wt 50 walk-towards rep set last-destination "456" ]
[ ifelse last-destination = "456" [set destination min-one-of (turtles with [label = 345] in-radius (360) )[distance myself] wt 30 walk-towards rep set last-destination "345"]
[ ifelse last-destination = "345" [set destination min-one-of (turtles with [label = 987] in-radius (360) )[distance myself] wt 50 walk-towards rep set last-destination "987"]
[ifelse last-destination = "987" [set destination min-one-of (turtles with [label = 789] in-radius (360) )[distance myself] wt 70 walk-towards rep set last-destination "7891" ]
[if last-destination = "7891" [set destination min-one-of (turtles with [label = 8529] in-radius (360) )[distance myself] wt 50 walk-towards rep set last-destination "boop" set route random 6 ]]]]]]]]
if shopper_type = "lvl2"[
if route = 0 [
ifelse last-destination ="boop" [set destination min-one-of (turtles with [label = 345] in-radius (360) )[distance myself] wt 40 walk-towards rep set last-destination "345" ]
[ ifelse last-destination = "345" [set destination min-one-of (turtles with [label = 789] in-radius (360) )[distance myself] wt 70 walk-towards rep set last-destination "789" ]
[ ifelse last-destination = "789" [set destination min-one-of (turtles with [label = 3344] in-radius (360) )[distance myself] wt 20 walk-towards rep set last-destination "3344" ]
[ ifelse last-destination = "3344" [set destination min-one-of (turtles with [label = 3232] in-radius (360) )[distance myself] wt 10 walk-towards set last-destination "3232" ]
[ifelse last-destination = "3232" [set destination min-one-of (turtles with [label = 1937] in-radius (360) )[distance myself] wt 30 walk-towards rep set last-destination "1937" ]
[if last-destination = "1937" [set destination min-one-of (turtles with [label = 951] in-radius (360) )[distance myself] wt 80 walk-towards rep set last-destination "boop" set route random 6 ]]]]]]]]
if shopper_type = "lvl2"[
if route = 1 [
ifelse last-destination ="boop" [set destination min-one-of (turtles with [label = 789] in-radius (360) )[distance myself] wt 100 walk-towards rep set last-destination "789" ]
[ ifelse last-destination = "789" [set destination min-one-of (turtles with [label = 987] in-radius (360) )[distance myself] wt 10 walk-towards rep set last-destination "987" ]
[ ifelse last-destination = "987" [set destination min-one-of (turtles with [label = 345] in-radius (360) )[distance myself] wt 50 walk-towards rep set last-destination "345"]
[ ifelse last-destination = "345" [set destination min-one-of (turtles with [label = 234] in-radius (360) )[distance myself] wt 5 walk-towards rep set last-destination "234"]
[ifelse last-destination = "234" [set destination min-one-of (turtles with [label = 789] in-radius (360) )[distance myself] wt 60 walk-towards rep set last-destination "7891" ]
[if last-destination = "7891" [set destination min-one-of (turtles with [label = 951] in-radius (360) )[distance myself] wt 40 walk-towards rep set last-destination "boop" set route random 6 ]]]]]]]]
if shopper_type = "lvl2"[
if route = 2 [
ifelse last-destination ="boop" [set destination min-one-of (turtles with [label = 912] in-radius (360) )[distance myself] wt 60 walk-towards rep set last-destination "912" ]
[ ifelse last-destination = "912" [set destination min-one-of (turtles with [label = 567] in-radius (360) )[distance myself] wt 50 walk-towards set last-destination "567" ]
[ ifelse last-destination = "567" [set destination min-one-of (turtles with [label = 345] in-radius (360) )[distance myself] wt 30 walk-towards rep set last-destination "345"]
[ ifelse last-destination = "345" [set destination min-one-of (turtles with [label = 987] in-radius (360) )[distance myself] wt 50 walk-towards rep set last-destination "987"]
[ifelse last-destination = "987" [set destination min-one-of (turtles with [label = 789] in-radius (360) )[distance myself] wt 70 walk-towards rep set last-destination "7891" ]
[if last-destination = "7891" [set destination min-one-of (turtles with [label = 8529] in-radius (360) )[distance myself] wt 50 walk-towards rep set last-destination "boop" set route random 6 ]]]]]]]]
if shopper_type = "lvl2"[
if route = 3 [
ifelse last-destination ="boop" [set destination min-one-of (turtles with [label = 987] in-radius (360) )[distance myself] wt 40 walk-towards rep set last-destination "987" ]
[ ifelse last-destination = "987" [set destination min-one-of (turtles with [label = 789] in-radius (360) )[distance myself] wt 70 walk-towards rep set last-destination "789" ]
[ ifelse last-destination = "789" [set destination min-one-of (turtles with [label = 678] in-radius (360) )[distance myself] wt 10 walk-towards set last-destination "678" ]
[ ifelse last-destination = "678" [set destination min-one-of (turtles with [label = 891] in-radius (360) )[distance myself] wt 10 walk-towards set last-destination "891" ]
[ifelse last-destination = "891" [set destination min-one-of (turtles with [label = 1927] in-radius (360) )[distance myself] wt 30 walk-towards rep set last-destination "1927" ]
[if last-destination = "1927" [set destination min-one-of (turtles with [label = 8529] in-radius (360) )[distance myself] wt 80 walk-towards rep set last-destination "boop" set route random 6 ]]]]]]]]
if shopper_type = "lvl2"[
if route = 4 [
ifelse last-destination ="boop" [set destination min-one-of (turtles with [label = 1937] in-radius (360) )[distance myself] wt 100 walk-towards rep set last-destination "1937" ]
[ ifelse last-destination = "1937" [set destination min-one-of (turtles with [label = 1826] in-radius (360) )[distance myself] wt 10 walk-towards rep set last-destination "1826" ]
[ ifelse last-destination = "1826" [set destination min-one-of (turtles with [label = 1725] in-radius (360) )[distance myself] wt 50 walk-towards rep set last-destination "1725"]
[ ifelse last-destination = "1725" [set destination min-one-of (turtles with [label = 345] in-radius (360) )[distance myself] wt 5 walk-towards rep set last-destination "345"]
[ifelse last-destination = "345" [set destination min-one-of (turtles with [label = 789] in-radius (360) )[distance myself] wt 60 walk-towards rep set last-destination "7891" ]
[if last-destination = "7891" [set destination min-one-of (turtles with [label = 3322] in-radius (360) )[distance myself] wt 40 walk-towards rep set last-destination "boop" set route random 6 ]]]]]]]]
if shopper_type = "lvl2"[
if route = 5 [
ifelse last-destination ="boop" [set destination min-one-of (turtles with [label = 912] in-radius (360) )[distance myself] wt 60 walk-towards rep set last-destination "912" ]
[ ifelse last-destination = "912" [set destination min-one-of (turtles with [label = 456] in-radius (360) )[distance myself] wt 50 walk-towards rep set last-destination "456" ]
[ ifelse last-destination = "456" [set destination min-one-of (turtles with [label = 345] in-radius (360) )[distance myself] wt 30 walk-towards rep set last-destination "345"]
[ ifelse last-destination = "345" [set destination min-one-of (turtles with [label = 987] in-radius (360) )[distance myself] wt 50 walk-towards rep set last-destination "987"]
[ifelse last-destination = "987" [set destination min-one-of (turtles with [label = 789] in-radius (360) )[distance myself] wt 70 walk-towards rep set last-destination "7891" ]
[if last-destination = "7891" [set destination min-one-of (turtles with [label = 8529] in-radius (360) )[distance myself] wt 50 walk-towards rep set last-destination "boop" set route random 6 ]]]]]]]]
if shopper_type = "lvl3"[
if route = 0 [
ifelse last-destination ="boop" [set destination min-one-of (turtles with [label = 987] in-radius (360) )[distance myself] wt 20 walk-towards rep set last-destination "987"]
[ ifelse last-destination = "987" [set destination min-one-of (turtles with [label = 789] in-radius (360) )[distance myself] wt 20 walk-towards rep set last-destination "789" ]
[ ifelse last-destination = "789"[set destination min-one-of (turtles with [label = 456] in-radius (360) )[distance myself] wt 20 walk-towards rep set last-destination "456" ]
[ ifelse last-destination = "456" [set destination min-one-of (turtles with [label = 912] in-radius (360) )[distance myself] wt 20 walk-towards rep set last-destination "912"rep ]
[ifelse last-destination = "912" [set destination min-one-of (turtles with [label = 1013] in-radius (360) )[distance myself] wt 20 walk-towards rep set last-destination "1013"rep ]
[if last-destination = "1013" [set destination min-one-of (turtles with [label = 789] in-radius (360) )[distance myself] wt 20 walk-towards rep set last-destination "boop" set route random 3 rep ]]]]]]]]
if shopper_type = "lvl3"[
if route = 1 [
ifelse last-destination ="boop" [set destination min-one-of (turtles with [label = 789] in-radius (360) )[distance myself] wt 20 walk-towards rep set last-destination "789" ]
[ ifelse last-destination = "789" [set destination min-one-of (turtles with [label = 456] in-radius (360) )[distance myself] wt 20 walk-towards rep set last-destination "456" ]
[ ifelse last-destination = "456" [set destination min-one-of (turtles with [label = 234] in-radius (360) )[distance myself] wt 20 walk-towards rep set last-destination "234"]
[ ifelse last-destination = "234" [set destination min-one-of (turtles with [label = 987] in-radius (360) )[distance myself] wt 20 walk-towards rep set last-destination "987"]
[ifelse last-destination = "987" [set destination min-one-of (turtles with [label = 789] in-radius (360) )[distance myself] wt 20 walk-towards rep set last-destination "7891" ]
[if last-destination = "7891" [set destination min-one-of (turtles with [label = 891] in-radius (360) )[distance myself] wt 20 walk-towards rep set last-destination "boop" set route random 3 ]]]]]]]]
if shopper_type = "lvl3"[
if route = 2 [
ifelse last-destination ="boop" [set destination min-one-of (turtles with [label = 789] in-radius (360) )[distance myself] wt 20 walk-towards rep set last-destination "789" ]
[ ifelse last-destination = "789" [set destination min-one-of (turtles with [label = 456] in-radius (360) )[distance myself] wt 20 walk-towards rep set last-destination "456" ]
[ ifelse last-destination = "456" [set destination min-one-of (turtles with [label = 234] in-radius (360) )[distance myself] wt 20 walk-towards rep set last-destination "234"]
[ ifelse last-destination = "234" [set destination min-one-of (turtles with [label = 987] in-radius (360) )[distance myself] wt 20 walk-towards rep set last-destination "987"]
[ifelse last-destination = "987" [set destination min-one-of (turtles with [label = 789] in-radius (360) )[distance myself] wt 20 walk-towards rep set last-destination "7891" ]
[if last-destination = "7891" [set destination min-one-of (turtles with [label = 891] in-radius (360) )[distance myself] wt 20 walk-towards rep set last-destination "boop" set route random 3 ]]]]]]]]
if shopper_type = "lvl4"[
if route = 0 [
ifelse last-destination ="boop" [set destination min-one-of (turtles with [label = 987] in-radius (360) )[distance myself] wt 20 walk-towards set last-destination "987"]
[ ifelse last-destination = "987" [set destination min-one-of (turtles with [label = 789] in-radius (360) )[distance myself] wt 20 walk-towards set last-destination "789" ]
[ ifelse last-destination = "789"[set destination min-one-of (turtles with [label = 456] in-radius (360) )[distance myself] wt 20 walk-towards set last-destination "456" ]
[ ifelse last-destination = "456" [set destination min-one-of (turtles with [label = 912] in-radius (360) )[distance myself] wt 20 walk-towards set last-destination "912" ]
[ifelse last-destination = "912" [set destination min-one-of (turtles with [label = 1013] in-radius (360) )[distance myself] wt 20 walk-towards set last-destination "1013" ]
[if last-destination = "1013" [set destination min-one-of (turtles with [label = 789] in-radius (360) )[distance myself] wt 20 walk-towards set last-destination "boop" set route random 3 ]]]]]]]]
if shopper_type = "lvl4"[
if route = 1 [
ifelse last-destination ="boop" [set destination min-one-of (turtles with [label = 789] in-radius (360) )[distance myself] wt 20 walk-towards set last-destination "789" ]
[ ifelse last-destination = "789" [set destination min-one-of (turtles with [label = 456] in-radius (360) )[distance myself] wt 20 walk-towards set last-destination "456" ]
[ ifelse last-destination = "456" [set destination min-one-of (turtles with [label = 234] in-radius (360) )[distance myself] wt 20 walk-towards set last-destination "234"]
[ ifelse last-destination = "234" [set destination min-one-of (turtles with [label = 987] in-radius (360) )[distance myself] wt 20 walk-towards set last-destination "987"]
[ifelse last-destination = "987" [set destination min-one-of (turtles with [label = 789] in-radius (360) )[distance myself] wt 20 walk-towards set last-destination "7891" ]
[if last-destination = "7891" [set destination min-one-of (turtles with [label = 891] in-radius (360) )[distance myself] wt 20 walk-towards set last-destination "boop" set route random 3 ]]]]]]]]
if shopper_type = "lvl4"[
if route = 2 [
ifelse last-destination ="boop" [set destination min-one-of (turtles with [label = 789] in-radius (360) )[distance myself] wt 20 walk-towards set last-destination "789" ]
[ ifelse last-destination = "789" [set destination min-one-of (turtles with [label = 456] in-radius (360) )[distance myself] wt 20 walk-towards set last-destination "456" ]
[ ifelse last-destination = "456" [set destination min-one-of (turtles with [label = 234] in-radius (360) )[distance myself] wt 20 walk-towards set last-destination "234"]
[ ifelse last-destination = "234" [set destination min-one-of (turtles with [label = 987] in-radius (360) )[distance myself] wt 20 walk-towards set last-destination "987"]
[ifelse last-destination = "987" [set destination min-one-of (turtles with [label = 789] in-radius (360) )[distance myself] wt 20 walk-towards set last-destination "7891" ]
[if last-destination = "7891" [set destination min-one-of (turtles with [label = 891] in-radius (360) )[distance myself] wt 20 walk-towards set last-destination "boop" set route random 3 ]]]]]]]]
END
to setup_color
ask shopper with [shopper_type = "lvl1"] [set color cyan]
ask shopper with [shopper_type = "lvl2"] [set color pink]
end
TO rep
output-show ticks
output-show xcor
output-show ycor
output-show last-destination
output-show cid
end
*这是我编写的代码摘录,因为原始版本使用GIS图层进行坐标和海龟制作