Skip to content

Instantly share code, notes, and snippets.

@tsimbalar
Created December 5, 2012 21:39
Show Gist options
  • Save tsimbalar/4219752 to your computer and use it in GitHub Desktop.
Save tsimbalar/4219752 to your computer and use it in GitHub Desktop.
ThiBOTv1
var lastSeenPositions = []
//FightCode can only understand your robot
//if its class is called Robot
var Robot = function(robot) {
// go straight to the wall
robot.rotateCannon(-40)
//robot.ahead(robot.arenaWidth + robot.arenaHeight);
};
Robot.prototype.onIdle = function(ev) {
var robot = ev.robot;
robot.ahead(50);
robot.rotateCannon(80);
robot.ahead(50);
robot.turn(60)
robot.ahead(50);
robot.rotateCannon(-80);
robot.turn(-60)
robot.ahead(50);
};
Robot.prototype.onScannedRobot = function(ev) {
var robot = ev.robot;
robot.fire();
var other = ev.scannedRobot;
lastSeenPositions.push(other.x)
};
Robot.prototype.onWallCollision = function(ev) {
var robot = ev.robot;
// bounc from the wall
robot.turn(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