Skip to content

Instantly share code, notes, and snippets.

@Mr0ok
Created December 4, 2012 21:20
Show Gist options
  • Select an option

  • Save Mr0ok/4208804 to your computer and use it in GitHub Desktop.

Select an option

Save Mr0ok/4208804 to your computer and use it in GitHub Desktop.
MR #7
//FightCode can only understand your robot
//if its class is called Robot
var found=false;
var wall=false;
var i=0;
var Robot = function(robot) {
};
Robot.prototype.onIdle = function(ev) {
var robot = ev.robot;
if(found){
robot.fire();
}else if(!found){
robot.rotateCannon(16);
robot.ahead(15);
}
i++;
if(i==200){
i=0;
found=false;
}
if(wall){
robot.turn(75)
wall=false;
}
};
Robot.prototype.onScannedRobot = function(ev) {
var robot = ev.robot;
found = true;
};
Robot.prototype.onWallCollision= function(ev){
var robot = ev.robot;
wall=true;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment