netlogo实现相向行驶的小汽车(共3页).docx
-
资源ID:5439873
资源大小:45.40KB
全文页数:3页
- 资源格式: DOCX
下载积分:20金币
快捷下载
会员登录下载
微信登录下载
三方登录下载:
微信扫一扫登录
友情提示
2、PDF文件下载后,可能会被浏览器默认打开,此种情况可以点击浏览器菜单,保存网页到桌面,就可以正常下载了。
3、本站不支持迅雷下载,请使用电脑自带的IE浏览器,或者360浏览器、谷歌浏览器下载即可。
4、本站资源下载后的文档和图纸-无水印,预览文档经过压缩,下载后原文更清晰。
5、试题试卷类文档,如果标题没有明确说明有答案则都视为没有答案,请知晓。
|
netlogo实现相向行驶的小汽车(共3页).docx
精选优质文档-倾情为你奉上在街道上行驶的汽车要求:1. 汽车按照上下行车道行驶2. 汽车的加速度和减速度,通过滑动空间来调节。行驶过程中不发生碰撞事件。3. 能够时时检测汽车在行驶过程中的最大速度和最小速度。4. 绘制某一选定汽车在整个运行期间的速度曲线globals sample-car turtles-own speed speed-limit speed-min to setup clear-all ask patches setup-road setup-cars reset-ticksendto setup-road if (pycor < 20) and (pycor > 0) set pcolor white endto setup-cars set-default-shape turtles "car" crt number-of-cars set color blue set size 1 set shape "car" setxy random-xcor random-ycor set heading 90 ; set initial speed to be in range 0.1 to 1.0 set speed 0.1 + random-float .9 set ycor 2 set ycor random 2 + 6 set speed 0.1 + random-float .9 set speed-limit 1 set speed-min 0 separate-cars crt number-of-car2s set color orange set size 1 set shape "car top" setxy random-xcor random-ycor set heading 270 ; set initial speed to be in range 0.1 to 1.0 set ycor random 2 set ycor random 2 + 17 set speed 0.1 + random-float .9 set speed-limit 1 set speed-min 0 separate-cars set sample-car one-of turtles ask sample-car set color red ask patches withpycor = 10 and pxcor >= 0 and pxcor <= 50 set pcolor 122 endto separate-cars if any? other turtles-here fd 1 separate-cars endto go ask turtles let car-ahead one-of turtles-on patch-ahead 1 ifelse car-ahead != nobody slow-down-car car-ahead speed-up-car if speed < speed-min set speed speed-min if speed > speed-limit set speed speed-limit fd speed tickendto slow-down-car car-ahead set speed speed of car-ahead - decelerationendto speed-up-car set speed speed + accelerationend专心-专注-专业