Skip to content

Instantly share code, notes, and snippets.

@s4ndm4ns
Created December 4, 2012 15:00
Show Gist options
  • Save s4ndm4ns/4204840 to your computer and use it in GitHub Desktop.
Save s4ndm4ns/4204840 to your computer and use it in GitHub Desktop.
AutoCannon
//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;
robot.clone();
robot.rotateCannon(360);
};
Robot.prototype.onScannedRobot = function(ev) {
var robot;
var scannedRobot;
robot = ev.robot;
scannedRobot = ev.scannedRobot;
if((robot.parentId == null && scannedRobot.parentId != robot.id)){
{
robot.fire();
robot.fire();
robot.fire();
robot.ahead(20);
robot.rotateCannon(-25);
}
}else if((robot.parentId != null && scannedRobot.id != robot.parentId)){
{
robot.fire();
robot.fire();
robot.fire();
robot.ahead(20);
robot.rotateCannon(-25);
}
}
};
Robot.prototype.onWallCollision = function(ev) {
var robot = ev.robot;
robot.ahead(200);
};
Robot.prototype.onRobotCollision = function(ev) {
var robot = ev.robot;
robot.ahead(200);
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment