3d-cube-maze

No 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 3D Preview 4 • Viewed 1161 times • Downloaded 54 times • Run 5 times
Download the '3d-cube-maze' 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?

BORG CUBE! No really, it's a maze generator and traverser, in three dimensions.

THINGS TO NOTICE

Using the observer and sexyz and set-gaze-xyz, it is possible to create moving camera effects. In this model, the camera is flown about the model space, giving the illusion that the cube is rotating.

RELATED MODELS

maze-maker-2004

3d-maze-2005

Comments and Questions

Click to Run Model

globals
[ old-slice ]

to setup
   ca
   crt 1
   [ set color yellow maze-3d die ]
end 

to maze-3d
   let location patch-here
   let choices open-routes-3d
   while [ any? choices ]
   [ let choice one-of choices
     let ddx ([pxcor] of choice - xcor) / 2
     let ddy ([pycor] of choice - ycor) / 2
     let ddz ([pzcor] of choice - zcor) / 2
     jump-to-dd ddx ddy ddz set pcolor color
     jump-to-dd ddx ddy ddz set pcolor color
     maze-3d
     set choices open-routes-3d
   ]
   setxyz [pxcor] of location [pycor] of location [pzcor] of location
end 

to go
   if spin-zoom? [ spin-pov ]
   if traverse? [ traverse-3d ]
end 

to traverse-3d
   let choice nobody
   if not any? turtles
   [ crt 1
     [ set size 2
       setxyz 0 0 0
       set shape "circle"
     ]
   ]
   if    shade-of? yellow [pcolor] of patch 0 0 0
      or shade-of? red [pcolor] of patch 0 0 0
   [ ask patches with [ pcolor != black ] [ set pcolor (green - 5) ] ]
   ask turtles
   [ set pcolor pink
     set choice nobody
     let choices neighbors6 with [ shade-of? pcolor green and no-wrap 1]
     if not any? choices
     [ set pcolor magenta
       set choices neighbors6 with [ shade-of? pcolor pink and no-wrap 1]
     ]
     if not any? choices
     [ set pcolor red
       set choices neighbors6 with [ shade-of? pcolor magenta and no-wrap 1]
     ]
     if any? choices
     [ set choice one-of choices
       setxyz ([pxcor] of choice)
              ([pycor] of choice)
              ([pzcor] of choice)
     ]
     if choice = nobody [ set traverse? false die ]
   ]
end 

to-report open-routes-3d
   report
     patches at-points
     [
       [  2  0  0 ]
       [  0  2  0 ]
       [  0  0  2 ]
       [ -2  0  0 ]
       [  0 -2  0 ]
       [  0  0 -2 ]
     ]
     with [ pcolor = black
            and no-wrap 2
          ]
end 

to-report no-wrap [ gap ]
   report
   (     abs pxcor <= max-pxcor - gap
     and abs pycor <= max-pycor - gap
     and abs pzcor <= max-pzcor - gap
   )
end 

to jump-to-dd [ ddx ddy ddz ]
   setxyz (xcor + ddx) (ycor + ddy) (zcor + ddz)
  face patch 0 0 0
end 

to spin-pov
   ;; rotates the gaze
   setxyz
     (world-width / zoom-level * sin (360 / 60 * rpm * timer) * cos vantage)
     (world-height / zoom-level * cos (360 / 60 * rpm * timer) * cos vantage)
     (world-depth / zoom-level * sin vantage )
  face patch 0 0 0
end 

There are 2 versions of this model.

Uploaded by When Description Download
Uri Wilensky over 14 years ago Updated from NetLogo 4.1 Download this version
Uri Wilensky over 14 years ago 3d-cube-maze Download this version

Attached files

No files

This model does not have any ancestors.

This model does not have any descendants.