Skip to content

Instantly share code, notes, and snippets.

@ticolucci
Created December 8, 2012 14:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ticolucci/4240362 to your computer and use it in GitHub Desktop.
Save ticolucci/4240362 to your computer and use it in GitHub Desktop.
MK1
//FightCode can only understand your robot
//if its class is called Robot
var Robot = function(robot) {
robot.rotateCannon(90);
};
Robot.prototype.onIdle = function(ev) {
var robot = ev.robot;
robot.ahead(50);
robot.fire();
};
Robot.prototype.onScannedRobot = function(ev) {
var robot = ev.robot;
robot.fire();
};
Robot
.prototype.onWallCollision = function(ev) {
var robot = ev.robot;
robot.turn(ev.bearing);
robot.turn(90);
};
Robot.prototype.onRobotCollision = function(ev) {
var robot = ev.robot;
var other = ev.collidedRobot;
robot.turn(180);
robot.rotateCannon(other.angle);
robot.fire();
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment