home processing download documents tutorial python tutorial gallery source about
 Python Tutorials (back to the list of tutorials)

Clock Stack Agent Algorithm

     Template Code


Warning: include(codepy/igeo_tutorial60_0/igeo_tutorial60_0.html): failed to open stream: No such file or directory in /home/mj7789dybiu5/public_html/igeo/tutorial/tutorial.php on line 66

Warning: include(): Failed opening 'codepy/igeo_tutorial60_0/igeo_tutorial60_0.html' for inclusion (include_path='.:/opt/alt/php56/usr/share/pear:/opt/alt/php56/usr/share/php') in /home/mj7789dybiu5/public_html/igeo/tutorial/tutorial.php on line 66


     Rule 1

To run the code, replace the rule method in the template code with the following.

  void rules(){
    if(clock(0)==9){
      if(clock(1)==0){
        next(2);
      }
      next(rot(PI/2), 1);
    }
    else{
      next(0);
    }
  }


     Rule 2

  void rules(){
    if(clock(0)==9){
      if(clock(1)==0){
        if(clock(2)==3){
          next(rot(-PI/2), 3);
        }
        else{ next(2); }
      }
      next(rot(PI/2), 1);
    }
    else{ next(0); }
  }


     Rule 3

  void rules(){
    if(clock(0)==9){
      if(clock(1)==0){
        if(clock(2)==3){
          next(rot(-PI/2), 3);
        }
        else{ next(2); }
      }
      if(clock(1)==2 && clock(2)==0 && clock(3)==1){
        next(rot(-PI/2), 4);
      }
      next(rot(PI/2), 1);
    }
    else{ next(0); }
  }


     Rule 4

  void rules(){
    if(clock(0)==3){
      if(clock(1)==0){
        if(clock(2)==3){
          next(rot(-PI/2), 3);
        }
        else{ next(2); }
      }
      if(clock(4)==3){
        if(clock(1)==2 && clock(2)==0 && clock(3)==0){
          next(rot(-PI/2), 5).clr(0);
        }
        if(clock(1)==2 && clock(2)==0 && clock(3)==1){
          next(rot(-PI/2), 5).clr(0);
        }
        if(clock(1)==2 && clock(2)==0 && clock(3)==2){
          next(rot(-PI/2), 5).clr(0);
        }
      }
      else if(clock(1)==2 && clock(2)==0 && clock(3)==1){
        next(rot(-PI/2), 4);
      }
      next(rot(PI/2), 1);
    }
    else{ next(0); }
  }


     Rule 5

  void rules(){
    if(clock(0)==3){
      if(clock(1)==0){
        if(clock(2)==3){
          next(rot(-PI/2), 3);
        }
        else{ next(2); }
      }
      if(clock(4)==3){
        if(clock(1)==2 && clock(2)==0 && clock(3)==0){
          next(rot(-PI/3), 5).clr(0);
        }
        if(clock(1)==2 && clock(2)==0 && clock(3)==1){
          next(rot(-PI/2), 5).clr(0);
        }
        if(clock(1)==2 && clock(2)==0 && clock(3)==2){
          next(rot(-PI/3), 5).clr(0);
        }
      }
      else if(clock(1)==2 && clock(2)==0 && clock(3)==1){
        next(rot(-PI/2), 4); //.clr(0, 0, (clock(4)+1)*0.3);
      }
      next(rot(PI/2), 1);
    }
    else{ next(0); }
  }


     Rule 6

  void rules(){
    if(clock(0)==3){
      if(clock(1)==0){
        if(clock(2)==3){
          next(rot(-PI/2), 3);
        }
        else{ next(2); }
      }
      if(clock(4)==3){
        if(clock(1)==2 && clock(2)==0 && clock(3)==0){
          next(rot(-PI/2), 5).clr(0);
        }
        if(clock(1)==2 && clock(2)==0 && clock(3)==1){
          next(rot(-PI/2), 5).clr(0);
        }
        if(clock(1)==2 && clock(2)==0 && clock(3)==2){
          next(rot(-PI/2), 5).clr(0);
        }
      }
      else if(clock(1)==2 && clock(2)==0 && clock(3)==1){
        next(rot(-PI/2), 4); //.clr(0, 0, (clock(4)+1)*0.3);
      }
      next(rot(PI/2), 1);
    }
    else{ next(rot(PI/180*1), 0); }
  }


     Rule 7

  void rules(){
    if(clock(0)==3){
      if(clock(1)==0){
        if(clock(2)==3){
          next(rot(-PI/2), 3);
        }
        else{ next(2); }
      }
      if(clock(4)==3){
        if(clock(1)==2 && clock(2)==0 && clock(3)==0){
          next(rot(-PI/2), 5).clr(0);
        }
        if(clock(1)==2 && clock(2)==0 && clock(3)==1){
          next(rot(-PI/2), 5).clr(0);
        }
        if(clock(1)==2 && clock(2)==0 && clock(3)==2){
          next(rot(-PI/2), 5).clr(0);
        }
      }
      else if(clock(1)==2 && clock(2)==0 && clock(3)==1){
        next(rot(-PI/2), 4); //.clr(0, 0, (clock(4)+1)*0.3);
      }
      next(rot(PI/2), 1);
    }
    else{ next(rot(PI/180*0.1), 0); }
  }


     Rule 8

  void rules(){
    if(clock(0)==3){
      if(clock(1)==0){
        if(clock(2)==3){
          next(rot(-PI/2), 3);
        }
        else{ next(2); }
      }
      if(clock(4) >= IRand.getInt(2, 7)){
        if(clock(1)==2 && clock(2)==0 && clock(3)==0){
          next(rot(-PI/2), 5); //.clr(IRand.clr());
        }
        if(clock(1)==2 && clock(2)==0 && clock(3)==1){
          next(rot(-PI/2), 5); //.clr(IRand.clr());
        }
        if(clock(1)==2 && clock(2)==0 && clock(3)==2){
          next(rot(-PI/2), 5); //.clr(IRand.clr());
        }
      }
      else if(clock(1)==2 && clock(2)==0 && clock(3)==1){
        next(rot(-PI/2), 4);
      }
      next(rot(PI/2), 1);
    }
    else{ next(0); }
  }


     Rule 9

  void rules(){
    if(clock(0)==3){
      if(clock(1)==0){
        if(clock(2) >= IRand.getInt(3,10)){
          next(rot(-PI/2), 3);
        }
        else{ next(2); }
      }
      if(clock(4) == 3){
        if(clock(1)==2 && clock(2)==0 && clock(3)==0){
          next(rot(-PI/2), 5);
        }
        if(clock(1)==2 && clock(2)==0 && clock(3)==1){
          next(rot(-PI/2), 5);
        }
        if(clock(1)==2 && clock(2)==0 && clock(3)==2){
          next(rot(-PI/2), 5);
        }
      }
      else if(clock(1)==2 && clock(2)==0 && clock(3)==1){
        next(rot(-PI/2), 4);
      }
      next(rot(PI/2), 1);
    }
    else{ next(0); }
  }


     Rule 10

  void rules(){
    if(clock(0)==3){
      if(clock(1)==0){
        if(clock(2) >= IRand.getInt(3,10)){
          next(rot(-PI/2), 3);
        }
        else{ next(2); }
      }
      if(clock(4) == 3){
        if(clock(1)==2 && clock(2)==0 && clock(3)==0){
          next(rot(-PI/2+IRand.get(-PI/12,PI/12)), 5);
        }
        if(clock(1)==2 && clock(2)==0 && clock(3)==1){
          next(rot(-PI/2), 5);
        }
        if(clock(1)==2 && clock(2)==0 && clock(3)==2){
          next(rot(-PI/2+IRand.get(-PI/12,PI/12)), 5);
        }
      }
      else if(clock(1)==2 && clock(2)==0 && clock(3)==1){
        next(rot(-PI/2), 4);
      }
      next(rot(PI/2), 1);
    }
    else{ next(0); }
  }


     Rule 11

  void rules(){
    if(clock(0)>=IRand.getInt(3,10)){
      if(clock(1)==0){
        if(clock(2) >= IRand.getInt(1,5)){
          next(rot(-PI/2), 3);
        }
        else{ next(rot(IRand.get(-0.15, 0.15)), 2); }
      }
      if(clock(4) == 3){
        if(clock(1)==2 && clock(2)==0 && clock(3)==0){
          next(rot(-PI/2), 5);
        }
        if(clock(1)==2 && clock(2)==0 && clock(3)==1){
          next(rot(-PI/2), 5);
        }
        if(clock(1)==2 && clock(2)==0 && clock(3)==2){
          next(rot(-PI/2), 5);
        }
      }
      else if(clock(1)==2 && clock(2)==0 && clock(3)==1){
        next(rot(-PI/2), 4);
      }
      next(rot(PI/2), 1);
    }
    else{ next(0); }
  }


     Rule 12

  void rules(){
    if(clock(0)==1){
      next(rot(-PI/6), 2);
      next(rot(PI/3*2), 1);
    }
    else{ next(0); }
  }


     Rule 13

  void rules(){
    if(clock(0)==1){
      next(rot(PI/3).flipNml(), 2);
      next(rot(PI/3*2), 1);
    }
    else{ next(0); }
  }


     Rule 14

  void rules(){
    if(clock(1)==0){
      if(clock(0)==5){
        next(rot(PI/2), 1);
      }
      else{ next(mul(0.99),0); }
    }
    else{
      if(clock(0)==15){
        next(rot(PI/2), 3);
      }
      else if(clock(0)==2){
        next(rot(-PI/2).flipNml(), 2);
        next(0);
      }
      else{ next(mul(0.99), 0); }
    }
  }


     Rule 15

  void rules(){
    if(clock(1)==0){
      if(clock(0)==15){
        next(rot(PI/3), 1);
        next(rot(-PI/3), 2);
      }
      else{ next(mul(0.99), 0); }
    }
    else if(clock(1)==1){
      if(clock(0)==5){
        next(rot(PI/3), 1);
      }
      else{ next(mul(0.99), 0); }
    }
    else{
      if(clock(0)==5){
        next(rot(PI/3), 3);
      }
      else{ next(mul(0.99), 0); }
    }
  }


     Rule 16

  void rules(){
    if(clock(1)==0){
      if(clock(0)==15){
        next(rot(PI/3), 1);
        next(rot(-PI/3), 2);
      }
      else{ next(0); }
    }
    else if(clock(1)==1){
      if(clock(0)==5){
        next(rot(PI/3), 1);
      }
      else{ next(0); }
    }
    else{
      if(clock(0)==5){
        next(rot(PI/3), 3);
      }
      else{ next(mul(0.99), 0); }
    }
  }


     Rule 17

  void rules(){
    if(clock(1)==0){
      next(rot(-PI/4), 1);
      next(rot(PI/2).flipNml(), 2);
    }
    else{
      if(clock(0)==5){
        if(IRand.pct(20)){
          next(rot(-PI/4).flipNml(), 2);
        }
      }
      else{ next(0); }
    }
  }


     Rule 18

  void rules(){
    if(clock(1)==0){
      if(clock(0)==5){
        next(rot(PI/2), 1);
        if(clock(2)==3){
          if(IRand.pct(70)) next(rot(PI/3),3);
          if(IRand.pct(50)) next(3);
          if(IRand.pct(30)) next(rot(-PI/2), 3);
        }
        else{ next(2); }
      }
      else{ next(0); }
    }
    else{
      if(clock(0)==5){
        next(rot(PI/2), 1);
      }
      else{
        next(mul(0.98), 0).clr(clock(0)*0.2, 0, clock(1)*0.1);
      }
    }
  }


     Rule 19

  void rules(){
    if(clock(1)==0){
      if(clock(0)==5){
        next(rot(PI/2), 1).clr(0,0.5,1.0);
        if(clock(2)==0){
          if(clock(3)==0){
            next(rot(-PI/2), 3).clr(0,0,1.0);
          }
          else{ next(rot(-PI/4), 4).clr(0); }
        }
      }
      else{ next(rot(PI/20),0); }
    }
    else{
      if(clock(0)==10){
        next(rot(PI/2),1).clr(0.5,0,1);
        if(clock(2)==0){
          next(3).clr(1.0,0.5,0);
        }
      }
      else{ next(rot(PI/20),0); }
    }
  }


     Rule 20

  void rules(){
    if(clock(1)==0){
      if(clock(0)==5){
        next(rot(PI/2), 1).clr(0,0.5,1.0);
        if(clock(2)==0){
          if(clock(3)==0){
            if(IRand.pct(90)) next(rot(-PI/4), 3).clr(0,0,1.0);
          }
          else{
            if(IRand.pct(40)) next(rot(-PI/2), 4).clr(0);
          }
        }
      }
      else{
        if(clock(2)==1){
          next(mul(0.99), 0);
        }
        else{ next(0); }
      }
    }
    else if(clock(1)==1){
      if(clock(0)==10){
        next(rot(PI/2),1).clr(0.5,0,1);
        if(clock(2)==0){
          next(3).clr(1.0,0.5,0);
        }
      }
      else{
        if(clock(2)==1){
          next(mul(0.99), 0);
        }
        else{ next(0); }
      }
    }
    else if(clock(1)==2){
      if(clock(0)==5){
        next(rot(PI/2), 1);
      }
      else{
        if(clock(2)==1){
          next(mul(0.99), 0);
        }
        else{ next(0); }
      }
    }
    else{
      if(clock(0)==10){
        if(clock(2)==0){
          next(rot(PI/2),2);
        }
      }
      else{ next(mul(0.99), 0); }
    }
  }


     Rule 21

  void rules(){
    if(clock(4)==0){
      if(clock(0)==3){
        next(rot(PI/2),1);
        if(clock(1)==0){
          if(clock(2)==2) next(rot(-PI/2),3);
          else next(2);
        }
      }
      else{
        if(clock(1)==2 && clock(0)==0) next(rot(-PI/2),4).clr(1.0,0,1.0);
        next(0);
      }
    }
    else{
      if(clock(0)==15) next(rot(PI/2),5).clr(0);
      else next(0);
    }
  }


     Rule 22

  void rules(){
    if(clock(0)==1){
      if(clock(1)==1){
        if(clock(2)==10){
          next(rot(-PI/6), 3);
        }
        else{ next(rot(-PI*5/6), 2); }
      }
      else{
        next(rot(PI*5/6), 1);
        if(clock(2)==5){
          next(rot(-PI/2),4);
        }
      }
    }
    else{ next(0); }
  }


     Rule 23

  void rules(){
    if(clock(0)==2){
      if(clock(1)==0 && clock(2)==3){
        next(rot(-PI/3), 3);
      }
      if(clock(1)==2){
        if(clock(2)==5){
          next(rot(-PI/3), 4);
        }
        else{ next(rot(-PI/3).flipNml(), 2); }
      }
      next(rot(PI/3), 1);
    }
    else{ next(0); }
  }


     Rule 24

  void rules(){
    if(clock(0)==2){
      if(clock(1)==0 && clock(2) >= IRand.get(3,6)){
        next(rot(-PI/3), 3);
      }
      if(clock(1)==2){
        if(clock(2) == IRand.getInt(2,5)){
          next(rot(-PI/3), 4);
        }
        else{ next(rot(-PI/3).flipNml(), 2); }
      }
      next(rot(PI/3), 1);
    }
    else{ next(0); }
  }


     Rule 25

  void rules(){
    if(clock(6)==0){
      if(clock(0)==3){
        if(clock(1)==0){
          if(clock(2) >= IRand.getInt(2,10)){
            next(rot(-PI/2), 3);
          }
          else{ next(2); }
        }
        if(clock(4) == 2){
          if(clock(1)==2 && clock(2)==0 && clock(3)==0){ // left
            if(IRand.pct(70)) next(rot(-PI/2), 5);
          }
          if(clock(1)==2 && clock(2)==0 && clock(3)==1){ // straight
            next(rot(-PI/2), 5);
          }
          if(clock(1)==2 && clock(2)==0 && clock(3)==2){ // right
            if(IRand.pct(70)) next(rot(-PI/2), 5);
          }
        }
        else if(clock(1)==2 && clock(2)==0 && clock(3)==1){
          next(rot(-PI/2), 4);
        }
        next(rot(PI/2), 1);
      }
      else{
        if(clock(0)==2 && clock(1)==0 && clock(3)==2){
          next(rot(-PI/2).mul(1), 6).clr(0.5,0,1);
        }
        next(0);
      }
    }
    else{ // branch mode
      if(clock(1)==60){
        if(IRand.pct(10)){
          next(mul(1), 7).clr(0,0,0.5);
        }
      }
      else{
        if(IRand.pct(20)){
          next(rot(-PI/4), 1);
        }
        if(IRand.pct(20)){
          next(rot(PI/4), 1);
        }
        if(IRand.pct(90)){
          next(1);
        }
      }
    }
  }


     Rule 26

  void rules(){
    if(clock(3)==1){
      if(clock(0)>=2 && IRand.pct(10)){
        next(4);
      }
      else{ next(0); }
    }
    else if(clock(0)==2){
      if(clock(1)==0){
        next(rot(-PI/3), 3);
      }
      if(clock(1)==0){
        next(rot(PI/3), 2);
      }
      else{ next(rot(PI/3), 1); }
    }
    else{ next(0); }
  }


     Rule 27

  void rules(){
    if(clock(3)==1){
      if(clock(0)>=2){
        next(4);
      }
      else{ next(rot(0.05), 0); }
    }
    else if(clock(0)==2){
      if(clock(1)==0){
        next(rot(-PI/3), 3);
      }
      if(clock(1)==0){
        next(rot(PI/3), 2);
      }
      else{ next(rot(PI/3), 1); }
    }
    else{ next(0); }
  }


     Rule 28

  void rules(){
    // corrugate
    if(clock(6)==0){
      if(clock(3)==1){
        if(clock(1)==1){
          if(clock(0)==5){
            if(clock(4)==12){ next(6); }
            else{ next(rot(PI/2), 4); }
          }
          else{ next(0); }
        }
        else{ next(rot(-PI/2), 1); }
      }
      else{
        if(clock(1)==1){
          if(clock(0)==5){
            next(rot(-PI/2), 3);
            if(clock(4)==10){ next(5); }
          }
          else{ next(0); }
        }
        else{ next(rot(PI/2), 1); }
      }
    }
    // triangles
    else if(clock(6)==1){
      if(clock(0)==3){
        if(clock(1)==0){
          if(clock(2)==20){ next(rot(-PI/4), 6); }
          else{ next(rot(-PI/3*2).flipNml(), 2); }
        }
        next(rot(PI/3*2), 1);
      }
      else{ next(0); }
    }
    // squares
    else{
      if(clock(0)==3){
        if(clock(1)==1){
          if(clock(2)==0){
            if(clock(3)==4){ next(rot(-PI/2), 7); }
            else{ next(rot(-PI/2),3); }
          }
          next(2);
        }
        next(rot(PI/2), 1);
      }
      else{ next(0); }
    }
  }


     Rule 29

  void rules(){
    if(clock(0)==10){

      if(clock(1)==0){
        if(clock(2)==0){
          next(pitch(PI/2).roll(-PI/2), 2);
        }
        else{
          next(pitch(-PI/2).roll(PI/2), 3);
        }
      }

      if(clock(1)==20); // stop
      else{
        if(clock(1)==0 || clock(1)==1){
          if(clock(1)==1 && clock(3)==1){
            next(4);
          }
          next(yaw(PI/2), 1).hsb(clock(1)*0.02,1,1);
        }
        else{
          next(yaw(PI/2).mul(0.9), 1).hsb(clock(1)*0.02,1,1);
        }
      }
    }
    else{ next(0); }
  }


     Rule 30

  void rules(){
    if(clock(0)==10){
      if(clock(1)==0){
        if(clock(2)==0){
          if(clock(3)==2){
            next(pitch(PI/2).roll(PI/2).mul(0.9), 2);
            next(yaw(-PI/2), 4); // new cube
          }
          else{
            next(pitch(PI/2).roll(PI/2), 2);
            if(clock(4)==4 && clock(3)==1){
              next(yaw(-PI/2), 5); // new cube
            }
          }
        }
        else{
          next(pitch(-PI/2).roll(-PI/2), 3);
        }
      }

      if(clock(1)==20); // stop
      else{
        next(yaw(PI/2).mul(0.9), 1).hsb(clock(1)*0.02,1,1);
      }
    }
    else{ next(0); }
  }


     Rule 31

  void rules(){
    if(clock(0)==3){
      if(clock(1)==0){
        if(clock(2)==0){
          if(clock(3)>=IRand.get(5,10)){
            next(yaw(-PI/2), 4).hsb(sin(IG.time()*.02)*.1+.7,1,1);
            if(IRand.pct(70)) next(4).hsb(sin(IG.time()*.02)*.1+.7,1,1);
          }
          else if(IRand.pct(97)) next(3).hsb(sin(IG.time()*.02)*.1+.7,1,1);
          next(pitch(PI/2).roll(PI/2), 2).hsb(sin(IG.time()*.02)*.1+.7,1,1);
        }
        else if(clock(2)==1){
          if(clock(3)>=IRand.get(5,10)){
            if(IRand.pct(70)) next(roll(-PI/2), 4).hsb(sin(IG.time()*.02)*.1+.7,1,1);
          }
          next(pitch(-PI/2).roll(PI/2), 2).hsb(sin(IG.time()*.02)*.1+.7,1,1);
        }
        else if(clock(2)==2){
          next(pitch(PI/2).roll(PI/2), 2).hsb(sin(IG.time()*.02)*.1+.7,1,1);
        }
        else if(clock(2)==3){
          next(pitch(-PI/2).roll(PI/2), 2).hsb(sin(IG.time()*.02)*.1+.7,1,1);
        }
      }
      next(yaw(PI/2),1).hsb(sin(IG.time()*.02)*.1+.7,1,1);
    }
    else{ next(0).hsb(sin(IG.time()*.02)*.1+.7,1,1); }
  }


     Rule 32

  void rules(){
    if(clock(0)==3){
      if(clock(1)==0){
        if(clock(2)==0){
          if(clock(3)>=IRand.get(5,10)){
            next(rot(-PI/2), 4).hsb(sin(IG.time()*.02)*.1,1,1);
            if(IRand.pct(50)) next(4).hsb(sin(IG.time()*.02)*.1,1,1);
          }
          else next(3).hsb(sin(IG.time()*.02)*.1,1,1);
          next(roll(PI/2).yaw(PI/2), 2).hsb(sin(IG.time()*.02)*.1,1,1);
        }
        else if(clock(2)==1){
          if(clock(3)>=IRand.get(5,10)){
            if(IRand.pct(10)) next(roll(-PI/2), 4).hsb(sin(IG.time()*.02)*.1,1,1);
          }
          next(roll(-PI/2).yaw(PI/2), 2).hsb(sin(IG.time()*.02)*.1,1,1);
        }
        else if(clock(2)==2){
          next(roll(PI/2).yaw(PI/2), 2).hsb(sin(IG.time()*.02)*.1,1,1);
        }
        else if(clock(2)==3){
          next(roll(-PI/2).yaw(PI/2), 2).hsb(sin(IG.time()*.02)*.1,1,1);
        }
      }
      next(rot(PI/2),1).hsb(sin(IG.time()*.02)*.1,1,1);
    }
    else{ next(pitch(-0.03).yaw(0.03), 0).hsb(sin(IG.time()*.02)*.1,1,1); }
  }


     Rule 33

  void rules(){
    if(clock(0)==99){
      next(pitch(PI/2).roll(PI/2), 1).clr(0,0,.5-cos(IG.time()*.05)*.5);
    }
    if(clock(0)==100){
      next(pitch(PI/3).roll(PI/2), 1).clr(0,0,.5-cos(IG.time()*.05)*.5);
    }
    next(yaw(PI/3*2).pitch(0.1), 0).clr(0,0,.5-cos(IG.time()*.05)*.5);
  }


     Rule 34

  void rules(){
    if(clock(0)==99){
      next(pitch(PI/2).roll(PI/2), 1);
    }
    if(clock(0)==100){
      next(pitch(PI/3).roll(PI/2), 1);
    }
    if(clock(0)%3==0){
      next(roll(0.1).yaw(PI/3*2).pitch(0.1), 0).clr(clock(0)*0.01,0,clock(1)*0.1);
    }
    else{
      next(yaw(PI/3*2).pitch(0.1), 0).clr(clock(0)*0.01,0,clock(1)*0.1);
    }
  }


     Rule 35

  void rules(){
    if(clock(5)==1){
      if(clock(0)==6){
        next(rot(PI/3).flipNml(),6);
      }
      else{ next(rot(PI/3).flipNml(),0); }
    }
    else{
      if(clock(0)==0){
        if(clock(4)==43 && clock(1)==1 && clock(2)==0){
          next(rot(PI/3),5);
        }
        else{
          if(clock(1)==2){
            if(clock(2)==1){
              if(clock(3)==11){
                next(yaw(PI/3-PI/15).pitch(PI/6).roll(PI/6), 4);
              }
              else{ next(yaw(PI/3).pitch(PI/6).roll(PI/6), 3); }
            }
            else{ next(yaw(PI/3).pitch(PI/6), 2); }
          }
          else{ next(yaw(PI/3),1); }
        }
      }
      else{ next(0); }
    }
  }


     Rule 36

  void rules(){
    if(clock(7)==2){ // stop
      return;
    }
    if(clock(2)==0){ // segment
      next(rot(PI/2), 2);
    }
    else{ // square
      if(clock(0)==3){
        if(clock(1)==2){
          if(clock(3)==3 && clock(5)==0){
            next(4);
          }
          else if(clock(3)==9 && clock(5)==1){
            next(6).clr(0);
          }
          else{ next(rot(PI/2), 3); }
        }
        next(rot(-PI/2),1);
      }
      else{
        if(clock(0)==1 && clock(1)==1 && clock(3)==1 && clock(5)==0){
          if(clock(6)==1){
            next(yaw(PI/2).pitch(PI/2), 7);
          }
          else{ next(rot(PI/2), 5).clr(0.5,0,0.5); }
        }
        next(0);
      }
    }
  }


     Template Code2


