Created
January 9, 2013 19:30
-
-
Save whiskers75/4496077 to your computer and use it in GitHub Desktop.
FightCode bot whiskers75
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//whiskers75's FightCode Robot | |
//Licenced under the GPLv2 or higher | |
//Forks of this may not battle this robot. | |
var Robot = function(robot) { | |
robot.log("whiskers75's robot initialized"); | |
}; | |
Robot.prototype.onIdle = function(ev) { | |
var robot = ev.robot; | |
robot.ahead(100); | |
robot.rotateCannon(45 - robot.life); | |
robot.turn(90 - robot.life); | |
robot.log("Idle..."); | |
}; | |
Robot.prototype.onScannedRobot = function(ev) { | |
var robot = ev.robot; | |
robot.fire(); | |
robot.log("Found Robot"); | |
}; | |
Robot.prototype.onWallCollision = function(ev) { | |
var robot = ev.robot; | |
robot.turn(180); // 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