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

📄 ---heatbugs.nlogo

📁 NETLOGO
💻 NLOGO
📖 第 1 页 / 共 2 页
字号:
turtles-own[  ideal-temp  output-heat  unhappiness]patches-own[  temp]to setup  clear-all  ;; creating the bugs the following way ensures that we won't  ;; wind up with more than one bug on a patch  ask random-n-of bug-count patches [    sprout 1 [      set color lime      set ideal-temp  min-ideal-temp  + random abs (max-ideal-temp  - min-ideal-temp )      set output-heat min-output-heat + random abs (max-output-heat - min-output-heat)      set unhappiness abs (ideal-temp - temp)    ]  ]  ;; plot the initial state of the system  plot mean values-from turtles [unhappiness]endto go  if not any? turtles [ stop ]  ;; diffuse heat through world  diffuse temp diffusion-rate  ask turtles [    ;; we must use without-interruption to prevent two turtles    ;; from ever ending up on the same patch    without-interruption [      step    ]  ]  recolor-patches  plot mean values-from turtles [unhappiness]endto recolor-patches  ask patches  [    ;; the world retains a percentage of its heat each cycle    set temp temp * (1 - evaporation-rate)    ;; hotter patches will be red turning to white, cooler patches will be black    set pcolor scale-color red temp 0 150  ]endto step  ;; turtle procedure  ;; my unhappiness is the magnitude or absolute value of the difference  ;; between by ideal temperature and the temperature of this patch  set unhappiness abs (ideal-temp - temp)  ;; if unhappy and not at the hottest neighbor8  ;; then move to an open neighbor (trying random ones up to 10 times)  ifelse unhappiness = 0    [ set temp temp + output-heat ]    [ let target find-target      if (patch-here != target) or (random-move-chance > random 100)        [ bug-move target ]      set temp temp + output-heat    ]end;; find the hottest or coolest location next to meto-report find-target  ;; turtle procedure  ifelse temp < ideal-temp    [ report max-one-of neighbors [temp] ]    [ report min-one-of neighbors [temp] ]endto bug-move [target]  ;; turtle procedure  let tries 0  ;; move to the hottest (or coolest location if I'm too hot) location next to me  ;; if it is not occupied by another bug  if not any? turtles-on target [    setxy (pxcor-of target) (pycor-of target)    stop  ]  ;; If I can't get to the best spot, then I try the others randomly  ;; I only try 9 times, since there are only nine spots around me.  ;; Even then, I might try a spot more than once.  while [tries <= 9]    [ set tries tries + 1      set target random-one-of neighbors      if not any? turtles-on target [        setxy (pxcor-of target) (pycor-of target)        stop      ]    ]end;;; the following procedures support the two extra buttons;;; in the interface;; remove all heat from the worldto deep-freeze  ask patches [ set temp 0 ]end;; add max-output-heat to all locations in the world, heating it evenlyto heat-up  ask patches [ set temp temp + max-output-heat ]end; *** NetLogo Model Copyright Notice ***;; This model was created as part of the projects:; PARTICIPATORY SIMULATIONS: NETWORK-BASED DESIGN FOR SYSTEMS LEARNING IN; CLASSROOMS and INTEGRATED SIMULATION AND MODELING ENVIRONMENT.; The project gratefully acknowledges the support of the; National Science Foundation (REPP & ROLE programs) -- grant numbers; REC #9814682 and REC-0126227.;; Copyright 2004 by Uri Wilensky.  Updated 2004.  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.;; To refer to this model in academic publications, please use:; Wilensky, U. (2004).  NetLogo Heatbugs model.; http://ccl.northwestern.edu/netlogo/models/Heatbugs.; Center for Connected Learning and Computer-Based Modeling,; Northwestern University, Evanston, IL.;; In other publications, please use:; Copyright 2004 Uri Wilensky.  All rights reserved.; See http://ccl.northwestern.edu/netlogo/models/Heatbugs; for terms of use.;; *** End of NetLogo Model Copyright Notice ***@#$#@#$#@GRAPHICS-WINDOW3731068634450503.00101110111CC-WINDOW5520695615Command Center0SLIDER144127674bug-countbug-count10500200101bugsBUTTON2718896221NILsetupNIL1TOBSERVERNILNILBUTTON98188166221NILgoT1TOBSERVERTNILSLIDER18305211338evaporation-rateevaporation-rate010.020.011NILSLIDER18339211372diffusion-ratediffusion-rate011.00.11NILSLIDER18374211407random-move-chancerandom-move-chance01001.01.01%PLOT373347686506Avg. Bug Unhappinesstimeunhappiness0.0100.00.010.0truefalseSLIDER1480186113min-ideal-tempmin-ideal-temp02000.01.01NILSLIDER14113186146max-ideal-tempmax-ideal-temp0200100.01.01NILSLIDER189113362146max-output-heatmax-output-heat010030.01.01NILSLIDER18980362113min-output-heatmin-output-heat010010.01.01NILBUTTON195188312221NILdeep-freezeNIL1TOBSERVERTNILBUTTON195222312255NILheat-upNIL1TOBSERVERTNILTEXTBOX102116039Initial settings for bugsTEXTBOX11273164301Other parameters (OK to change during run)TEXTBOX12167162185Actions

⌨️ 快捷键说明

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