Warning: include(codepy/igeo_tutorial60_37/igeo_tutorial60_37.html): failed to open stream: No such file or directory in /home/mj7789dybiu5/public_html/igeo/tutorial/tutorial.php on line 66

Warning: include(): Failed opening 'codepy/igeo_tutorial60_37/igeo_tutorial60_37.html' for inclusion (include_path='.:/opt/alt/php56/usr/share/pear:/opt/alt/php56/usr/share/php') in /home/mj7789dybiu5/public_html/igeo/tutorial/tutorial.php on line 66


     Rule 37

void setup(){
  size(640, 480, IG.GL);
  IConfig.syncDrawAndDynamics=true;
  IG.bg(1.0);
  new ClockStackAgent(new IVec(0,0,0), new IVec(0,0,10), new IVec(0,-1,0), null, null).clr(0.2);
}

//...

  void rules(){
    double rinc = 0.002;
    double ginc = 0.02;
    double ginc2 = 0.05;
    double binc = 0.004;

    if(clock(2)==1){
      next(pitch(-PI/70), 0).clr(red(),green(),blue()+binc);
    }
    else if(clock(3)==1){
      next(pitch(-PI/96).rot(-PI/96).roll(PI/6000), 0).clr(red(),green(),blue()+binc);
    }
    else if(clock(4)==1){
      next(pitch(-PI*0.01475), 0).clr(red(),green(),blue()+binc);
    }
    else if(clock(5)==1){
      next(rot(-PI*0.01545), 0).clr(red(),green(),blue()+binc);
    }
    else if(clock(6)==1){
      if(clock(0)==5) next(pitch(-PI/4-PI/10), 1).clr(red(),green()+ginc,blue());
      else next(pitch(PI/20), 0).clr(red(),green(),blue()+binc);
    }
    else if(clock(7)==1){
      next(pitch(-PI/58), 0).clr(red(),green(),blue()+binc);
    }
    else if(clock(8)==1){
      if(clock(0)==5) next(rot(PI/4).pitch(-PI/58), 1).clr(red(),green()+ginc,blue());
      else next(rot(-PI/20).pitch(-PI/58), 0).clr(red(),green(),blue()+binc);
    }
    else if(clock(9)==1){
      if(clock(1)==0){
        if(clock(0)==15) next(1).clr(red(),green(),blue()+binc*2);
        else next(0).delay(0).clr(red(),green(),blue()+binc*2);
      }
      else{
        next(pitch(-PI/35).mul(0.99), 0).clr(red(),green(),blue()+binc*2);
      }
      next(rot(PI/2), 10).clr(red(),green()+ginc,blue()).clr(red(),green()+ginc2,blue());
      next(rot(-PI/2), 10).clr(red(),green()+ginc,blue()).clr(red(),green()+ginc2,blue());
    }
    else if(clock(10)==1){
      if(clock(1)==0){
        next(pitch(-PI/2), 1).clr(red(),green()+ginc,blue());
      }
      else if(clock(1)==1){
        if(clock(0)==4) next(1);
        else next(0).clr(red(),green(),blue()+binc);
      }
    }
    else{
      if(clock(1)==0){
        if(clock(0)==2){ next(pitch(-PI/4), 1).clr(red(),green()+ginc,blue()); }
        else next(0).clr(red()+rinc,green(),blue());
        next(rot(PI/2).pitch(-PI/120), 2).clr(red(),green()+ginc2,blue());
      }
      else if(clock(1)==1){
        if(clock(0)==8) next(pitch(PI/4), 1).clr(red(),green()+ginc,blue());
        else next(mul(0.97),0).clr(red()+rinc,green(),blue());
        next(rot(PI/2-PI/192).pitch(-PI/192), 3).clr(red(),green()+ginc2,blue());
      }
      else if(clock(1)==2){
        if(clock(0)==2){
          next(pitch(-PI/2), 0).clr(red()+rinc,green(),blue());
          next(rot(PI/2).pitch(-PI*0.01475/2), 4).clr(red(),green()+ginc2,blue());
        }
        else if(clock(0)==3){
          next(pitch(PI/2).mul(1.114), 1).clr(red(),green()+ginc,blue());
          next(mul(0.954), 0).clr(red()+rinc,green(),blue());
          next(rot(PI/2-PI*0.01545/2), 5).clr(red(),green()+ginc2,blue());
        }
        else if(clock(0)==4){
          next(rot(PI/2-PI*0.01545/2), 5).clr(red(),green()+ginc2,blue());
        }
        else{
          next(0).clr(red()+rinc,green(),blue());
          next(rot(PI/2).pitch(-PI*0.01475/2), 4).clr(red(),green()+ginc2,blue());
        }
      }
      else if(clock(1)==3){
        if(clock(0)==200) next(1).clr(red(),green()+ginc,blue()); else next(0).clr(red()+rinc,green(),blue());
        next(rot(PI/2).pitch(-PI/6-PI/120), 6).clr(red(),green()+ginc2,blue());
      }
      else if(clock(1)==4){
        if(clock(0)==7) next(1).clr(red(),green()+ginc,blue()); else next(0).clr(red()+rinc,green(),blue());
        next(rot(PI/2).pitch(-PI/120), 7).clr(red(),green()+ginc2,blue());
      }
      else if(clock(1)==5){
        next(1).clr(red(),green()+ginc,blue());
      }
      else if(clock(1)==6){
        if(clock(0)==6) next(1).clr(red(),green()+ginc,blue()); else next(0).clr(red()+rinc,green(),blue());
        next(rot(PI/2).pitch(-PI/120).rot(PI/8), 8).clr(red(),green()+ginc2,blue());
      }
      else if(clock(1)==7){
        if(clock(0)==4){
          next(pitch(-PI/2), 1).clr(red(),green()+ginc,blue());
        }
        else next(0).clr(red()+rinc,green(),blue());
      }
      else if(clock(1)==8){
        if(clock(0)<35) next(0).clr(red(),green()+ginc,blue());
        next(rot(PI/2).mul(1+0.08*cos(2*PI*clock(0)/35)), 9).clr(red(),green()+ginc2,blue());
        next(rot(-PI/2).mul(1+0.08*cos(2*PI*clock(0)/35)), 9).delay(25).clr(red(),green()+ginc2,blue());
      }
    }
  }


     Rule 38

