# ANath Physics Final Project

No preview image

Model was written in NetLogo 5.3.1
•
Viewed 89 times
•
Downloaded 8 times
•
Run 0 times

Do you have questions or comments about this model? Ask them here! (You'll first need to log in.)

## Comments and Questions

Please start the discussion about this model!
(You'll first need to log in.)

Click to Run Model

Globals [ hillHeight cliffHeight finalVelocity pathEndX pathEndY hillBottomX hillBottomY target distanceTravelled ] breed [ masses mass ] to setup ca make-world show-target make-mass calculate-finalVelocity end to make-world ask patches [ set pcolor white ] set hillHeight (random 10) set cliffHeight (random 10) while [ hillheight + cliffHeight < 12 ] [ set hillHeight (random 10) set cliffHeight (random 10) ] change-hill-height change-cliff-height make-hill-cliff end to change-hill-height if changeHillHeight? [ set hillHeight userHillHeight ] end to change-cliff-height if changeCliffHeight? [ set cliffHeight userCliffHeight ] end to make-hill-cliff create-turtles 1 [ set color black setxy -18 (hillHeight + cliffHeight - 10) pen-down create-path die ] create-turtles 1 [ set color white setxy -18 (hillHeight + cliffHeight - 10) facexy xcor 11 pen-down while [ xcor = -18 and ycor < (hillHeight * cos(abs(xcor) * 10) * -1)] [ fd 1 set ycor (ycor + 1) ] die ] end to create-path while [ xcor < 0 and ycor > 1 ] [ set ycor (hillHeight * cos(abs(xcor) * 10) * -1) set xcor (xcor + .01) ] facexy 0 ycor fd 3 rt 90 fd cliffHeight lt 90 fd 26 set pathEndX xcor set pathEndY ycor end to show-target set target (random (pathEndX - 2)) ask patches [ if pxcor >= target and pxcor <= (target + 2) and pycor < pathEndY + 1 and pycor > pathEndY [ set pcolor green ] ] end to make-mass set-default-shape masses "circle" create-masses 1 [ set color red set size 1 setxy -18 (hillHeight * cos(180) * -1 + .5) ] end to calculate-finalVelocity set finalVelocity sqrt (2 * 9.8 * hillHeight + (initialVelocity) ^ 2) end to go ask masses [ go-down-hill travel determine-result ] end to go-down-hill while [ xcor < 0 and ycor > 1.5 ] [ set ycor (hillHeight * cos(abs(xcor) * 10) * -1 + .5) set xcor (xcor + .01) wait .001 ] facexy 1 ycor set hillBottomX xcor set hillBottomY ycor while [ xcor < (hillBottomX + 3)] [ fd .01 wait .001 ] end to travel while [ xcor < 20 and ycor >= pathEndY ] [ set distanceTravelled (finalVelocity * sqrt (2 * (hillBottomY - pathEndY) / 9.8)) set ycor (abs(1 / (distanceTravelled + 7))) * (- ((xcor - hillBottomX - 3) ^ 2)) + 1.5 set xcor (xcor + .01) wait .001 ] end to determine-result ifelse pcolor = green [ output-print "You Win!!" ] [ output-print "Try Again!" ] end to reset ask masses [ die ] ask patches [ set pcolor white ] create-turtles 1 [ set color white setxy -18 (hillHeight + cliffHeight - 10) pen-down create-path die ] change-hill-height change-cliff-height make-hill-cliff ask patches [ if pxcor >= target and pxcor <= (target + 2) and pycor < pathEndY + 1 and pycor > pathEndY [ set pcolor green ] ] make-mass ask masses [ set hillBottomX xcor set hillBottomY ycor ] calculate-finalVelocity end

There is only one version of this model, created over 3 years ago by Anusua Nath.

## Attached files

No files

This model does not have any ancestors.

This model does not have any descendants.