/* Slowly moves east and west. Does not fire. */
var west = false;
while (true) {
if (west) {
if (getX() > 25) {
swim(180, 25);
} else {
west = false;
swim(0, 0);
}
} else {
if (getX() < 75) {
swim(0, 25);
} else {
west = true;
swim(0, 0);
}
}
}
/* Moves south-west when hit. Does not fire. */
var d = damage();
while (true) {
if (d != damage()) {
swim(45, 100);
var t = 0;
for (var t = 0; t < 100; t++) {}
d = damage();
stop();
}
}
Use the 'cannon' command to hit the target. The first parameter is the angle, the second parameter is the range. Find the right combination.
cannon(0, 70);
Congratulations!
Your solution works, but you can do better. Use 'scan' to tell the cannon how far to shoot.