void setup(){
  size(640, 480, IG.GL);
  IConfig.syncDrawAndDynamics=true;
  IG.bg(1.0);
  new ClockStackAgent(new IVec(0,0,0), new IVec(0,0,10), new IVec(0,-1,0), null, null).clr(0.2);
}

//...

  void rules(){
    double rinc = 0.002;
    double ginc = 0.02;
    double ginc2 = 0.05;
    double binc = 0.004;

    if(clock(2)==1){
      next(pitch(-PI/70).mul(1.0003), 0).clr(red(),green(),blue()+binc);
    }
    else if(clock(3)==1){
      next(pitch(-PI/96).rot(-PI/96).roll(PI/6000*0).mul(1.0003), 0).clr(red(),green(),blue()+binc);
    }
    else if(clock(4)==1){
      next(pitch(-PI*0.01475), 0).clr(red(),green(),blue()+binc);
    }
    else if(clock(5)==1){
      next(rot(-PI*0.01545), 0).clr(red(),green(),blue()+binc);
    }
    else if(clock(6)==1){
      if(clock(0)==5) next(pitch(-PI/4-PI/10), 1).clr(red(),green()+ginc,blue());
      else next(pitch(PI/20).mul(1.002), 0).clr(red(),green(),blue()+binc);
    }
    else if(clock(7)==1){
      next(pitch(-PI/58), 0).clr(red(),green(),blue()+binc);
    }
    else if(clock(8)==1){
      if(clock(0)==5) next(rot(PI/4).pitch(-PI/58), 1).clr(red(),green()+ginc,blue());
      else next(rot(-PI/20).pitch(-PI/58), 0).clr(red(),green(),blue()+binc);
    }
    else if(clock(9)==1){
      if(clock(1)==0){
        if(clock(0)==15) next(1).clr(red(),green(),blue()+binc*2);
        else next(pitch(PI*0.01).mul(1.01), 0).delay(0).clr(red(),green(),blue()+binc*2);
      }
      else{
        next(pitch(-PI/35).mul(0.99), 0).clr(red(),green(),blue()+binc*2);
      }
      next(rot(PI/2), 10).clr(red(),green()+ginc,blue()).clr(red(),green()+ginc2,blue());
      next(rot(-PI/2), 10).clr(red(),green()+ginc,blue()).clr(red(),green()+ginc2,blue());
    }
    else if(clock(10)==1){
      if(clock(1)==0){
        next(pitch(-PI/2), 1).clr(red(),green()+ginc,blue());
      }
      else if(clock(1)==1){
        if(clock(0)==4) next(1);
        else next(0).clr(red(),green(),blue()+binc);
      }
    }

    else{
      if(clock(1)==0){
        if(clock(0)==2){ next(pitch(-PI/4), 1).clr(red(),green()+ginc,blue()); }
        else next(0).clr(red()+rinc,green(),blue());
        next(rot(PI/2).pitch(-PI/120), 2).clr(red(),green()+ginc2,blue());
      }
      else if(clock(1)==1){
        if(clock(0)==8) next(pitch(PI/4), 1).clr(red(),green()+ginc,blue());
        else next(mul(0.97),0).clr(red()+rinc,green(),blue());
        next(rot(PI/2-PI/192).pitch(-PI/192), 3).clr(red(),green()+ginc2,blue());
      }
      else if(clock(1)==2){
        if(clock(0)==2){
          next(pitch(-PI/2), 0).clr(red()+rinc,green(),blue());
          next(rot(PI/2).pitch(-PI*0.01475/2), 4).clr(red(),green()+ginc2,blue());
        }
        else if(clock(0)==3){
          next(pitch(PI/2-PI*0.05).mul(1.114), 1).clr(red(),green()+ginc,blue());
          next(mul(0.954), 0).clr(red()+rinc,green(),blue());
          next(rot(PI/2-PI*0.01545/2), 5).clr(red(),green()+ginc2,blue());
        }
        else if(clock(0)==4){
          next(rot(PI/2-PI*0.01545/2), 5).clr(red(),green()+ginc2,blue());
        }
        else{
          next(0).clr(red()+rinc,green(),blue());
          next(rot(PI/2).pitch(-PI*0.01475/2), 4).clr(red(),green()+ginc2,blue());
        }
      }
      else if(clock(1)==3){
        if(clock(0)==200) next(1).clr(red(),green()+ginc,blue());
        else next(pitch(PI*0.001).mul(0.998), 0).clr(red()+rinc,green(),blue());
        next(rot(PI/2).pitch(-PI/6-PI/120), 6).clr(red(),green()+ginc2,blue());
      }
      else if(clock(1)==4){
        if(clock(0)==7) next(1).clr(red(),green()+ginc,blue()); else next(0).clr(red()+rinc,green(),blue());
        next(rot(PI/2).pitch(-PI/120), 7).clr(red(),green()+ginc2,blue());
      }
      else if(clock(1)==5){
        next(1).clr(red(),green()+ginc,blue());
      }
      else if(clock(1)==6){
        if(clock(0)==6) next(1).clr(red(),green()+ginc,blue()); else next(0).clr(red()+rinc,green(),blue());
        next(rot(PI/2).pitch(-PI/120).rot(PI/8), 8).clr(red(),green()+ginc2,blue());
      }
      else if(clock(1)==7){
        if(clock(0)==4){
          next(pitch(-PI/2), 1).clr(red(),green()+ginc,blue());
        }
        else next(0).clr(red()+rinc,green(),blue());
      }
      else if(clock(1)==8){
        if(clock(0)<200) next(pitch(PI*0.015).mul(0.995), 0).clr(red(),green()+ginc,blue());
        next(rot(PI/2).mul(1+0.08*cos(2*PI*clock(0)/35)), 9).clr(red(),green()+ginc2,blue());
        next(rot(-PI/2).mul(1+0.08*cos(2*PI*clock(0)/35)), 9).delay(25).clr(red(),green()+ginc2,blue());
      }
    }
  }


     Rule 39

