/* Denrite by Charles Bennet, in CAMRexx by THOR */

MakeAlgorithm:
   PLANEALGORITHM margolus hvcenters
return

MakePlane:
   if plane=0 then; do
      if (center_ | cw_ | opp_ | ccw_) then     /* wall ? */
         SETPLANE 0                             /* remove from moving */
      else; do
         if alt_ then   SETPLANE ccw
         else           SETPLANE cw             /* random walk else */
      end
   end
   if plane=1 then; do
      if (center_ | cw_ | opp_ | ccw_) then; do /* wall again ? */
            new=center | center_                /* glue here ! */
            SETPLANE new
      end; else
            SETPLANE center_
   end
   if plane=2 then; do
      new=(ul ^ ur)^(ll & lr)^(ul_ & ll_)^(ur_ ^ lr_)
      SETPLANE new
   end
   if plane=3 then; do
      SETPLANE center      /* delay line */
   end
return


