netlogo之turtles的设置

匿名 (未验证) 提交于 2019-12-03 00:22:01

turtle1.0

numbernumber

nobody

ask turtle 5 [ set color red ] ;; turtle with who number 5 turns red 

turtle-set4.0

value1

Reports an agentset containing all of the turtles anywhere in any of the inputs. The inputs may be individual turtles, turtle agentsets, nobody, or lists (or nested lists) containing any of the above.

turtle-set self (turtle-set self turtles-on neighbors) (turtle-set turtle 0 turtle 2 turtle 9) (turtle-set frogs mice) 

patch-setlink-set.

turtles1.0

turtles

Reports the agentset consisting of all turtles.

show count turtles ;; prints the number of turtles 

turtles-at1.0

<breeds>

Reports an agentset containing the turtles on the patch (dx, dy) from the caller. (The result may include the caller itself if the caller is a turtle.)

create-turtles 5 [ setxy 2 3 ] show count [turtles-at 1 1] of patch 1 2 => 5 

If the name of a breed is substituted for "turtles", then only turtles of that breed are included.

turtles-here1.0

turtles-here<breeds>-here

Reports an agentset containing all the turtles on the caller's patch (including the caller itself if it's a turtle).

crt 10 ask turtle 0 [ show count turtles-here ] => 10 

If the name of a breed is substituted for "turtles", then only turtles of that breed are included.

breed [cats cat] breed [dogs dog] create-cats 5 create-dogs 1 ask dogs [ show count cats-here ] => 5 

turtles-on2.0

agentagentset<breeds>agent<breeds>agentset

Reports an agentset containing all the turtles that are on the given patch or patches, or standing on the same patch as the given turtle or turtles.

ask turtles [   if not any? turtles-on patch-ahead 1     [ fd 1 ] ] ask turtles [   if not any? turtles-on neighbors [     die-of-loneliness   ] ] 

If the name of a breed is substituted for "turtles", then only turtles of that breed are included.

turtles-own

turtles-own [var1<breeds>-own [var1

<breeds>-own, and patches-own keywords, can only be used at the beginning of a program, before any function definitions. It defines the variables belonging to each turtle.

If you specify a breed instead of "turtles", only turtles of that breed have the listed variables. (More than one turtle breed may list the same variable.)

breed [cats cat ] breed [dogs dog] breed [hamsters hamster] turtles-own [eyes legs]   ;; applies to all breeds cats-own [fur kittens] hamsters-own [fur cage] dogs-own [hair puppies] 

globalspatches-ownbreed<breeds>-own.



下面直接上代码 自己写的

 turtles-own [   people-type;    ;普通人   ;volunteer; ;志愿者  ; leader;    ;意见领袖   safeplace; ;安全区   vision-radius;  ;感知范围   escape-speed;   ;逃跑速度 ] to init   clear-all;     set-patch-color;    create-people ;   create-safeplace; end to set-patch-color  ;设置瓦片颜色   ask patches     [set pcolor 9] ; end   to create-safeplace  ;创建安全区   create-turtles count-of-safeplace;   [     set color white;     set shape "pentagon";      setxy 0 0;     set size 8;   ] end  to create-people       ;创建人群     create-turtles count-of-person  ;普通人   [   set color green;   set shape "person";   ;set vision-radius 100;   setxy random-xcor random-ycor;  ; set escape-speed 1;   ]    create-turtles count-of-volunteer ;志愿者   [     set color red;     set shape "person";     setxy random-xcor random-ycor;   ;  set escape-speed 1;    ]   create-turtles count-of-leader     ;意见领袖   [     set color yellow;     set shape "person";     setxy random-xcor random-ycor;     ;set vision-radius 100;    ;  set escape-speed 1;   ]  end  to start     move-person   move-volunteer   move-leader  end    to move-person  end  to move-volunteer  ;ask volunteer   ;fd 1 end  to move-leader end

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!