Skip to content

Instantly share code, notes, and snippets.

@fwitzke
Created December 5, 2012 23:09
Show Gist options
  • Save fwitzke/4220364 to your computer and use it in GitHub Desktop.
Save fwitzke/4220364 to your computer and use it in GitHub Desktop.
stupid_bot
var Robot = function(robot) {
robot.clone();
};
var scanning=true;
Robot.prototype.onIdle = function(ev) {
var robot = ev.robot;
robot.ahead(3);
if(scanning) {
robot.turn(robot.parentId ? 2 : -2);
} else {
robot.rotateCannon(15);
robot.rotateCannon(-15);
robot.ahead(1);
scanning = true;
}
};
Robot.prototype.onScannedRobot = function(ev) {
var robot = ev.robot;
var scanned = ev.scannedRobot;
if(robot.parentId == scanned.id || robot.id == scanned.parentId) {
robot.rotateCanon(-45);
} else {
scanning = false;
robot.fire(1);
}
};
Robot.prototype.onWallCollision = function(ev) {
var robot = ev.robot;
robot.turn(90);
};
Robot.prototype.onRobotCollision = function(ev) {
var robot = ev.robot;
robot.back(80);
}
Robot.prototype.onHitByBullet = function(ev) {
var robot;
robot = ev.robot;
robot.turn(ev.bulletBearing);
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment