📄 !!!---fixmodel2.nlogo
字号:
to setup ca set-default-shape turtles "circle" draw-walls cct 5 ;; create some turtles [ randomize ] ;; set random coordinates and random directionend; draws the boundaries (walls) of the "billiard table"to draw-wall ; draw left and right walls ask patches with [abs pxcor = screen-edge-x] [ set pcolor blue ] ; draw top and bottom walls ask patches with [abs pycor = screen-edge-y] [ set pcolor blue ]end; set random coordinates and random directionto randomize setxy (random-float screen-size-x) (random-float screen-size-y) rt random-float 360 if pcolor = blue ; if it's on the wall... [ randomize ] ; ...try againendto go ;; turtle procedure every 0.5 - speed / 10 [ ifelse leave-trace? ;; the turtle puts its pen up or down depending on the [ pd ] ;; value of the LEAVE-TRACE? switch [ pu ] bounce fd 1 ]end;; this procedure checks the coordinates and makes the turtles;; reflect according to the law that the angle of reflection is ;; equal to the angle of incidenceto bounce ;; turtle procedure ; check: hitting left or right wall? if (abs pxcor-of patch-ahead 1 = screen-edge-x) ; if so, reflect heading around x axis [ set heading (- heading) ] ; check: hitting top or bottom wall? if (abs pycor-of patch-ahead 1 = screen-edge-y) ; if so, reflect heading around y axis [ set heading (180 - heading) ]end@#$#@#$#@GRAPHICS-WINDOW2931063136920208.0110111CC-WINDOW7115286410Command CenterBUTTON701012843NILsetupNIL1TOBSERVERTBUTTON1411019643gogoT1TTURTLETSWITCH216415097leave-trace?leave-trace?11-1000SLIDER1636425597SpeedSpeed0.05.04.70.11NIL@#$#@#$#@WHAT IS IT?------------This demo shows how to make turtles bounce off the walls.@#$#@#$#@defaulttrue0Polygon -7566196 true true 150 5 40 250 150 205 260 250circletrue0Circle -7566196 true true 10 10 283@#$#@#$#@NetLogo 2.0.0@#$#@#$#@setupset leave-trace? truerepeat 40 [ ask turtles [ go ] ]@#$#@#$#@@#$#@#$#@
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -