Perspective Example

Perspective Example preview image

1 collaborator

Uri_dolphin3 Uri Wilensky (Author)

Tags

(This model has yet to be categorized with any tags)
Model group CCL | Visible to everyone | Changeable by group members (CCL)
Model was written in NetLogo 5.0.4 • Viewed 152 times • Downloaded 37 times • Run 0 times
Download the 'Perspective Example' 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

;; this code is from Bounce Example. The perspective code is all in the buttons.

to setup
  clear-all
  set-default-shape turtles "circle"
  draw-walls
  crt 20                                ;; create some turtles
    [ randomize ]                       ;; set random coordinates and random direction
  reset-ticks
end 

; draws the boundaries of the billiard table

to draw-walls
  ask patches with [abs pxcor = max-pxcor]
    [ set pcolor blue ]
  ask patches with [abs pycor = max-pycor]
    [ set pcolor blue ]
end 

; set random coordinates

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 

;; check the turtles coordinates and bounce it if needed

to bounce  ;; turtle procedure
  if abs [pxcor] of patch-ahead 0.1 = max-pxcor
    [ set heading (- heading) ]
  if abs [pycor] of patch-ahead 0.1 = max-pycor
    [ 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 9 versions of this model.

Uploaded by When Description Download
Uri Wilensky over 11 years ago Updated to NetLogo 5.0.4 Download this version
Uri Wilensky about 12 years ago Updated version tag Download this version
Uri Wilensky almost 13 years ago Updated to NetLogo 5.0 Download this version
Uri Wilensky over 14 years ago Updated from NetLogo 4.1 Download this version
Uri Wilensky over 14 years ago Updated from NetLogo 4.1 Download this version
Uri Wilensky over 14 years ago Updated from NetLogo 4.1 Download this version
Uri Wilensky over 14 years ago Updated from NetLogo 4.1 Download this version
Uri Wilensky over 14 years ago Model from NetLogo distribution Download this version
Uri Wilensky over 14 years ago Perspective Example Download this version

Attached files

File Type Description Last updated
Perspective Example.png preview Preview for 'Perspective Example' over 11 years ago, by Uri Wilensky Download

This model does not have any ancestors.

This model does not have any descendants.