Skip to content

Instantly share code, notes, and snippets.

@drapello
Created December 3, 2012 14:13
Show Gist options
  • Save drapello/4195266 to your computer and use it in GitHub Desktop.
Save drapello/4195266 to your computer and use it in GitHub Desktop.
vaievolta
//FightCode can only understand your robot
//if its class is called Robot
var Robot = function(robot) {
robot.clone();
robot.turn(45);
this.offset = 1;
};
Robot.prototype.onRobotCollision = function(ev) {
var robot = ev.robot;
if (onScanned) {
return
}
robot.back(1000);
};
var onScanned;
Robot.prototype.onIdle = function(ev) {
var robot = ev.robot;
for (i=1; i<10; i++) {
robot.turn(15);
robot.fire();
robot.ahead(20);
}
onScanned = false
};
Robot.prototype.onScannedRobot = function(ev) {
var robot = ev.robot,
scannedRobot = ev.scannedRobot;
if (robot.id == scannedRobot.parentId || robot.parentId == scannedRobot.id) {
robot.turn(45);
return
}
onScanned = true
for (i=1; i<10; i++) {
robot.fire();
robot.ahead(10);
}
};
Robot.prototype.onWallCollision = function(ev) {
var robot = ev.robot;
robot.turn(robot.angle-90);
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment