Skip to content

Instantly share code, notes, and snippets.

@djcornell
Created December 8, 2012 03:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save djcornell/4238528 to your computer and use it in GitHub Desktop.
Save djcornell/4238528 to your computer and use it in GitHub Desktop.
BoogerBot
//FightCode can only understand your robot
//if its class is called Robot
var Robot = function(robot) {
};
Robot.prototype.onIdle = function(ev) {
var robot = ev.robot;
if (robot.availableClones > 0) {
robot.clone();
}
robot.ahead(30);
robot.rotateCannon(45);
};
Robot.prototype.onScannedRobot = function(ev) {
var robot = ev.robot;
if (ev.scannedRobot.parentId == robot.id) {
robot.log("not shooting clone: me: " + robot.id + " him: " + ev.scannedRobot.id);
return;
}
if (ev.scannedRobot.id == robot.parentId) {
robot.log("not shooting clone: me: " + robot.id + " him: " + ev.scannedRobot.id);
return;
}
robot.log("me: " + robot.id + " him: " + ev.scannedRobot.parentId);
robot.fire();
robot.rotateCannon(-25);
robot.back(4);
};
Robot.prototype.onWallCollision = function(ev) {
var robot = ev.robot;
robot.back(20);
robot.turn(ev.bearing - 90);
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment