Skip to content

Instantly share code, notes, and snippets.

@satansfate
Created December 5, 2012 17:42
Show Gist options
  • Save satansfate/4217812 to your computer and use it in GitHub Desktop.
Save satansfate/4217812 to your computer and use it in GitHub Desktop.
SatansFate
//FightCode can only understand your robot
//if its class is called Robot
var Robot = function(robot) {
};
var status = 0//0 = searching, 1 = found
Robot.prototype.onIdle = function(ev) {
var robot = ev.robot;
if(status== 0){
robot.rotateCannon(1);
}
else {
for(i=0;i<6;i++){
robot.fire();
}
robot.ahead(Math.floor(Math.random()*101));
status = 0;
}
};
Robot.prototype.onScannedRobot = function(ev) {
var robot = ev.robot;
status = 1;
robot.fire();
};
Robot.prototype.onHitByBullet = function(ev){
robot.ahead(Math.floor(Math.random()*101));
status = 0;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment