Created
December 5, 2012 21:39
-
-
Save tsimbalar/4219752 to your computer and use it in GitHub Desktop.
ThiBOTv1
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
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