下载此文档

10(多主体仿真4).ppt


文档分类:论文 | 页数:约12页 举报非法文档有奖
1/12
下载提示
  • 1.该资料是网友上传的,本站提供全文预览,预览什么样,下载就什么样。
  • 2.下载该文档所得收入归上传者、原创者。
  • 3.下载的文档,不会出现我们的网址水印。
1/12 下载此文档
文档列表 文档介绍
Multiagent Simulation with NetLogo Slide 1 Lecture 10 Multiagent Simulation with NetLogo (Part 4) Last revision June 7, 2003 Multiagent Simulation with NetLogo Slide Logo 常用建模技术(续) Last revision June 7, 2003 Multiagent Simulation with NetLogo Slide 3 5. 子程序和函数?不带参数的子程序(略) ?带参数的子程序(右例) NetLogo 常用建模技术(续) to draw-polygon [ num-sides len ] ;; turtle procedure pen-down repeat num-sides [ fd len rt 360 / num-sides ] end To test_polygon ca create-turtles 1 ask turtles [ draw-polygon 8 who ] end 此例程带两个参数调用方式 Multiagent Simulation with NetLogo Slide 4 5. 子程序和函数?不带参数的函数(略) ?带参数的函数(右例) NetLogo 常用建模技术(续) to-report absolute-value [number] ifelse number >= 0 [ report number ] [ report (- number) ] end To test_absolute print absolute-value -5 end 返回表达式。注意:不修改原始值 Multiagent Simulation with NetLogo Slide 5 6. 列表(list) NetLogo 常用建模技术(续) turtles-own [ my_property my_stocks ] to print_label ; a turtle procedure set label ( word "property:" my_property " stocks: " my_stocks ) end to setup ca create-turtles 1 [ set size 3 set my_property [ ] set my_stocks n-values 5 [0] print_label ] end 空的列表初始化为[0 0 0 0 0] Word 是个万能字串连接函数 Multiagent Simulation with NetLogo Slide 6 6. 列表(续) NetLogo 常用建模技术(续) to add_property ask turtle 0 [ ifelse _left = true [ set my_property fput new_pro my_property ] [ set my_property lput new_pro my_property ] print_label ] end to remove_property ask turtle 0 [ set my_property remove new_pro my_property print_label ] end to remove_dup_pro ask turtle 0 [ set my_property remove-duplicates my_property print_label ] end _left 和 new_pro 是界面全局变量 fput ( lput )是左(右)端添加将 my_property 中所有叫 new_pro 的项目删去将 my_property 中所有重复出现的项目删去 Multiagent Simulation with NetLogo Slide 7 6. 列表(续) NetLogo 常用建模技术(续) to change_st_value ask turtle 0 [ set my_stocks replace-item st_num my_stocks st_val print_label ] end to add_all_value ask turtl

10(多主体仿真4) 来自淘豆网www.taodocs.com转载请标明出处.

相关文档 更多>>
非法内容举报中心
文档信息
  • 页数12
  • 收藏数0 收藏
  • 顶次数0
  • 上传人aluyuw1
  • 文件大小250 KB
  • 时间2017-02-18
最近更新