⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ---wolf_schaf.nlogo

📁 NETLOGO
💻 NLOGO
📖 第 1 页 / 共 2 页
字号:
globals [ ticks;;sheepStock;;wolveStockarea]breeds [ sheep wolves ]turtles-own [ energy ]sheep-own [ grabbed? ]     ;; used to prevent two wolves from eating the same sheeppatches-own [ countdown ]to setup  ct  cp  set-current-plot "agent-populations"  clear-plot  set ticks 0  ask patches [ set pcolor green ]  set-default-shape sheep "sheep"  create-custom-sheep initial-number-sheep  ;; create the sheep, then initialize their variables  [    set color white    set label-color blue - 2    set energy random (2 * sheep-gain-from-food)    setxy random-float screen-size-x          random-float screen-size-y    set grabbed? false    set size 1.5  ]  set-default-shape wolves "wolf"  create-custom-wolves initial-number-wolves  ;; create the wolves, then initialize their variables  [    set color black    set energy random (2 * wolf-gain-from-food)    setxy random-float screen-size-x          random-float screen-size-y    set size 1.5  ]  display-labels  do-plotendto setup-aggregate  set-current-plot "populations"  clear-plot  ;; call procedure generated by aggregate modeler  system-dynamics-setupendto step-aggregate  ;; each agent tick is DT=1  repeat ( 1 / dt ) [ system-dynamics-go ]  system-dynamics-do-plotendto go  ask sheep [    move    reproduce-sheep    death  ]  ask wolves [    move    set energy energy - 1  ;; wolves lose energy as they move    catch-sheep    reproduce-wolves    death  ]  do-plot  ;; plot populations  every 0.5    [ display-labels ]  set ticks ticks + 1  if not any? turtles [ stop ]endto move  ;; turtle procedure  rt random-float 50 - random-float 50  fd 1endto eat-grass  ;; sheep procedure  ;; sheep eat grass, turn the patch brown  if pcolor = green [    set pcolor brown    set energy energy + sheep-gain-from-food  ;; sheep gain energy by eating  ]endto reproduce-sheep  ;; sheep procedure  if random-float 100 < sheep-reproduce [  ;; throw "dice" to see if you will reproduce    set energy (energy / 2)          ;; divide energy between parent and offspring    hatch 1 [ rt random-float 360 fd 1 ]   ;; hatch an offspring and move it forward 1 step  ]endto reproduce-wolves  ;; wolf procedure  if random-float 100 < wolf-reproduce [  ;; throw "dice" to see if you will reproduce    set energy (energy / 2 )  ;; divide energy between parent and offspring    hatch 1 [ rt random-float 360 fd 1 ]  ;; hatch an offspring and move it forward 1 step  ]endto catch-sheep  ;; wolf procedure  let prey random-one-of (sheep-here             ;; grab a random sheep                           with [not grabbed?]) ;; that no one else is grabbing  if prey != nobody                             ;; did we get one?  if so,    [ set grabbed?-of prey true                 ;; prevent other wolves from grabbing it      ask prey [ die ]                          ;; kill it      set energy energy + wolf-gain-from-food ]     ;; get energy from eatingendto death  ;; turtle procedure  ;; when energy dips below zero, die  if energy < 0 [ die ]endto do-plot  set-current-plot "agent-populations"  set-current-plot-pen "sheep"  plot count sheep  set-current-plot-pen "wolves"  plot count wolvesendto display-labels  ifelse show-energy?  [      ask wolves      [ set label round energy ]      ask sheep      [ set label no-label ]  ]  [    ask turtles    [ set label no-label ]  ]end; *** NetLogo Model Copyright Notice ***;; This model was created as part of the project: CONNECTED MATHEMATICS:; MAKING SENSE OF COMPLEX PHENOMENA THROUGH BUILDING OBJECT-BASED PARALLEL; MODELS (OBPML).  The project gratefully acknowledges the support of the; National Science Foundation (Applications of Advanced Technologies; Program) -- grant numbers RED #9552950 and REC #9632612.;; Copyright 2005 by Uri Wilensky. All rights reserved.;; Permission to use, modify or redistribute this model is hereby granted,; provided that both of the following requirements are followed:; a) this copyright notice is included.; b) this model will not be redistributed for profit without permission;    from Uri Wilensky.; Contact Uri Wilensky for appropriate licenses for redistribution for; profit.;; This model was converted to NetLogo as part of the project:; PARTICIPATORY SIMULATIONS: NETWORK-BASED DESIGN FOR SYSTEMS LEARNING IN; CLASSROOMS.  The project gratefully acknowledges the support of the; National Science Foundation (REPP program) -- grant number REC #9814682.;; To refer to this model in academic publications, please use:; Wilensky, U. (2005).  NetLogo Wolf Sheep Predation model.; http://ccl.northwestern.edu/netlogo/models/WolfSheepPredationDocked.; Center for Connected Learning and Computer-Based Modeling,; Northwestern University, Evanston, IL.;; In other publications, please use:; Copyright 2005 by Uri Wilensky.  All rights reserved.  See; http://ccl.northwestern.edu/netlogo/models/WolfSheepPredationDocked; for terms of use.;; *** End of NetLogo Model Copyright Notice ***@#$#@#$#@GRAPHICS-WINDOW3501072941020209.01141110111CC-WINDOW56161077711Command Center0SLIDER3100177133initial-number-sheepinitial-number-sheep025014811NILSLIDER3137177170sheep-gain-from-foodsheep-gain-from-food0.050.04.01.01NILSLIDER3172177205sheep-reproducesheep-reproduce1.020.04.01.01%SLIDER181100346133initial-number-wolvesinitial-number-wolves02503011NILSLIDER181136346169wolf-gain-from-foodwolf-gain-from-food0.0100.013.01.01NILSLIDER181172346205wolf-reproducewolf-reproduce0.020.05.01.01%BUTTON10387971setupsetupNIL1TOBSERVERTNILBUTTON923815971gogoT1TOBSERVERTNILPLOT8269317466agent-populationstimepop.0.0100.00.0100.0truetruePENS"sheep" 1.0 0 -13345367 true"wolves" 1.0 0 -2674135 trueMONITOR87211158260sheepcount sheep31MONITOR162211244260wolvescount wolves31MONITOR248211324260grass / 4count patches with [ pcolor = green ] / 401TEXTBOX88014899Sheep settingsTEXTBOX1868029998Wolf settingsMONITOR521183260time-ticksticks01SWITCH1693830571show-energy?show-energy?01-1000PLOT7592711068469populationstimepop.0.0100.00.0100.0truetruePENS"wolfStock" 1.0 0 -2674135 true"sheepStock" 1.0 0 -13345367 trueBUTTON75977903110system-dynamics-gosystem-dynamics-go\nsystem-dynamics-do-plotNIL1TOBSERVERTNILMONITOR762217845266NILsheepStock51MONITOR857218938267NILwolfStock51BUTTON511484645517Step Comparego\nstep-aggregateNIL1TOBSERVERTNBUTTON7583390166setup-aggregatesetup-aggregateNIL1TOBSERVERTNILSLIDER9171231067156predationRatepredationRate00.13.0E-41.0E-41NILSLIDER757123909156predatorEfficiencypredatorEfficiency0101.00.11NILSLIDER763171949204wolves-death-ratewolves-death-rate010.150.011NILBUTTON91533105066system-dynamics-gosystem-dynamics-go\nsystem-dynamics-do-plotT1TOBSERVERNILNILMONITOR9024961043545NIL

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -