netlogo之turtles的设置

turtle1.0

turtle number<breed> number

Reports the turtle with the given who number, or nobody if there is no such turtle. For breeded turtles you may also use the single breed form to refer to them.

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

turtle-set4.0

turtle-set value1(turtle-set value1 value2 ...)

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)

See also patch-setlink-set.

turtles1.0

turtles

Reports the agentset consisting of all turtles.

show count turtles
;; prints the number of turtles

turtles-at1.0

turtles-at dx dy<breeds>-at dx dyTurtle Command Patch Command

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>-hereTurtle Command Patch Command

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

turtles-on agentturtles-on agentset<breeds>-on agent<breeds>-on agentsetTurtle Command Patch Command

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 ...]

The turtles-own keyword, like the globals, breed, <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]

See also globalspatches-ownbreed<breeds>-own.

这些来自官网netlogo6.0.3用户手册  内容简单就不翻译了



下面直接上代码 自己写的

 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

  • 3
    点赞
  • 14
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值