Area Gradients Simulation
Model was written in NetLogo 6.2.0
•
Viewed 185 times
•
Downloaded 10 times
•
Run 0 times
Do you have questions or comments about this model? Ask them here! (You'll first need to log in.)
Info tab cannot be displayed because of an encoding error
Comments and Questions
Please start the discussion about this model!
(You'll first need to log in.)
Click to Run Model
;;Title: Exam project ;; Student: Constant Patrice KODJA ADJOVI ;; S21 ;; Model: This project goal is to implement the gradien paths based on the areas' elevation in altitude (gradlevel variable) ;; Please do reduce the ticks speed in order the experience slow move. ;;Notice: ;;Gradien_0_XPosition and Gradien_0_YPosition are values that provide an offset from min-pxcor and min-pycor. breed [ originTurtles originTurtle ] ;; Turtle to be placed at the most min point (area with lower gradien) breed [ fieldTurtles fieldTurtle ] ;; Turtles in the field which will run to grafien 0 (gradlevel 0) globals[ optPt-xcor optPt-ycor ;; min point of gathering patchCurrXcor patchCurrYcor ;; This is to keep track with the turtles move in relation with the area elevation. countrestfieldturtles ;; for counting non-dying fieldTurtles dyingTurtles ;; number of dead fieldTurtles ] patches-own [ gradlevel ;; area geographicla elevation ] turtles-own [ ] to setup clear-all set countrestfieldturtles 0 ;; set remaining fieldTurtles counter to 0 create-originTurtles 1 [set xcor optPt-xcor set ycor optPt-ycor set hidden? true] ;; Turtle 0 creation for world origin identification ;; Gradien_0_XPosition and Gradien_0_YPosition ;; are values that provide an offset from min-pxcor and min-pycor. ;; originTurtle 0 is hidden in oorder to let the red patch appear. set patchCurrXcor 0 ;; turtle patch position initialization set patchCurrYcor 0 post-setup ;; to create and point a turtle to the origin set optPt-xcor min-pxcor + Gradien_0_XPosition ;; select the origin point at the minimum point of the area elevation set optPt-ycor min-pycor + Gradien_0_YPosition ask patch optPt-xcor optPt-ycor [ask neighbors [ set pcolor white ] set gradlevel 0 set pcolor red] ;; color origin patch's turtle's ;; neighbors in WHITE ;;post-setup ;; to create and point a turtle to the origin reset-ticks end to post-setup patches-elevation ;; To assign area elevation to each patch by feeling it local variable grad-level ask patch optPt-xcor optPt-ycor [set gradlevel 0] create-fieldTurtles TotTurtlesNum [ set xcor random-pxcor set ycor random-pycor ;;set color yellow set size 2 set shape "arrow" pen-down facexy optPt-xcor optPt-ycor ] end to patches-elevation let totpatches (max-pxcor * max-pycor) ask patches [ let elevation random totpatches let elev% ceiling ( (elevation / totpatches) * 100 ) if elevation != 0 [ set gradlevel elevation ;;set pcolor scale-color basefieldcolor 10 50 5 ;; is a color if ( (elev% >= 95) and (elev% <= 100) ) [set pcolor basefieldcolor + 1.17 ] if ( (elev% >= 75) and (elev% < 95) ) [set pcolor (basefieldcolor + 1.2) ] if ( (elev% >= 50) and (elev% < 75) ) [set pcolor (basefieldcolor + 1.3) ] if ( (elev% >= 20) and (elev% < 50) ) [set pcolor (basefieldcolor + 1.4) ] if ( (elev% > 00) and (elev% < 20) ) [set pcolor (basefieldcolor + 1.5) ] ;;if (elev% = 00) [set pcolor white ] show gradlevel show elev% ] ] end to go ;;setup ;; to force running setup procedure first set countrestfieldturtles count fieldTurtles ;; fieldTurtles counting set dyingTurtles TotTurtlesNum - countrestfieldturtles ask fieldTurtles [ ask patch optPt-xcor optPt-ycor [ask neighbors [ set pcolor white ] set gradlevel 0 set pcolor red] ;; color origin patch's turtle's neighbors in WHITE savePatchXY ;; to save the current turtle position ;; in order to compare it to the next position ;; and see if the turtle will come back to it ;; if the min elevation <= the same show "Below former pxcor and pycor" show patchCurrXcor show patchCurrYcor ;; for checking move-to min-one-of neighbors [gradlevel] ;; Move the turtle onto ;; the lowest elevation within its close patches savePatchXY ;; To save the new coordinates after "min-one-of neighbors" ask neighbors [set pcolor green] ;; color the turtle close patches show "Below after move pxcor and pycor" show pxcor show pycor ;; for checking show "Area (patch) altitude value (area elevation)" show gradlevel minPointNeigborhood ;; procedure for turtle's death if the most min point (area) is reached facexy optPt-xcor optPt-ycor ;; To allow the turtle to always point to ;; the general min point (2,2) if (patchCurrXcor = pxcor and patchCurrYcor = pycor) [ fd 3 minPointNeigborhood ] ;; move to 3 steps away in order to avoid having the former low elevation ;; within it close patches if by the that value would ne lower than the next one ;; and will force the turtle to come back to it's former position ;;ask patch optPt-xcor optPt-ycor [ask neighbors [ set pcolor white ] set gradlevel 0 set pcolor red] ;; color origin patch's turtle's ;; neighbors in WHITE ] ask patch optPt-xcor optPt-ycor [ask neighbors [ set pcolor white ] set gradlevel 0 set pcolor red] ;; color origin patch's turtle's neighbors in WHITE tick if ticks = Stop_ticks_Num [ beep stop ] ;; Stops the steps counter and emits a sound to indicate the simulation end end to savePatchXY set patchCurrXcor pxcor ;; update the global variables with the current turtle position set patchCurrYcor pycor end ;; to check if the turtle's patch is within the close patch's neighbors of the most min point (area) ;;and if so, turtle can die to minPointNeigborhood if ( (pxcor = optPt-xcor and pycor = optPt-ycor) or gradlevel = 0 ) [ show "The most min point is reached (-grad)" die ] ;; If general min point (area) is reached ;;or area's altitude is 0, the turtle die ask originTurtle 0 [if ( member? [pxcor] of fieldTurtles [pxcor] of neighbors ) [ die ]] ;; if a turtle arrives in origin neighborhood, it dies end
There is only one version of this model, created almost 3 years ago by Constant Patrice KODJA ADJOVI.
Attached files
File | Type | Description | Last updated | |
---|---|---|---|---|
Area Gradients Simulation.png | preview | Preview for 'Area Gradients Simulation' | almost 3 years ago, by Constant Patrice KODJA ADJOVI | Download |
This model does not have any ancestors.
This model does not have any descendants.