/** SBug @author Sam B 2012 */ import info.gridworld.actor.Bug; import info.gridworld.grid.Location; public class SBug extends Bug { private int steps; // the # of steps in the current side private int segment;// which segment of the W the WBug is on public SBug() { setDirection(Location.WEST); steps = 0; segment = 1; } public void act() { // SEGMENT 1 if (segment == 1 && steps < 5) { setDirection(Location.WEST); move(); steps ++; } else if (steps >= 5) { segment++; steps = 0; } //SEGMENT 2 if (segment == 2 && steps < 5) { setDirection(Location.SOUTH); move(); steps ++; } else if (steps >= 5) { segment ++; steps = 0; } //SEGMENT 3 if (segment == 3 && steps < 5) { setDirection(Location.EAST); move(); steps ++; } else if (steps >= 5) { segment++; steps = 0; } //SEGMENT 4 if (segment == 4 && steps < 5) { setDirection(Location.SOUTH); move(); steps ++; } else if (steps >= 5) { segment++; steps = 0; } //SEGMENT 5 if (segment == 5 && steps < 6) { setDirection(Location.WEST); move(); steps ++; } else if (steps >= 5) { segment++; steps = 0; } } }