Maze Generator 1
Model was written in NetLogo 6.1.1
•
Viewed 667 times
•
Downloaded 42 times
•
Run 0 times
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 [ xxx ] to setup clear-all ;; set sides with starting turtles ask patches with [count neighbors != 8] [ set xxx 1 ] ask patches with [pxcor = min-pxcor + 1] [set pcolor white] ask patches with [pxcor = max-pxcor - 1] [set pcolor white] ;; set top and bottom white ask patches with [pycor = max-pycor or pycor = min-pycor] [ set pcolor white ] clean-corners setup-start-finish ;set start and finish ;; sprout turtles ask n-of edges (patches with [pcolor = white]) [ sprout 1 [ set color blue facexy -1 * pxcor pycor fd 1 ] ] reset-ticks end to setup-start-finish ask patches with [pxcor = max-pxcor and pycor = Right-Height] [ set pcolor red ask neighbors [ set pcolor black ] ask patch-at 0 2 [ set pcolor white ] ask patch-at 0 -2 [ set pcolor white ] ] ask patches with [pxcor = min-pxcor and pycor = Left-Height] [ set pcolor red ask neighbors [ set pcolor black ] ask patch-at 0 2 [ set pcolor white ] ask patch-at 0 -2 [ set pcolor white ] ] end to clean-corners ask patches with [pycor = max-pycor and pxcor = max-pxcor ] [ set pcolor black ] ask patches with [pycor = max-pycor and pxcor = min-pxcor ] [ set pcolor black ] ask patches with [pycor = min-pycor and pxcor = max-pxcor ] [ set pcolor black ] ask patches with [pycor = min-pycor and pxcor = min-pxcor ] [ set pcolor black ] end to go ;; die if neighbors ask turtles [ if count turtles-on neighbors > 0 [ die ] ] ;; turn if facing edge ask turtles [ if patch-ahead 1 = nobody or patch-left-and-ahead 45 1 = nobody or patch-right-and-ahead 45 1 = nobody [ rt 180 ] ] ;; die if facing white ask turtles [ if [pcolor] of patch-ahead 1 = white or [pcolor] of patch-left-and-ahead 45 1 = white or [pcolor] of patch-right-and-ahead 45 1 = white or [pcolor] of patch-left-and-ahead 90 1 = white or [pcolor] of patch-right-and-ahead 90 1 = white [ die ] ] ;; move ask turtles [ set pcolor white set xxx 1 downhill4 xxx ask patch-left-and-ahead 135 1 [ set xxx 1 ] ask patch-right-and-ahead 135 1 [ set xxx 1 ] ] ;; sprout turtles ask n-of edges (patches with [pcolor = white]) [ sprout 1 [ set color blue let yyy random 4 if yyy > 2.5 [ set heading 0 ] if yyy > 1.5 and yyy < 2.5 [ set heading 90 ] if yyy > 0.5 and yyy < 1.5 [ set heading 180 ] if yyy > -0.5 and yyy < 0.5 [ set heading 270 ] ifelse patch-ahead 1 = nobody [ rt 180 fd 1] [ fd 1] ] ] tick end to kill ask turtles [ die ] ask patches with [ pcolor = red ] [ask neighbors4 [ set pcolor black ] ] end to-report edges if Difficulty = "Easy" [ report count patches with [count neighbors != 8] - 6 ] if Difficulty = "Medium" [ report max-pycor / 3 ] if Difficulty = "Hard" [ report 1 ] end
There are 3 versions of this model.
Attached files
File | Type | Description | Last updated | |
---|---|---|---|---|
Maze Generator 1.png | preview | Preview for 'Maze Generator 1' | about 5 years ago, by Benjamin Menashe | Download |
This model does not have any ancestors.
This model does not have any descendants.