puzzle3

No preview image

1 collaborator

Default-person soheir othman (Author)

Tags

(This model has yet to be categorized with any tags)
Visible to everyone | Changeable by the author
Model was written in NetLogo 4.1.2 • Viewed 93 times • Downloaded 19 times • Run 0 times
Download the 'puzzle3' 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?

This example sets up a box that can be placed anywhere in the world. It is one patch thick.

Comments and Questions

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

Click to Run Model

;; declare a global variable, halfedge, to be used when the box center is at (0,0)

globals [halfedge]

;; setup procedure for case where point (0,0) is lower left corner of Box
;;note slider that sets the size of the box.

to setup-corner
;  ca                                              ;; clear everything
  ask patches[
    ;; if patches are between (0,0) to (3,edge)...
    if ( pxcor = 0 and pycor >= 0 and pycor <= edge )
      [set pcolor red]                                 ;; ... draws left edge in red
    ;; if patches are between (edge,0) to (edge,edge)...
    if ( pxcor = edge and pycor >= 0 and pycor <= edge )
      [set pcolor red]                                 ;; ... draws right edge in red
    ;; if patches are between (0,0) to (edge,0)...
    if ( pycor = 0 and pxcor >= 0 and pxcor <= edge )
      [set pcolor red]                                 ;; ... draws bottom edge in red
    ;; if patches are between (0,edge) to (edge,edge)...
    if ( pycor = edge and pxcor >= 0 and pxcor <= edge )
      [set pcolor red]                                 ;; ... draws upper edge in red
    ]
end 


;; setup procedure for case where point (0,0) is in the center of Box

to setup-center
  ;ca                                              ;; clear everything
  ;; set halfedge as edge divided by two. in case edge is an odd number,
  ;; halfedge get the integer value of the division.
  set halfedge int (edge / 2)
  ask patches[
    ;; if patches are between (-halfedge,-halfedge) to (-halfedge,halfedge)...
    if (pxcor = (- halfedge) and pycor >= (- halfedge) and pycor <= (0 + halfedge) )
      [set pcolor blue]                                ;; ... draws left edge in blue
    ;; if patches are between (halfedge,-halfedge) to (halfedge,halfedge)...
    if ( pxcor = (0 + halfedge) and pycor >= (- halfedge) and pycor <= (0 + halfedge) )
      [set pcolor blue]                                ;; ... draws right edge in blue
    ;; if patches are between (-halfedge,-halfedge) to (halfedge,-halfedge)...
    if ( pycor = (- halfedge) and pxcor >= (- halfedge) and pxcor <= (0 + halfedge) )
      [set pcolor blue]                                ;; ... draws bottom edge in blue
    ;; if patches are between (-halfedge,halfedge) to (halfedge,halfedge)...
    if ( pycor = (0 + halfedge) and pxcor >= (- halfedge) and pxcor <= (0 + halfedge) )
      [set pcolor blue]                                ;; ... draws upper edge in blue
    ]
end 

to example
  clear-all                                              ;; clear everything
  ask patches[
        if ( pxcor = 0 and pycor >= 0  )
      [set pcolor yellow]                              
   
    if ( pxcor = 10 and pycor >= 20  )
      [set pcolor red]                              
    ]
end 

to example1
; ca                                              ;; clear everything
  ask patches[
  ;;  if patches are between (0,0) to (3,edge)...
    if ( pxcor = 0 and pycor >= 0  )
      [set pcolor yellow]                                
  ;; if patches are between (edge,0) to (edge,edge)...
    if ( pxcor = 10 and pycor >= 20  )
      [set pcolor red]                                
   ;; if patches are between (0,0) to (edge,0)...
    if ( pycor = 0 and pxcor >= 0 and pxcor <= edge )
      [set pcolor red]                                
   ;;  if patches are between (0,edge) to (edge,edge)...
    if ( pycor = edge and pxcor >= 0 and pxcor <= edge )
     [set pcolor red]                                 
    ]
end 

There is only one version of this model, created about 13 years ago by soheir othman.

Attached files

No files

This model does not have any ancestors.

This model does not have any descendants.