Skip to content

Instantly share code, notes, and snippets.

@bpinto
Created December 7, 2012 21:17
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 bpinto/4236605 to your computer and use it in GitHub Desktop.
Save bpinto/4236605 to your computer and use it in GitHub Desktop.
Grande Pinto
//FightCode can only understand your robot
//if its class is called Robot
var Robot = function(robot) {
robot.turnLeft(robot.angle % 90);
robot.clone();
this.direction = 1;
};
Robot.prototype.onIdle = function(ev) {
var robot = ev.robot;
robot.ahead(1);
if (robot.parentId) {
}
};
Robot.prototype.onWallCollision = function(ev) {
var robot = ev.robot;
if(!robot.parentId)
robot.turnRight(ev.bearing - 90);
else
robot.turnRight(ev.bearing + 90);
};
Robot.prototype.onScannedRobot = function(ev) {
var robot = ev.robot;
if (robot.id == scannedRobot.parentId || robot.parentId == scannedRobot.id) {
return;
}
robot.fire();
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment