📄 ---termitesslow.nlogo
字号:
to setup ca ask patches [ ;;randomly distributes wood chips if random 100 < density [set pcolor yellow ] ] create-turtles number ;;randomly distributes termites ask turtles [ set color white setxy random screen-size-x random screen-size-y ]endto go ; turtle procedure search-for-chip find-new-pile put-down-chipendto go-slow ; turtle procedure slow-search-for-chip slow-find-new-pile slow-put-down-chipendto search-for-chip ; turtle procedure -- "picks up chip" by turning orange ifelse pcolor = yellow [ stamp black set color orange jump 20 ] [ wiggle search-for-chip ]endto slow-search-for-chip ; turtle procedure -- "picks up chip" by turning orange ifelse pcolor = yellow [ stamp black set color orange jump 20 ] [ slow-wiggle slow-search-for-chip ]endto find-new-pile ; turtle procedure -- look for yellow patches if pcolor != yellow [wiggle find-new-pile]endto slow-find-new-pile ; turtle procedure -- look for yellow patches if pcolor != yellow [slow-wiggle slow-find-new-pile]endto put-down-chip ; turtle procedure -- finds empty spot & drops chip ifelse pcolor = black [stamp yellow set color white get-away] [rt random 360 fd 1 put-down-chip]endto slow-put-down-chip ; turtle procedure -- finds empty spot & drops chip ifelse pcolor = black [stamp yellow set color white slow-get-away] [rt random 360 fd 1 slow-put-down-chip]endto get-away ; turtle procedure -- jump out of yellow piles rt random 360 jump 20 if pcolor != black [get-away]endto slow-get-away ; turtle procedure -- jump out of yellow piles rt random 360 jump 20 wait 0.15 if pcolor != black [slow-get-away]endto wiggle ; turtle procedure fd 1 rt random 50 - random 50endto slow-wiggle ; turtle procedure fd 1 wait 0.15 rt random 50 - random 50end; ***NetLogo Model Copyright Notice***; This model was adapted from the MIT Media Lab termites model 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 1998 by Uri Wilensky. All rights reserved.; Converted from StarLogoT to NetLogo, 2001.; 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. (1998). NetLogo Termites model.; http://ccl.northwestern.edu/netlogo/models/Termites.; Center for Connected Learning and Computer-Based Modeling,; Northwestern University, Evanston, IL.; ***End NetLogo Model Copyright Notice***@#$#@#$#@GRAPHICS-WINDOW2402764443150504.001000CC-WINDOW14214224360Command CenterBUTTON1252818661gogoT1TTURTLEBUTTON522811361setupsetupNIL1TOBSERVERSLIDER33130204163numbernumber030011311NILSLIDER31164205197densitydensity0.0100.025.01.01%BUTTON7080155113Go Slowgo-slowT1TTURTLE@#$#@#$#@WHAT IS IT?-----------This project is inspired by the behavior of termites gathering wood chips into piles. The termites follow a set of simple rules. Each termite starts wandering randomly. If it bumps into a wood chip, it picks the chip up, and continues to wander randomly. When it bumps into another wood chip, it finds a nearby empty space and puts its wood chip down. With these simple rules, the wood chips eventually end up in a single pile.HOW TO USE IT ------------- Click the SETUP button to set up the termites (white) and wood chips (yellow). Click the GO button to start the simulation. The termites turn orange when they are carrying a wood chip.The NUMBER slider controls the number of termites. (Note: Changes in the NUMBER slider do not take effect until the next setup.) The DENSITY slider controls the initial density of wood chips.THINGS TO NOTICE----------------As piles of wood chips begin to form, the piles are not "protected" in any way. That is, termites sometimes take chips away from existing piles. That strategy might seem counter-productive. But if the piles were "protected", you would end up with lots of little piles, not one big one.The final piles are roughly round. Why is this? What other physical situations also produce round things? In general, the number of piles decreases with time. Why? Some piles disappear, when termites carry away all of the chips. And there is no way to start a new pile from scratch, since termites always put their wood chips near other wood chips. So the number of piles must decrease over time. (The only way a "new" pile starts is when an existing pile splits into two.)This project is a good example of a DECENTRALIZED strategy. There is no termite in charge, and no special pre-designated site for the piles. Each termite follows a set of simple rules, but the colony as a whole accomplishes a rather sophisticated task.THINGS TO TRY-------------Do the results change if you use just a single termite? What if you use several thousand termites?When there are just two piles left, which of them is most likely to "win" as the single, final pile? How often does the larger of the two piles win? If one pile has only a single wood chip, and the other pile has the rest of the wood chips, what are the chances that the first pile will win?EXTENDING THE MODEL-------------------Can you extend the model to have the termites sort several colors of wood? Plot the number of piles, or their average size, or the number of termites carrying wood chips, as the model runs. NETLOGO FEATURES-------------------Notice that the wood chips do not exist as objects. They are just represented as colors in the patches. The termites update the patch colors as they pick up and put down the wood chips. In effect, the screen is being used as the data structure. This strategy is useful in many NetLogo programs.Note than when you stop the GO forever button, the termites keep moving for a little while. This is because they are each finishing the commands in the GO procedure. To do this, they must finish their current cycle of finding a chip, finding a pile, and then finding an empty spot near the pile. (In most models, the GO function only moves the model forward one step, but in this model, the GO function is written to advance the turtles through a full cycle of activity.)RELATED MODELS--------------Shepherds, Painted Desert ChallengeCREDITS AND REFERENCES----------------------This model was developed at the MIT Media Lab. See Resnick, M. (1994) "Turtles, Termites and Traffic Jams: Explorations in Massively Parallel Microworlds." Cambridge, Ma: MIT Press. Adapted to StarLogoT, 1997, as part of the Connected Mathematics Project. Adapted to NetLogo, 2000, as part of the Participatory Simulations Project.To refer to this model in academic publications, please use: Wilensky, U. (1998). NetLogo Termites model. http://ccl.northwestern.edu/netlogo/models/Termites. Center for Connected Learning and Computer-Based Modeling, Northwestern University, Evanston, IL.@#$#@#$#@defaulttrue0Polygon -7566196 true true 150 5 40 250 150 205 260 250@#$#@#$#@NetLogo 1.1 (Rev D)@#$#@#$#@@#$#@#$#@@#$#@#$#@
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -