Skip to content

Instantly share code, notes, and snippets.

@hery84
Created December 6, 2012 18:18
Show Gist options
  • Save hery84/4226733 to your computer and use it in GitHub Desktop.
Save hery84/4226733 to your computer and use it in GitHub Desktop.
OverKill
//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.rotateCannon(-30);
var rndAhead=Math.floor((Math.random()*250)+100);
robot.ahead(rndAhead);
};
Robot.prototype.onScannedRobot = function(ev) {
var robot = ev.robot;
robot.fire();
var rndBack=Math.floor((Math.random()*250)+50);
robot.back(rndBack);
};
Robot.prototype.onRobotCollision = function(ev) {
var robot = ev.robot;
robot.stop();
robot.fire(5);
robot.rotateCannon(-5); // trying to run away
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment