//You need these as a universal variables double dir = 1; static final double favorite = 200; //set Favorite to how far away you want to be! //this goes in onScannedRobot if(getDistanceRemaining() == 0){ dir=-dir; setAhead(300*Math.random()*dir); } setTurnRight(t.getBearing() + 90 - 90*Math.random()*dir* (t.getDistance()>favorite?1:-1));
Just set favorite to your favorite distance! --Bayen
|