Patch Coordinates Example

Patch Coordinates 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 1524 times • Downloaded 106 times • Run 0 times
Download the 'Patch Coordinates 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.)


WHAT IS IT?

The turtle goes forward "distance-of-travel" and returns to (start-x, start-y). The green patch is the center patch upon which there is a turtle at (start-x, start-y), and the patch "distance-of-travel" away from that center will flash as the turtle passes through it.

This is an illustration of the difference between a radius of 1 and the distance from patch to patch. Distance in NetLogo is measured in patches, and so "forward 1" for a turtle means for it to go forward exactly the length of one side of a patch. However, as illustrated by the pythagorean theorem, the distance across the diagonal of a patch is root 2 (around 1.414). As such, there are points and headings of a turtle within a patch from which going forward 1 will not result in changing the patch on which the turtle lands.

HOW IT WORKS

There is a searcher turtle that travels clockwise at distance-of-travel from the center (start-x,start-y). The searcher returns to the center each tick and goes forward distance-of-travel. distance-of-travel, start-x, and start-y are all sliders. The center turtle simply marks the center at (start-x, start-y).

HOW TO USE IT

Press setup, then press go. You can change the sliders while the model is running.

THINGS TO NOTICE

Patches are laid out in NetLogo such that they span from pxcor - 0.5 on the left to an open boundary at pxcor + 0.5. The same equation is used for pycor. That is, for patch 3 1, it's actual real range is ([-3.5,2.5), [-1.5,-0.5)). This is illustrated in the model.

THINGS TO TRY

Try changing start-x to 0.5 and start-y to 0.5. Where is the green patch now? Now try changing start-x to -0.5 and start-y to -0.5. When the start-x = -0.5 and start-y = -0.5, the turtle is centered on patch 0 0. When the start-x = 0.5 and start-y = 0.5, the turtle is centered on patch 1 1.

EXTENDING THE MODEL

You could change the model such that there are a "halo" of turtles always distance-of-travel from the center.

Comments and Questions

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

Click to Run Model

breed [centers center]
breed [searchers searcher]

to setup
  clear-all
  ask patches [ set pcolor gray ]
  ask patch start-x start-y [ set pcolor green ]
  create-searchers 1
  [
    set heading 0
    set color red
    set size 0.2
    set shape "circle"
    setxy start-x start-y
  ]
  create-centers 1
  [
    set color blue
    set size 0.1
    set shape "circle"
    setxy start-x start-y
  ]
  reset-ticks
end 

to go
  ;; this is to reset the patches to gray so it changes
  ;; when you move the start-x or start-y slider
  ask patches [ set pcolor gray ]

  ;; this resets the center turtle to the point indicated by the sliders
  ask centers [ setxy start-x start-y ]

  ask searchers
  [
    setxy start-x start-y    ;; return to center
    set pcolor green
    rt 5                     ;; it goes clockwise in 5 degree increments
    fd distance-of-travel    ;; go back out to edge of circle
    set pcolor black
  ]
  tick
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 10 versions of this model.

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

Attached files

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

This model does not have any ancestors.

This model does not have any descendants.