Skip to content

Instantly share code, notes, and snippets.

@giubueno
Forked from heynemann/robot.js
Created December 3, 2012 16:39
Show Gist options
  • Save giubueno/4196172 to your computer and use it in GitHub Desktop.
Save giubueno/4196172 to your computer and use it in GitHub Desktop.
Metal Go XP
//FightCode can only understand your robot
//if its class is called Robot
var Robot = function(robot){
//robot.ignore('onRobotCollision');
};
Robot.prototype.onIdle = function(ev) {
var robot = ev.robot;
robot.turn(1);
};
Robot.prototype.onScannedRobot = function(ev) {
var robot = ev.robot;
for (var i=0; i<5; i++) {
robot.fire();
robot.ahead(15);
}
};
Robot.prototype.onWallCollision = function(ev) {
ev.robot.turn(20);
};
Robot.prototype.onRobotCollision = function(ev) {
ev.robot.turn(ev.bearing);
ev.robot.back(20);
};
Robot.prototype.onHitByBullet = function(ev) {
ev.robot.turn(ev.bearing);
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment