/*
 * The round switches won't stay on unless something is placed on top of them.
 */


 /**
 * Tactic: Move in these directions: >, ^, >, v, >, v, >, ^, >
 * The sensors will trigger on the big boxes, even though you can move them,
 * so you have to `disable` the sensors when pushing. The sensors will trigger
 * when you move past the small blue boxes though, use them to know when you're 
 * done pushing.
 */

var numRights = 0;
var ignoreTop = false;
var finalTurn = false;
var ignoreBottom = true;

this.on("start", function(){
  this.thrusters.bottom(true);
});

this.on("sensor:top", function(contact){
  if (!contact || ignoreTop) return;
  this.thrusters.bottom(false);
  this.thrusters.left(true);
});

this.on("sensor:right", function(contact){
  if (!contact) return;
  this.thrusters.left(false);
  numRights += 1;
  if(numRights <= 2){
    this.thrusters.top(true);
  } else {
    this.thrusters.bottom(true);
    ignoreTop = true;
  }
  if (numRights == 2){
    ignoreBottom = false;
  }
});

this.on("sensor:left", function(contact){
  if (!contact) return;
  if(finalTurn){
    this.thrusters.bottom(false);
  } else {
      this.thrusters.top(false);
      finalTurn = true;
  }
  this.thrusters.left(true);

});

this.on("sensor:bottom", function(contact){
  if (!contact || ignoreBottom) return;
  this.thrusters.left(true);
  this.thrusters.top(false);
});
@@ -84,463 +84,243 @@
 */%0A%0A
-%0A /**%0A * Tactic: Move in these directions: %3E, %5E, %3E, v, %3E, v, %3E, %5E, %3E%0A * The sensors will trigger on the big boxes, even though you can move them,%0A * so you have to %60disable%60 the sensors when pushing. The sensors will trigger%0A * when you move past the small blue boxes though, use them to know when you're %0A * done pushing.%0A */%0A%0Avar numRights = 0;%0Avar ignoreTop = 
+this.thrusters.bottom(true);%0Avar thrusters = this.thrusters;%0A%0Avar instructions = %5B%0A  %7Bstep: function (contact) %7B%0A    thrusters.bottom(
 false
+)
 ;%0A
-var finalTurn = false;%0Avar ignoreBottom = 
+    thrusters.left(
 true
+)
 ;%0A
-%0Athis.on(%22start%22, function()%7B%0A  this.
+  %7D%7D,%0A  %7Bstep: function (contact) %7B%0A    thrusters.left(false);%0A    
 thru
@@ -325,30 +325,27 @@
 rusters.
-bot
 to
-m
+p
 (true);%0A
 %7D);%0A%0Athi
@@ -340,34 +340,22 @@
 e);%0A
-%7D);%0A%0Athis.on(%22sensor:top%22,
+  %7D%7D,%0A  %7Bstep:
  fun
@@ -351,32 +351,33 @@
  %7Bstep: function
+ 
 (contact)%7B%0A  if 
@@ -373,54 +373,51 @@
 act)
+ 
 %7B%0A  
-if
+%7D%7D,%0A  %7Bstep: function
  (
-!
 contact
- %7C%7C ignoreTop) return;%0A  this.
+) %7B%0A    
 thru
@@ -414,38 +414,35 @@
 %7B%0A    thrusters.
-bot
 to
-m
+p
 (false);%0A  this.
@@ -432,29 +432,26 @@
 p(false);%0A  
-this.
+  
 thrusters.le
@@ -464,36 +464,22 @@
 e);%0A
-%7D);%0A%0Athis.on(%22sensor:right%22,
+  %7D%7D,%0A  %7Bstep:
  fun
@@ -475,32 +475,33 @@
  %7Bstep: function
+ 
 (contact)%7B%0A  if 
@@ -497,154 +497,103 @@
 act)
+ 
 %7B%0A  
-if (!contact) return;%0A  this.thrusters.left(false);%0A  numRights += 1;%0A  if(numRights %3C= 2)%7B%0A    this.thrusters.top(true);%0A  %7D else
+  thrusters.left(false);%0A    thrusters.top(true);%0A  %7D%7D,%0A  %7Bstep: function (contact)
  %7B%0A    
-this.
 thru
@@ -602,128 +602,60 @@
 ers.
-bottom(true);%0A    ignoreTop = true;%0A  %7D%0A  if (numRights == 2)%7B%0A    ignoreBottom = false;%0A  %7D%0A%7D);%0A%0Athis.on(%22sensor:left%22,
+top(false);%0A    thrusters.left(true);%0A  %7D%7D,%0A  %7Bstep:
  fun
@@ -651,32 +651,33 @@
  %7Bstep: function
+ 
 (contact)%7B%0A  if 
@@ -673,60 +673,42 @@
 act)
+ 
 %7B%0A  
-if (!contact) return;%0A  if(finalTurn)%7B%0A    this.
+  thrusters.left(false);%0A    
 thru
@@ -724,38 +724,91 @@
 tom(
-fals
+tru
 e);%0A  %7D
- else %7B%0A      this.
+%7D,%0A  %7Bstep: function (contact) %7B%0A  %7D%7D,%0A  %7Bstep: function (contact) %7B%0A    
 thru
@@ -805,35 +805,38 @@
 %7B%0A    thrusters.
+bot
 to
-p
+m
 (false);%0A      f
@@ -836,91 +836,49 @@
     
- 
- finalTurn = true;%0A  %7D%0A  this.thrusters.left(true);%0A%0A%7D);%0A%0Athis.on(%22sensor:bottom%22,
+thrusters.left(true);%0A  %7D%7D%0A%5D;%0A%0Avar next =
  fun
@@ -895,16 +895,17 @@
 act)
+ 
 %7B%0A  if (
 !con
@@ -904,99 +904,239 @@
 if (
-!
 contact
- %7C%7C ignoreBottom) return;%0A  this.thrusters.left(true
+)%7B%0A    instructions%5Bcurrent_action%5D.step(contact);%0A    current_action++;%0A  %7D%0A%7D;%0A%0Avar current_action = 0;%0A%0Athis.on('sensor:top', next);%0Athis.on('sensor:right', next);%0Athis.on('sensor:left', next
 );%0A
-  
 this.
-thrusters.top(false);%0A%7D);
+on('sensor:bottom', next);%0A

simplify 6