Courses/CS 461/Winter 2006/Nghia Phan/Nghia Phan/Week 1
From CSWiki
< Courses | CS 461 | Winter 2006 | Nghia Phan
Contents |
[edit] My Information
- Email: nghiangocphan@gmail.com
[edit] Exercise 1
[edit] Description
This is a simple model that shows bouncing balls in a box. The extension of this model can simulate the following:
- Interaction of the molecules in the closed space
- Using a bouncing ball to trace a graph of any mathematical equations
- Soccer game simular to soccer.jar
- etc.
[edit] Instruction on installation
- Create buttons called "setup" and "go" (Set "go" button to forever)
- Create a slider called "number"
[edit] Code
globals [step]
;;This is the procedure to setup the model
to setup
ca
setup-turtles
end
;;******************************************************************************************************
;;This is the procedure to setup the turtles
to setup-turtles
crt number
ask turtles
[
set shape "circle"
fd (random screen-edge-x)
if (shade-of? black color)
[ set color white ]
]
end
;;******************************************************************************************************
to go
ask turtles
[
set step 1
if (pxcor-of patch-ahead 1 >= screen-edge-x or pxcor-of patch-ahead 1 <= (- screen-edge-x)
or pycor-of patch-ahead 1 >= screen-edge-y or pycor-of patch-ahead 1 <= (- screen-edge-y))
[
set heading (random 360)
set step 0
]
fd step
]
end
;;******************************************************************************************************
[edit] Comments
So far, I like using Netlogo. However, I am still not comfortable with its syntax. Especially, you have to distinquish the primitive functions between turtle, patch, observer, and etc. Beside these, I think Netlogo can be very usefull in education. We can use Netlogo to build any model to help the students better understand of what they are studying.