void setup(){
  size(640, 480, IG.GL);
  IConfig.syncDrawAndDynamics=true;
  IG.bg(1.0);
  new ClockStackAgent(new IVec(0,0,0), new IVec(0,0,10), new IVec(0,-1,0), null, null).clr(0.2);
}

//...

  void rules(){
    double rinc = 0.002;
    double ginc = 0.02;
    double ginc2 = 0.05;
    double binc = 0.004;

    if(clock(2)==1){
      next(pitch(-PI/70), 0).clr(red(),green(),blue()+binc);
    }
    else if(clock(3)==1){
      next(pitch(-PI/96).rot(-PI/96).roll(PI/6000), 0).clr(red(),green(),blue()+binc);
    }
    else if(clock(4)==1){
      next(pitch(-PI*0.01475), 0).clr(red(),green(),blue()+binc);
    }
    else if(clock(5)==1){
      next(rot(-PI*0.01545), 0).clr(red(),green(),blue()+binc);
    }
    else if(clock(6)==1){
      if(clock(0)==5){
        next(pitch(-PI/4-PI/10), 1).clr(red(),green()+ginc,blue());
        if(clock(1)%5==0){
          if(IRand.pct(1)){
            next(pitch(PI/2).mul(0.5), 1).clr(red(),green()+ginc,blue());
          }
          else if(IRand.pct(1)){
            next(rot(PI/2).mul(0.5), 12).clr(red(),green()+ginc,blue());
          }
          else if(IRand.pct(1)){
            next(rot(-PI/2).mul(0.5), 12).clr(red(),green()+ginc,blue());
          }
          else if(IRand.pct(0.5)){
            next(mul(0.5), 11).clr(red(),green()+ginc,blue());
          }
        }
      }
      else next(pitch(PI/20), 0).clr(red(),green(),blue()+binc);
    }
    else if(clock(7)==1){
      next(pitch(-PI/58), 0).clr(red(),green(),blue()+binc);
    }
    else if(clock(8)==1){
      if(clock(0)==5) next(rot(PI/4).pitch(-PI/58), 1).clr(red(),green()+ginc,blue());
      else next(rot(-PI/20).pitch(-PI/58), 0).clr(red(),green(),blue()+binc);
    }
    else if(clock(9)==1){
      if(clock(1)==0){
        if(clock(0)==15) next(1).clr(red(),green(),blue()+binc*2);
        else next(0).delay(0).clr(red(),green(),blue()+binc*2);
      }
      else{
        next(pitch(-PI/35).mul(0.99), 0).clr(red(),green(),blue()+binc*2);
      }
    }
    else if(clock(10)==1){
      if(clock(1)==0){
        next(pitch(-PI/2), 1).clr(red(),green()+ginc,blue());
      }
    }
    else if(clock(11)==1){
      if(clock(0)<35) next(0).clr(red(),green()+ginc,blue());
      next(rot(PI/2).mul(1+0.08*cos(2*PI*clock(0)/35)), 9).clr(red(),green()+ginc2,blue());
      next(rot(-PI/2).mul(1+0.08*cos(2*PI*clock(0)/35)), 9).delay(25).clr(red(),green()+ginc2,blue());
    }

    else{
      if(clock(1)==0){
        if(clock(0)==2){ next(pitch(-PI/4), 1).clr(red(),green()+ginc,blue()); }
        else next(0).clr(red()+rinc,green(),blue());
        next(rot(PI/2).pitch(-PI/120), 2).clr(red(),green()+ginc2,blue());
      }
      else if(clock(1)==1){
        if(clock(0)==8) next(pitch(PI/4), 1).clr(red(),green()+ginc,blue());
        else next(mul(0.97),0).clr(red()+rinc,green(),blue());
        next(rot(PI/2-PI/192).pitch(-PI/192), 3).clr(red(),green()+ginc2,blue());
      }
      else if(clock(1)==2){
        if(clock(0)==2){
          next(pitch(-PI/2), 0).clr(red()+rinc,green(),blue());
          next(rot(PI/2).pitch(-PI*0.01475/2), 4).clr(red(),green()+ginc2,blue());
        }
        else if(clock(0)==3){
          next(pitch(PI/2).mul(1.114), 1).clr(red(),green()+ginc,blue());
          next(mul(0.954), 0).clr(red()+rinc,green(),blue());
          next(rot(PI/2-PI*0.01545/2), 5).clr(red(),green()+ginc2,blue());
        }
        else if(clock(0)==4){
          next(rot(PI/2-PI*0.01545/2), 5).clr(red(),green()+ginc2,blue());
        }
        else{
          next(0).clr(red()+rinc,green(),blue());
          next(rot(PI/2).pitch(-PI*0.01475/2), 4).clr(red(),green()+ginc2,blue());
        }
      }
      else if(clock(1)==3){
        if(clock(0)>=260) next(1).clr(red(),green()+ginc,blue());
        else{
          next(mul(0.997), 0).clr(red()+rinc,green(),blue());
          if(IRand.pct(1)){
            if(IRand.pct(50)){
              next(pitch(PI/4).mul(0.7), 0).clr(red()+rinc,green(),blue());
            }
            else{
              next(pitch(-PI/4).mul(0.7), 0).clr(red()+rinc,green(),blue());
            }
          }
        }
        if(IRand.pct(80)){
          next(rot(PI/2).pitch(-PI/6-PI/120), 6).clr(red(),green()+ginc2,blue());
        }
        else{
          next(rot(PI/2).pitch(-PI/6-PI/120).mul(0.5), 6).clr(red(),green()+ginc2,blue());
        }
      }
      else if(clock(1)==4){
        if(clock(0)==7) next(1).clr(red(),green()+ginc,blue()); else next(0).clr(red()+rinc,green(),blue());
        next(rot(PI/2).pitch(-PI/120), 7).clr(red(),green()+ginc2,blue());
      }
      else if(clock(1)==5){
        next(1).clr(red(),green()+ginc,blue());
      }
      else if(clock(1)==6){
        if(clock(0)==6) next(1).clr(red(),green()+ginc,blue()); else next(0).clr(red()+rinc,green(),blue());
        next(rot(PI/2).pitch(-PI/120).rot(PI/8), 8).clr(red(),green()+ginc2,blue());
      }
      else if(clock(1)==7){
        if(clock(0)==4){
          next(pitch(-PI/2), 11).clr(red(),green()+ginc,blue());
        }
        else next(0).clr(red()+rinc,green(),blue());
      }
    }
  }


     Template Code3: Imported Module Geometry


