📄 cruise.nlogo
字号:
to go if ticks = 0 [if (count turtles) = 0 [setup]] set ticks ticks + 1 ask turtles [ move-forward ]endto move-forward ; turtle proc locals [n p l] set n neighbors with [on-road?] ifelse count n = 0 [go-home] [ set l [] ask patch-left-and-ahead 90 3 [if on-road? [set l lput self l]] ask patch-right-and-ahead 90 3 [if on-road? [set l lput self l]] if (length l != 0) and (0 = random 3) [ set p random-one-of l ] if p = 0 [ set p one-of n with [(heading-angle myself) = 0] ] if p = nobody [ set p random-one-of n with [(heading-angle myself) <= 45] ] if p = nobody [ set p random-one-of n with [(heading-angle myself) <= 90] ] if p = nobody [ set p min-one-of n [heading-angle myself] ] set heading towards p forward distance p ]endto-report heading-angle [t] ; patch proc locals [h] ;set h abs (heading-of t - (towards t + 180) mod 360) set h (towards t + 180 - heading-of t) mod 360 if h > 180 [set h 360 - h] report hend; ---------------------------------------------------------------------------; Can delete; only used to build map data. Not used by model.; ---------------------------------------------------------------------------; These are called by hand to create the compressed (.dat) form of the map.; To create the file, call: create-dat "mapname" (w/o .dat); Can remove once the .dat is created. Here to explain the stunt.; Note: patchcolors proc below is an array form of the .dat file.; ---------------------------------------------------------------------------to init-map create-dat mapnameendto create-dat [mapfile] print "..creating patches, I'll print 'done' when completed"
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -