内容简介 · · · · · ·
◎ 编辑推荐
● 无须任何编程基础,简单易学快速上手
● 精选七大实战案例,动手搭建经典模型
● 张江教授精心打造,集智学园精品课程
◎ 内容简介
本书从大量跨学科、跨领域的实际案例入手,循序渐进地讲解了NetLogo的使用方式、基本语法、设计思想,以及背后的计算机模拟、多主体建模、复杂性科学的基本理念和数理建模的常用方法,包括数值计算、微分方程、动力系统、概率统计等。通过学习,读者可以学会搭建一个人工生命的世界、一个人工经济系统,以及一个人工生态系统;通过计算机模拟,读者可以理解大自然的捕食依存关系、病毒传播和疫情暴发的原理,还能对人类社会财富分布不均衡的起源有全新的认识。
◎ 名人推荐
这是一本难得的好书,是国内系统介绍NetLogo的开荒之作,适合数理及人文多个领域的学生和学者阅读和参考,值得广泛推荐。
——陈关荣,香港城市大学讲座教授,欧洲科...
◎ 编辑推荐
● 无须任何编程基础,简单易学快速上手
● 精选七大实战案例,动手搭建经典模型
● 张江教授精心打造,集智学园精品课程
◎ 内容简介
本书从大量跨学科、跨领域的实际案例入手,循序渐进地讲解了NetLogo的使用方式、基本语法、设计思想,以及背后的计算机模拟、多主体建模、复杂性科学的基本理念和数理建模的常用方法,包括数值计算、微分方程、动力系统、概率统计等。通过学习,读者可以学会搭建一个人工生命的世界、一个人工经济系统,以及一个人工生态系统;通过计算机模拟,读者可以理解大自然的捕食依存关系、病毒传播和疫情暴发的原理,还能对人类社会财富分布不均衡的起源有全新的认识。
◎ 名人推荐
这是一本难得的好书,是国内系统介绍NetLogo的开荒之作,适合数理及人文多个领域的学生和学者阅读和参考,值得广泛推荐。
——陈关荣,香港城市大学讲座教授,欧洲科学院院士,发展中国家科学院院士
本书基本上囊括了入门NetLogo所需掌握的各种模块。只要你真真正正把这11章内容学完,就能成功掌握NetLogo的基础。剩下的,就是灵活运用你的“屠龙宝刀”了。
——王树义,天津师范大学副教授,公众号“玉树芝兰”主理人,少数派网站专栏作者
未来的世界,人人都需要编程思维;而从还原论思维走向系统论思维,NetLogo是一个好选择。NetLogo,让复杂的世界变得简单。
——王小川,北京搜狗科技发展有限公司CEO
NetLogo软件不仅是一种研究工具和模型可视化工具,更是一种系统性思维,必将揭示人类社会、自然科学之间的普适性联系。
——吕鹏,中南大学公共管理学院教授、社会计算研究中心主任,教育部青年长江学者
随着科学技术的进步和国家建设的发展,我们面临越来越多的复杂性问题。NetLogo就是复杂系统建模的有利工具。本书用清新的写作手法带领读者快速了解NetLogo,并通过一系列鲜活有趣的例子,带领读者一窥复杂系统建模的殿堂。
——韩战钢,北京师范大学系统科学学院教授、副院长
作者简介 · · · · · ·
集智俱乐部(Swarma Club)
成立于2003年,是一个从事学术研究、享受科学乐趣的探索者团体,也是国内最早研究人工智能、复杂系统的科学社区之一,倡导以平等开放的态度、科学实证的精神,进行跨学科的研究与交流,力图搭建一个中国的“没有围墙的研究所”。编写、翻译过多本科普著作,著作有《科学的极致:漫谈人工智能》《走近2050:注意力、互联网与人工智能》《深度学习原理与PyTorch实战》,译作有《深度思考:人工智能的终点与人类创造力的起点》等。
目录 · · · · · ·
序二 iv
序三 vii
前言 i
作者简介 i
第 1章 复杂系统与多主体模拟 2
1.1 如何探索复杂系统 2
1.2 多主体模拟 3
1.3 为什么要学习NetLogo 5
1.4 生命游戏 6
1.5 鸟群模型 9
1.6 财富分布模型 11
1.7 小结 14
第 2章 小球宇宙:认识NetLogo 15
2.1 什么是小球宇宙 15
2.2 搭建宇宙框架 17
2.2.1 创建小球 18
2.2.2 让小球动起来 21
2.2.3 修改宇宙属性 24
2.3 模拟程序的流程图 25
2.4 NetLogo的特点 26
2.5 学习资源 27
2.6 小结 29
第3章 通过“生命游戏”认识patch 30
3.1 什么是生命游戏 30
3.2 认识patch 32
3.3 创建模拟世界 32
3.3.1 random-float命令 33
3.3.2 初始化模拟世界 33
3.3.3 用patches-own自定义添加patch属性 34
3.4 让生命游戏运转起来 35
3.5 NetLogo 语法的注意事项 39
3.6 小结 41
第4章 朗顿的蚂蚁 42
4.1 什么是朗顿的蚂蚁 42
4.2 创建蚂蚁 44
4.2.1 turtle的方法与属性 45
4.2.2 random命令 45
4.3 让蚂蚁动起来
4.3.1 turtle和patch之间的交互 47
4.3.2 使用tick计时 48
4.4 小结 50
第5章 从羊-草生态系统深入turtle与plot画图 51
5.1 羊-草生态系统的规则 51
5.2 初始化羊-草生态系统 53
5.3 添加to go程序 55
5.3.1 add_food 55
5.3.2 turtle_move 56
5.3.3 turtle_breed 57
5.3.4 turtle_die 57
5.4 追踪某一个具体的turtle或者patch的行为 58
5.5 变量的主体 61
5.6 添加绘图框 61
5.7 小结 63
第6章 人工经济模型与turtle间的互动 66
6.1 货币转移模型 66
6.2 NetLogo添加全局变量 69
6.3 初始化模拟世界 70
6.4 主体之间如何交互 70
6.4.1 transaction子模块 72
6.4.2 变量作用域 73
6.5 使用命令中心 74
6.6 绘制财富分布直方图 76
6.7 小结 78
第7章 文件导出与复杂曲线绘制 79
7.1 人工经济模型回顾及遗留问题 79
7.2 NetLogo导出文件 80
7.3 洛伦兹曲线 85
7.4 用 NetLogo实现洛伦兹曲线 89
7.4.1 绘图语句 90
7.4.2 表示财富分布极端不均衡的折线的绘制 91
7.4.3 洛伦兹曲线的绘制 92
7.5 小结 94
第8章 使用行为空间做实验 95
8.1 更新人工经济模型的基本规则 95
8.2 程序修改 97
8.3 两种规则下的财富分布对比 99
8.4 基尼系数的定义及程序实现 100
8.4.1 什么是基尼系数 100
8.4.2 基尼系数的计算方法 101
8.4.3 基尼系数的程序实现 101
8.5 参数变化对财富分布不均衡性的影响 105
8.6 使用行为空间做重复实验 106
8.7 小结 110
第9章 透过人工鸟群模型Boids学习list的使用 111
9.1 人工鸟群模型Boids 112
9.2.1 矢量的加法 114
9.2.2 矢量的减法 114
9.2.3 矢量的数乘 115
9.3 Boids模型需要的矢量运算 116
9.3.1 靠近力 118
9.3.2 对齐力 119
9.3.3 斥力 119
9.3.4 合力 120
9.4 让Boids动起来 121
9.5 NetLogo的列表——list 122
9.6 Boids模型程序实现 124
9.7 小结 128
第 10章 用link建模网络动力学 129
10.1 病毒传播SIR模型 129
10.2 构建网络拓扑结构 131
10.3 NetLogo中的link对象 131
10.4 SIR模型搭建 132
10.5 SIR模型代码实现 133
10.5.1 给turtle设置state属性 134
10.5.2 to setup代码块 135
10.5.3 setup-network函数 135
10.5.4 to go代码块 138
10.6 参数变化对模拟结果的影响 139
10.7 SIR模型的弊端与无标度网络 141
10.8 改进网络模型 142
10.9 修改程序实现改进的网络模型 142
10.10 小结 144
第 11章 重访羊-草模型与系统动力学建模 145
11.1 多主体建模的弊端 145
11.2 羊-草的系统动力学模型 145
11.2.1 代数求解羊-草的系统动力学模型 146
11.2.2 用计算机求解羊-草的系统动力学模型 147
11.3 系统动力学建模工具求解微分方程 148
11.4 让羊-草模型运行起来 151
11.5 重新构建羊-草生态系统 152
11.5.1 用流-存的方法建模 153
11.5.2 羊-草生态系统模型的动力学方程 153
11.6 羊-草生态系统模型的系统动力学搭建 154
11.7 调试羊-草生态系统模型 157
11.7.1 如何设定各个参数的数值 158
11.7.2 设置dt取值 158
11.8 更一般的微分动力系统 160
11.9 小结 160
结束语 162
后记 165
· · · · · · (收起)
丛书信息
NetLogo多主体建模入门的书评 · · · · · · ( 全部 0 条 )
读书笔记 · · · · · ·
我来写笔记-
里面有些代码都前后不一致,也有打错了的。70页有个赋值语句里有个保留词写的是 turtles-here,到后面讲解的时候同样的位置就突然变成turtles,少了-here,不知道为什么前后不一致的,也没讲解或者任何的说明,如果两种表达在语法上都是没错的,但做出来模型就完全不一样,离谱。 还有不少那种语焉不详、解释不清,讲解不明的地方,我寻思这书也不是国外译介的,中国人讲中国话都讲不好。 讲真,不知道前言里那些极力推荐这本书...
2022-01-30 00:11:21 3人喜欢
-
弦歌 (從吾所好與古為徒)
## WHAT IS IT? This model is an attempt to mimic the flocking of birds. (The resulting motion also resembles schools of fish.) The flocks that appear in this model are not created or led in any way by special leader birds. Rather, each bird is following exactly the same set of rules, from which flocks emerge. ## HOW IT WORKS The birds follow three rules: "alignment", "separation", and "cohes... (1回应)2021-12-03 16:58:26
## WHAT IS IT?
This model is an attempt to mimic the flocking of birds. (The resulting motion also resembles schools of fish.) The flocks that appear in this model are not created or led in any way by special leader birds. Rather, each bird is following exactly the same set of rules, from which flocks emerge.
## HOW IT WORKS
The birds follow three rules: "alignment", "separation", and "cohesion".
"Alignment" means that a bird tends to turn so that it is moving in the same direction that nearby birds are moving.
"Separation" means that a bird will turn to avoid another bird which gets too close.
"Cohesion" means that a bird will move towards other nearby birds (unless another bird is too close).
When two birds are too close, the "separation" rule overrides the other two, which are deactivated until the minimum separation is achieved.
The three rules affect only the bird's heading. Each bird always moves forward at the same constant speed.
## HOW TO USE IT
First, determine the number of birds you want in the simulation and set the POPULATION slider to that value. Press SETUP to create the birds, and press GO to have them start flying around.
The default settings for the sliders will produce reasonably good flocking behavior. However, you can play with them to get variations:
Three TURN-ANGLE sliders control the maximum angle a bird can turn as a result of each rule.
VISION is the distance that each bird can see 360 degrees around it.
## THINGS TO NOTICE
Central to the model is the observation that flocks form without a leader.
There are no random numbers used in this model, except to position the birds initially. The fluid, lifelike behavior of the birds is produced entirely by deterministic rules.
Also, notice that each flock is dynamic. A flock, once together, is not guaranteed to keep all of its members. Why do you think this is?
After running the model for a while, all of the birds have approximately the same heading. Why?
Sometimes a bird breaks away from its flock. How does this happen? You may need to slow down the model or run it step by step in order to observe this phenomenon.
## THINGS TO TRY
Play with the sliders to see if you can get tighter flocks, looser flocks, fewer flocks, more flocks, more or less splitting and joining of flocks, more or less rearranging of birds within flocks, etc.
You can turn off a rule entirely by setting that rule's angle slider to zero. Is one rule by itself enough to produce at least some flocking? What about two rules? What's missing from the resulting behavior when you leave out each rule?
Will running the model for a long time produce a static flock? Or will the birds never settle down to an unchanging formation? Remember, there are no random numbers used in this model.
## EXTENDING THE MODEL
Currently the birds can "see" all around them. What happens if birds can only see in front of them? The `in-cone` primitive can be used for this.
Is there some way to get V-shaped flocks, like migrating geese?
What happens if you put walls around the edges of the world that the birds can't fly into?
Can you get the birds to fly around obstacles in the middle of the world?
What would happen if you gave the birds different velocities? For example, you could make birds that are not near other birds fly faster to catch up to the flock. Or, you could simulate the diminished air resistance that birds experience when flying together by making them fly faster when in a group.
Are there other interesting ways you can make the birds different from each other? There could be random variation in the population, or you could have distinct "species" of bird.
## NETLOGO FEATURES
Notice the need for the `subtract-headings` primitive and special procedure for averaging groups of headings. Just subtracting the numbers, or averaging the numbers, doesn't give you the results you'd expect, because of the discontinuity where headings wrap back to 0 once they reach 360.
## RELATED MODELS
* Moths
* Flocking Vee Formation
* Flocking - Alternative Visualizations
## CREDITS AND REFERENCES
This model is inspired by the Boids simulation invented by Craig Reynolds. The algorithm we use here is roughly similar to the original Boids algorithm, but it is not the same. The exact details of the algorithm tend not to matter very much -- as long as you have alignment, separation, and cohesion, you will usually get flocking behavior resembling that produced by Reynolds' original model. Information on Boids is available at https://web.archive.org/web/20210818090425/http://www.red3d.com/cwr/boids/.
## HOW TO CITE
If you mention this model or the NetLogo software in a publication, we ask that you include the citations below.
For the model itself:
* Wilensky, U. (1998). NetLogo Flocking model. http://ccl.northwestern.edu/netlogo/models/Flocking. Center for Connected Learning and Computer-Based Modeling, Northwestern University, Evanston, IL.
Please cite the NetLogo software as:
* Wilensky, U. (1999). NetLogo. http://ccl.northwestern.edu/netlogo/. Center for Connected Learning and Computer-Based Modeling, Northwestern University, Evanston, IL.
## COPYRIGHT AND LICENSE
Copyright 1998 Uri Wilensky.