Warning: include(codepy/igeo_tutorial60_41/igeo_tutorial60_41.html): failed to open stream: No such file or directory in /home/mj7789dybiu5/public_html/igeo/tutorial/tutorial.php on line 66

Warning: include(): Failed opening 'codepy/igeo_tutorial60_41/igeo_tutorial60_41.html' for inclusion (include_path='.:/opt/alt/php56/usr/share/pear:/opt/alt/php56/usr/share/php') in /home/mj7789dybiu5/public_html/igeo/tutorial/tutorial.php on line 66

FYI: If it is too heavy or too slow to generate module geometries in the way above, you can generate only lines which suggest the locations and orientations of modules by using "makeCSLine()" method instead of "makeModule()", and then you can place module geometries inside Rhinoceros using this python script AllocateModuleToGeometryToLine.py.


     Template Code4: Module Delivdery Simulation

module_geometry1.3dm


Warning: include(codepy/igeo_tutorial60_42/igeo_tutorial60_42.html): failed to open stream: No such file or directory in /home/mj7789dybiu5/public_html/igeo/tutorial/tutorial.php on line 66

Warning: include(): Failed opening 'codepy/igeo_tutorial60_42/igeo_tutorial60_42.html' for inclusion (include_path='.:/opt/alt/php56/usr/share/pear:/opt/alt/php56/usr/share/php') in /home/mj7789dybiu5/public_html/igeo/tutorial/tutorial.php on line 66


(back to the list of tutorials)

HOME
FOR PROCESSING
DOWNLOAD
DOCUMENTS
TUTORIALS (Java / Python)
GALLERY
SOURCE CODE(GitHub)
PRIVACY POLICY
ABOUT/CONTACT