Skip to content

Instantly share code, notes, and snippets.

@mwclarkson
Forked from musashix90/robot.js
Created December 3, 2012 18:37
Show Gist options
  • Save mwclarkson/4196963 to your computer and use it in GitHub Desktop.
Save mwclarkson/4196963 to your computer and use it in GitHub Desktop.
Out Of Cheese Error v2.0
//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.clone();
robot.ahead(100);
robot.rotateCannon(90);
};
Robot.prototype.onScannedRobot = function(ev) {
var robot = ev.robot;
robot.stop();
robot.fire(3);
robot.fire(5);
robot.rotateCannon(-30);
};
Robot.prototype.onWallCollision = function(ev) {
var robot = ev.robot;
robot.turn(ev.bearing+90); // turn enought to be in a straight
// angle with the wall.
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment