cruise.nlogo

来自「NETLOGO」· NLOGO 代码 · 共 239 行 · 第 1/5 页

NLOGO
239
字号
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 + =
减小字号Ctrl + -
显示快捷键?