/* Tube-Worms:    By an idea of Toffoli, converted to CAMRexx by THOR */

MakeAlgorithm:
   PLANEALGORITHM moore centers
return

/* parameters.alarm */
MakePlane:
   if plane=0 then; do
      if alts=0   then  SETPLANE on       /* emerge if timer over */
      else              SETPLANE off
   end
   if plane=1 then; do
     sum8=north+south+west+east+n_west+n_east+s_west+s_east /* add up */
     if sum8>=parameters.alarm then    SETPLANE on          /* ring alarm */
     else                              SETPLANE off
   end
   if plane=2 | plane=3 then; do
      if alt & alt_ then               SETPLANES 12         /* set timer */
      else; do
         newcenter=centers
         if newcenter>0 then newcenter=newcenter-1          /* decrement */
         newcenter=newcenter*4         /* set in planes 2..3 */
         SETPLANES newcenter
      end
   end
return