This work is licensed under the Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License. To view a copy of this license, visit https://creativecommons.org/licenses/by-nc-sa/3.0/ or send a letter to Creative Commons, 559 Nathan Abbott Way, Stanford, California 94305, USA.
Commercial licenses are also available. To inquire about commercial licenses, please contact Uri Wilensky at uri@northwestern.edu.
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.
This model was converted to NetLogo as part of the projects: PARTICIPATORY SIMULATIONS: NETWORK-BASED DESIGN FOR SYSTEMS LEARNING IN CLASSROOMS and/or 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. Converted from StarLogoT to NetLogo, 2002.
<!-- 1998 2002 -->
1回应 2021-12-03 16:58:26 -
弦歌 (從吾所好與古為徒)
生命游戏 这个模型下的笔记,待考。 Is there a “critical density” - one at which all change and motion stops/eternal motion begins? 这个density指的是初始的密度。模型默认为35%,在帮助文件中有问临界密度。不知道什么意思。 原代码 globals [ erasing? ;; is the current draw-cells mouse click erasing or adding? ] patches-own [ living? ;; indicates if the cell is living live-neighb...2021-11-27 14:21:05
生命游戏 这个模型下的笔记,待考。
Is there a “critical density” - one at which all change and motion stops/eternal motion begins?
这个density指的是初始的密度。模型默认为35%,在帮助文件中有问临界密度。不知道什么意思。
原代码
globals [
erasing? ;; is the current draw-cells mouse click erasing or adding?
]
patches-own [
living? ;; indicates if the cell is living
live-neighbors ;; counts how many neighboring cells are alive
]
to setup-blank
clear-all
ask patches [ cell-death ]
reset-ticks
end
to setup-random
clear-all
ask patches
[ ifelse random-float 100.0 < initial-density
[ cell-birth ]
[ cell-death ] ]
reset-ticks
end
to cell-birth
set living? true
set pcolor fgcolor
end
to cell-death
set living? false
set pcolor bgcolor
end
to go
ask patches
[ set live-neighbors count neighbors with [living?] ]
;; Starting a new "ask patches" here ensures that all the patches
;; finish executing the first ask before any of them start executing
;; the second ask. This keeps all the patches in synch with each other,
;; so the births and deaths at each generation all happen in lockstep.
ask patches
[ ifelse live-neighbors = 3
[ cell-birth ]
[ if live-neighbors != 2
[ cell-death ] ] ]
tick
end
to draw-cells
ifelse mouse-down? [
if erasing? = 0 [
set erasing? [living?] of patch mouse-xcor mouse-ycor
]
ask patch mouse-xcor mouse-ycor [
ifelse erasing? [
cell-death
] [
cell-birth
]
]
display
] [
set erasing? 0
]
end
; Copyright 1998 Uri Wilensky.
; See Info tab for full copyright and license.
回应 2021-11-27 14:21:05
-
里面有些代码都前后不一致,也有打错了的。70页有个赋值语句里有个保留词写的是 turtles-here,到后面讲解的时候同样的位置就突然变成turtles,少了-here,不知道为什么前后不一致的,也没讲解或者任何的说明,如果两种表达在语法上都是没错的,但做出来模型就完全不一样,离谱。 还有不少那种语焉不详、解释不清,讲解不明的地方,我寻思这书也不是国外译介的,中国人讲中国话都讲不好。 讲真,不知道前言里那些极力推荐这本书...
2022-01-30 00:11:21 3人喜欢
-
弦歌 (從吾所好與古為徒)
## WHAT IS IT? This model is an attempt to mimic the flocking of birds. (The resulting motion also resembles schools of fish.) The flocks that appear in this model are not created or led in any way by special leader birds. Rather, each bird is following exactly the same set of rules, from which flocks emerge. ## HOW IT WORKS The birds follow three rules: "alignment", "separation", and "cohes... (1回应)2021-12-03 16:58:26
## WHAT IS IT?
This model is an attempt to mimic the flocking of birds. (The resulting motion also resembles schools of fish.) The flocks that appear in this model are not created or led in any way by special leader birds. Rather, each bird is following exactly the same set of rules, from which flocks emerge.
## HOW IT WORKS
The birds follow three rules: "alignment", "separation", and "cohesion".
"Alignment" means that a bird tends to turn so that it is moving in the same direction that nearby birds are moving.
"Separation" means that a bird will turn to avoid another bird which gets too close.
"Cohesion" means that a bird will move towards other nearby birds (unless another bird is too close).
When two birds are too close, the "separation" rule overrides the other two, which are deactivated until the minimum separation is achieved.
The three rules affect only the bird's heading. Each bird always moves forward at the same constant speed.
## HOW TO USE IT
First, determine the number of birds you want in the simulation and set the POPULATION slider to that value. Press SETUP to create the birds, and press GO to have them start flying around.
The default settings for the sliders will produce reasonably good flocking behavior. However, you can play with them to get variations:
Three TURN-ANGLE sliders control the maximum angle a bird can turn as a result of each rule.
VISION is the distance that each bird can see 360 degrees around it.
## THINGS TO NOTICE
Central to the model is the observation that flocks form without a leader.
There are no random numbers used in this model, except to position the birds initially. The fluid, lifelike behavior of the birds is produced entirely by deterministic rules.
Also, notice that each flock is dynamic. A flock, once together, is not guaranteed to keep all of its members. Why do you think this is?
After running the model for a while, all of the birds have approximately the same heading. Why?
Sometimes a bird breaks away from its flock. How does this happen? You may need to slow down the model or run it step by step in order to observe this phenomenon.
## THINGS TO TRY
Play with the sliders to see if you can get tighter flocks, looser flocks, fewer flocks, more flocks, more or less splitting and joining of flocks, more or less rearranging of birds within flocks, etc.
You can turn off a rule entirely by setting that rule's angle slider to zero. Is one rule by itself enough to produce at least some flocking? What about two rules? What's missing from the resulting behavior when you leave out each rule?
Will running the model for a long time produce a static flock? Or will the birds never settle down to an unchanging formation? Remember, there are no random numbers used in this model.
## EXTENDING THE MODEL
Currently the birds can "see" all around them. What happens if birds can only see in front of them? The `in-cone` primitive can be used for this.
Is there some way to get V-shaped flocks, like migrating geese?
What happens if you put walls around the edges of the world that the birds can't fly into?
Can you get the birds to fly around obstacles in the middle of the world?
What would happen if you gave the birds different velocities? For example, you could make birds that are not near other birds fly faster to catch up to the flock. Or, you could simulate the diminished air resistance that birds experience when flying together by making them fly faster when in a group.
Are there other interesting ways you can make the birds different from each other? There could be random variation in the population, or you could have distinct "species" of bird.
## NETLOGO FEATURES
Notice the need for the `subtract-headings` primitive and special procedure for averaging groups of headings. Just subtracting the numbers, or averaging the numbers, doesn't give you the results you'd expect, because of the discontinuity where headings wrap back to 0 once they reach 360.
## RELATED MODELS
* Moths
* Flocking Vee Formation
* Flocking - Alternative Visualizations
## CREDITS AND REFERENCES
This model is inspired by the Boids simulation invented by Craig Reynolds. The algorithm we use here is roughly similar to the original Boids algorithm, but it is not the same. The exact details of the algorithm tend not to matter very much -- as long as you have alignment, separation, and cohesion, you will usually get flocking behavior resembling that produced by Reynolds' original model. Information on Boids is available at https://web.archive.org/web/20210818090425/http://www.red3d.com/cwr/boids/.
## HOW TO CITE
If you mention this model or the NetLogo software in a publication, we ask that you include the citations below.
For the model itself:
* Wilensky, U. (1998). NetLogo Flocking model. http://ccl.northwestern.edu/netlogo/models/Flocking. Center for Connected Learning and Computer-Based Modeling, Northwestern University, Evanston, IL.
Please cite the NetLogo software as:
* Wilensky, U. (1999). NetLogo. http://ccl.northwestern.edu/netlogo/. Center for Connected Learning and Computer-Based Modeling, Northwestern University, Evanston, IL.
## COPYRIGHT AND LICENSE
Copyright 1998 Uri Wilensky.

This work is licensed under the Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License. To view a copy of this license, visit https://creativecommons.org/licenses/by-nc-sa/3.0/ or send a letter to Creative Commons, 559 Nathan Abbott Way, Stanford, California 94305, USA.
Commercial licenses are also available. To inquire about commercial licenses, please contact Uri Wilensky at uri@northwestern.edu.
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.
This model was converted to NetLogo as part of the projects: PARTICIPATORY SIMULATIONS: NETWORK-BASED DESIGN FOR SYSTEMS LEARNING IN CLASSROOMS and/or 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. Converted from StarLogoT to NetLogo, 2002.
<!-- 1998 2002 -->
1回应 2021-12-03 16:58:26 -
弦歌 (從吾所好與古為徒)
生命游戏 这个模型下的笔记,待考。 Is there a “critical density” - one at which all change and motion stops/eternal motion begins? 这个density指的是初始的密度。模型默认为35%,在帮助文件中有问临界密度。不知道什么意思。 原代码 globals [ erasing? ;; is the current draw-cells mouse click erasing or adding? ] patches-own [ living? ;; indicates if the cell is living live-neighb...2021-11-27 14:21:05
生命游戏 这个模型下的笔记,待考。
Is there a “critical density” - one at which all change and motion stops/eternal motion begins?
这个density指的是初始的密度。模型默认为35%,在帮助文件中有问临界密度。不知道什么意思。
原代码
globals [
erasing? ;; is the current draw-cells mouse click erasing or adding?
]
patches-own [
living? ;; indicates if the cell is living
live-neighbors ;; counts how many neighboring cells are alive
]
to setup-blank
clear-all
ask patches [ cell-death ]
reset-ticks
end
to setup-random
clear-all
ask patches
[ ifelse random-float 100.0 < initial-density
[ cell-birth ]
[ cell-death ] ]
reset-ticks
end
to cell-birth
set living? true
set pcolor fgcolor
end
to cell-death
set living? false
set pcolor bgcolor
end
to go
ask patches
[ set live-neighbors count neighbors with [living?] ]
;; Starting a new "ask patches" here ensures that all the patches
;; finish executing the first ask before any of them start executing
;; the second ask. This keeps all the patches in synch with each other,
;; so the births and deaths at each generation all happen in lockstep.
ask patches
[ ifelse live-neighbors = 3
[ cell-birth ]
[ if live-neighbors != 2
[ cell-death ] ] ]
tick
end
to draw-cells
ifelse mouse-down? [
if erasing? = 0 [
set erasing? [living?] of patch mouse-xcor mouse-ycor
]
ask patch mouse-xcor mouse-ycor [
ifelse erasing? [
cell-death
] [
cell-birth
]
]
display
] [
set erasing? 0
]
end
; Copyright 1998 Uri Wilensky.
; See Info tab for full copyright and license.
回应 2021-11-27 14:21:05
-
里面有些代码都前后不一致,也有打错了的。70页有个赋值语句里有个保留词写的是 turtles-here,到后面讲解的时候同样的位置就突然变成turtles,少了-here,不知道为什么前后不一致的,也没讲解或者任何的说明,如果两种表达在语法上都是没错的,但做出来模型就完全不一样,离谱。 还有不少那种语焉不详、解释不清,讲解不明的地方,我寻思这书也不是国外译介的,中国人讲中国话都讲不好。 讲真,不知道前言里那些极力推荐这本书...
2022-01-30 00:11:21 3人喜欢
-
弦歌 (從吾所好與古為徒)
## WHAT IS IT? This model is an attempt to mimic the flocking of birds. (The resulting motion also resembles schools of fish.) The flocks that appear in this model are not created or led in any way by special leader birds. Rather, each bird is following exactly the same set of rules, from which flocks emerge. ## HOW IT WORKS The birds follow three rules: "alignment", "separation", and "cohes... (1回应)2021-12-03 16:58:26
## WHAT IS IT?
This model is an attempt to mimic the flocking of birds. (The resulting motion also resembles schools of fish.) The flocks that appear in this model are not created or led in any way by special leader birds. Rather, each bird is following exactly the same set of rules, from which flocks emerge.
## HOW IT WORKS
The birds follow three rules: "alignment", "separation", and "cohesion".
"Alignment" means that a bird tends to turn so that it is moving in the same direction that nearby birds are moving.
"Separation" means that a bird will turn to avoid another bird which gets too close.
"Cohesion" means that a bird will move towards other nearby birds (unless another bird is too close).
When two birds are too close, the "separation" rule overrides the other two, which are deactivated until the minimum separation is achieved.
The three rules affect only the bird's heading. Each bird always moves forward at the same constant speed.
## HOW TO USE IT
First, determine the number of birds you want in the simulation and set the POPULATION slider to that value. Press SETUP to create the birds, and press GO to have them start flying around.
The default settings for the sliders will produce reasonably good flocking behavior. However, you can play with them to get variations:
Three TURN-ANGLE sliders control the maximum angle a bird can turn as a result of each rule.
VISION is the distance that each bird can see 360 degrees around it.
## THINGS TO NOTICE
Central to the model is the observation that flocks form without a leader.
There are no random numbers used in this model, except to position the birds initially. The fluid, lifelike behavior of the birds is produced entirely by deterministic rules.
Also, notice that each flock is dynamic. A flock, once together, is not guaranteed to keep all of its members. Why do you think this is?
After running the model for a while, all of the birds have approximately the same heading. Why?
Sometimes a bird breaks away from its flock. How does this happen? You may need to slow down the model or run it step by step in order to observe this phenomenon.
## THINGS TO TRY
Play with the sliders to see if you can get tighter flocks, looser flocks, fewer flocks, more flocks, more or less splitting and joining of flocks, more or less rearranging of birds within flocks, etc.
You can turn off a rule entirely by setting that rule's angle slider to zero. Is one rule by itself enough to produce at least some flocking? What about two rules? What's missing from the resulting behavior when you leave out each rule?
Will running the model for a long time produce a static flock? Or will the birds never settle down to an unchanging formation? Remember, there are no random numbers used in this model.
## EXTENDING THE MODEL
Currently the birds can "see" all around them. What happens if birds can only see in front of them? The `in-cone` primitive can be used for this.
Is there some way to get V-shaped flocks, like migrating geese?
What happens if you put walls around the edges of the world that the birds can't fly into?
Can you get the birds to fly around obstacles in the middle of the world?
What would happen if you gave the birds different velocities? For example, you could make birds that are not near other birds fly faster to catch up to the flock. Or, you could simulate the diminished air resistance that birds experience when flying together by making them fly faster when in a group.
Are there other interesting ways you can make the birds different from each other? There could be random variation in the population, or you could have distinct "species" of bird.
## NETLOGO FEATURES
Notice the need for the `subtract-headings` primitive and special procedure for averaging groups of headings. Just subtracting the numbers, or averaging the numbers, doesn't give you the results you'd expect, because of the discontinuity where headings wrap back to 0 once they reach 360.
## RELATED MODELS
* Moths
* Flocking Vee Formation
* Flocking - Alternative Visualizations
## CREDITS AND REFERENCES
This model is inspired by the Boids simulation invented by Craig Reynolds. The algorithm we use here is roughly similar to the original Boids algorithm, but it is not the same. The exact details of the algorithm tend not to matter very much -- as long as you have alignment, separation, and cohesion, you will usually get flocking behavior resembling that produced by Reynolds' original model. Information on Boids is available at https://web.archive.org/web/20210818090425/http://www.red3d.com/cwr/boids/.
## HOW TO CITE
If you mention this model or the NetLogo software in a publication, we ask that you include the citations below.
For the model itself:
* Wilensky, U. (1998). NetLogo Flocking model. http://ccl.northwestern.edu/netlogo/models/Flocking. Center for Connected Learning and Computer-Based Modeling, Northwestern University, Evanston, IL.
Please cite the NetLogo software as:
* Wilensky, U. (1999). NetLogo. http://ccl.northwestern.edu/netlogo/. Center for Connected Learning and Computer-Based Modeling, Northwestern University, Evanston, IL.
## COPYRIGHT AND LICENSE
Copyright 1998 Uri Wilensky.

This work is licensed under the Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License. To view a copy of this license, visit https://creativecommons.org/licenses/by-nc-sa/3.0/ or send a letter to Creative Commons, 559 Nathan Abbott Way, Stanford, California 94305, USA.
Commercial licenses are also available. To inquire about commercial licenses, please contact Uri Wilensky at uri@northwestern.edu.
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.
This model was converted to NetLogo as part of the projects: PARTICIPATORY SIMULATIONS: NETWORK-BASED DESIGN FOR SYSTEMS LEARNING IN CLASSROOMS and/or 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. Converted from StarLogoT to NetLogo, 2002.
<!-- 1998 2002 -->
1回应 2021-12-03 16:58:26 -
弦歌 (從吾所好與古為徒)
生命游戏 这个模型下的笔记,待考。 Is there a “critical density” - one at which all change and motion stops/eternal motion begins? 这个density指的是初始的密度。模型默认为35%,在帮助文件中有问临界密度。不知道什么意思。 原代码 globals [ erasing? ;; is the current draw-cells mouse click erasing or adding? ] patches-own [ living? ;; indicates if the cell is living live-neighb...2021-11-27 14:21:05
生命游戏 这个模型下的笔记,待考。
Is there a “critical density” - one at which all change and motion stops/eternal motion begins?
这个density指的是初始的密度。模型默认为35%,在帮助文件中有问临界密度。不知道什么意思。
原代码
globals [
erasing? ;; is the current draw-cells mouse click erasing or adding?
]
patches-own [
living? ;; indicates if the cell is living
live-neighbors ;; counts how many neighboring cells are alive
]
to setup-blank
clear-all
ask patches [ cell-death ]
reset-ticks
end
to setup-random
clear-all
ask patches
[ ifelse random-float 100.0 < initial-density
[ cell-birth ]
[ cell-death ] ]
reset-ticks
end
to cell-birth
set living? true
set pcolor fgcolor
end
to cell-death
set living? false
set pcolor bgcolor
end
to go
ask patches
[ set live-neighbors count neighbors with [living?] ]
;; Starting a new "ask patches" here ensures that all the patches
;; finish executing the first ask before any of them start executing
;; the second ask. This keeps all the patches in synch with each other,
;; so the births and deaths at each generation all happen in lockstep.
ask patches
[ ifelse live-neighbors = 3
[ cell-birth ]
[ if live-neighbors != 2
[ cell-death ] ] ]
tick
end
to draw-cells
ifelse mouse-down? [
if erasing? = 0 [
set erasing? [living?] of patch mouse-xcor mouse-ycor
]
ask patch mouse-xcor mouse-ycor [
ifelse erasing? [
cell-death
] [
cell-birth
]
]
display
] [
set erasing? 0
]
end
; Copyright 1998 Uri Wilensky.
; See Info tab for full copyright and license.
回应 2021-11-27 14:21:05
论坛 · · · · · ·
在这本书的论坛里发言当前版本有售 · · · · · ·
-
限时抢
以下书单推荐 · · · · · · ( 全部 )
- 集智俱乐部相关出版物 (168 Hours)
- 读完的书 (玉壶)
- 演化/集群 (纳坦利)
- 图灵 (巴恩与木)
- 未评分书 (北风)
谁读这本书?
二手市场
订阅关于NetLogo多主体建模入门的评论:
feed: rss 2.0
0 有用 Amadeus 2022-02-28 11:11:19
其实就是集智学园的课程配套,讲得比较清楚。netlogo语法虽然怪,但两三天还没上手说明学的不对。每次我都是听课前看PPT把程序自己写一遍然后听课,不过初学几天就写boid模型,对我这种编程能力很烂的人还是非常有难度
0 有用 初兮 2022-06-07 10:36:24
很少在豆瓣标记这类书😂
0 有用 帅椰椰王子 2022-07-16 23:05:21
学习模拟的第一本书✓
0 有用 帅椰椰王子 2022-07-16 23:05:21
学习模拟的第一本书✓
0 有用 初兮 2022-06-07 10:36:24
很少在豆瓣标记这类书😂
0 有用 Amadeus 2022-02-28 11:11:19
其实就是集智学园的课程配套,讲得比较清楚。netlogo语法虽然怪,但两三天还没上手说明学的不对。每次我都是听课前看PPT把程序自己写一遍然后听课,不过初学几天就写boid模型,对我这种编程能力很烂的人还是非常有难度