Bounce Lottery

Bounce Lottery preview image

1 collaborator

Dsc_0179_-_version_2 Jacob Wilkes (Author)

Tags

bounce 

"this is the name of the original model"

Tagged by Jacob Wilkes almost 12 years ago

jacob 

"this is the co-author of the modification"

Tagged by Jacob Wilkes almost 12 years ago

meng 

"this is the co-author of the modification"

Tagged by Jacob Wilkes almost 12 years ago

Parent of 1 model: Bounce Lottery
Model group LS426_2013 | Visible to everyone | Changeable by everyone
Model was written in NetLogo 5.0beta1 • Viewed 311 times • Downloaded 32 times • Run 0 times
Download the 'Bounce Lottery' modelDownload this modelEmbed this model

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

to setup
  clear-all
  set-default-shape turtles "circle"
  draw-walls
  crt 5                                 ;; create some turtles
    [ randomize ]                       ;; place them randomly
  reset-ticks
end 

; draws the boundaries (walls) of the "billiard table"

to draw-walls
  ; draw left and right walls
  ask patches with [abs pxcor = max-pxcor]
    [ set pcolor blue ]
  ; draw top and bottom walls
  ask patches with [abs pycor = max-pycor]
    [ set pcolor blue ]
end 

; set random location

to randomize
  setxy random-xcor random-ycor
  if pcolor = blue       ; if it's on the wall...
    [ randomize ]        ; ...try again
end 

to go
  ask turtles [
    ifelse leave-trace?             ;; the turtle puts its pen up or down depending on the
      [ pd ]                        ;; value of the LEAVE-TRACE? switch
      [ pu ]
    bounce
    fd 0.1
  ]
  tick
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 incidence

to bounce  ;; turtle procedure
  ; check: hitting left or right wall?
  if abs [pxcor] of patch-ahead 0.1 = max-pxcor
    ; if so, reflect heading around x axis
    [ set heading (- heading) ]
  ; check: hitting top or bottom wall?
  if abs [pycor] of patch-ahead 0.1 = max-pycor
    ; if so, reflect heading around y axis
    [ set heading (180 - heading) ]
end 


; Public Domain:
; To the extent possible under law, Uri Wilensky has waived all
; copyright and related or neighboring rights to this model.

There are 2 versions of this model.

Uploaded by When Description Download
Jacob Wilkes almost 12 years ago original bounce model Download this version
Jacob Wilkes almost 12 years ago Initial upload Download this version

Attached files

File Type Description Last updated
Bounce Lottery.png preview Preview for 'Bounce Lottery' over 11 years ago, by Jacob Wilkes Download

This model does not have any ancestors.

Children:

Graph of models related to 'Bounce Lottery'