No preview image

1 collaborator


(This model has yet to be categorized with any tags)
Model group LS426-2012 | Visible to everyone | Changeable by group members (LS426-2012)
Model was written in NetLogo 5.0RC7 • Viewed 933 times • Downloaded 67 times • Run 0 times
Download the 'Airports?' 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

  patches-own ;; this way turtles can recognize which patches are airports and which aren't
 [airport? ;; patches are either airports (airport? = true) or not (airport? = false)
 num-of-flights ;; so airports keep track of how many turtles have departed from them
 airport-id] ;; this helps us with the plotting.  the airport-id will be on the x-axis and the number of flights that have departed from each airport (corresponding to it's airport-id) will be on the y-axis)

globals [airport-count] ;; to help us keep track of the total number of airports and to keep the airport-id procedure increasing by 1 for each new airport created

to setup
  set airport-count 0 ;; because there are no airports yet!
 ask patches [set airport? false] ;; to make all the black patches not airports
    repeat initial-airports ;; use the slider to set # of initial airports
    [ask patch  random-pxcor random-pycor 
    [ set pcolor green 
      set num-of-flights 0  ;; because no flights have departed yet
      set airport-id airport-count ;; so the first airport created has an airport-id of 0
      set airport-count airport-count + 1] ] ;; we need to increase the airport-count so that next time an airport is created it will have a higher id number
    ask patches with [pcolor = green] [set airport? true] ;; to make the green patches be recognizable to turtles as airports
    crt initial-airports [set color red setxy random-xcor random-ycor ] ;; still working on how to get the airplanes to appear at same location as the airports
    set-default-shape turtles "airplane" ;; for fun and authenticity

to go
  ask turtles [fly] ;; asks turtles to fly to an airport
  new-airport ;; creates new airports after a set # of ticks

to new-airport
  if remainder ticks 25 = 0 ;; this is asking if the total number of ticks divided by twenty five leaves no remainder. this way this procedure will happen only every 25 ticks
  [ask patch  random-pxcor random-pycor 
    [ set pcolor green  set num-of-flights  0  
      set airport-id airport-count 
      set airport-count airport-count + 1]  ;; makes a new airport with a new airport-id
    crt 1 [set color red setxy random-xcor random-ycor] ;; and a new airplane
    ask patches with [pcolor = green] 
    [set airport? true] ]

to fly
 pd ;; so it leaves a nice path we can see

to land  ;; turtle procedure
  ifelse airport? 
  [depart] ;; if the patch the turtle is on right now is an airport, it's time to depart and find a new airport
  [ let airports patches with [airport? = true]  ;; this let command tells the turtles that all patches that answer true to airport? are in fact airports
   face one-of airports ;; this tells the turtle to choose just one of the patches it now knows it an airport to face (changes turtle's heading so it heads toward the airport)
   while [airport? = false] [ fd 1 ] ]  ;; as long as the turtle is on a patch that is not an airport it will keep moving forward in it's given heading. 

to depart
 set heading random 170 ;; just to add some randomness
  ask patch-here [set num-of-flights num-of-flights + 1]
 fd 1
land ;; so the turtle will continue to look for another airport

There are 3 versions of this model.

Uploaded by When Description Download
Laurel Schrementi over 12 years ago most recent version with plane image! Download this version
Laurel Schrementi over 12 years ago This is our most current version! Download this version
Laurel Schrementi over 12 years ago Initial upload Download this version

Attached files

No files

This model does not have any ancestors.

This model does not have any descendants.