Skip to content

Instantly share code, notes, and snippets.

@puelocesar
Created December 5, 2012 18:04
Show Gist options
  • Save puelocesar/4217993 to your computer and use it in GitHub Desktop.
Save puelocesar/4217993 to your computer and use it in GitHub Desktop.
Khan
//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.ahead(50);
robot.turn(360);
robot.back(50);
};
Robot.prototype.onScannedRobot = function(ev) {
var robot = ev.robot;
// robot.stop();
robot.fire();
robot.turn(60);
robot.back(30);
robot.fire();
};
Robot.prototype.onWallCollision = function(ev) {
robot.turn(ev.bearing);
robot.ahead(50);
};
Robot.prototype.onHitByBullet = function(ev) {
var robot = ev.robot;
robot.turn(ev.bearing);
robot.back(60);
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment