Created
December 5, 2012 15:18
-
-
Save HugoLnx/4216453 to your computer and use it in GitHub Desktop.
SEXMACHINE (JESSE)
This file contains hidden or 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 SexMachine = function() { | |
| //FightCode can only understand your robot | |
| //if its class is called Robot | |
| var Robot = function(robot) { | |
| //robot.rotateCannon(90); | |
| }; | |
| var state = 0; | |
| var lastFound = 0; | |
| Robot.prototype.onIdle = function(ev) { | |
| var robot = ev.robot; | |
| robot.stop(); | |
| if(state === 0 || lastFound > 40) | |
| robot.turn(1); | |
| if(state === 2) { | |
| robot.turn(3); | |
| state = 3; | |
| } | |
| lastFound += 1; | |
| }; | |
| Robot.prototype.onScannedRobot = function(ev) { | |
| if(state !== 3) | |
| state = 2; | |
| var robot = ev.robot; | |
| var scanned = ev.scannedRobot; | |
| robot.stop(); | |
| robot.ahead(10); | |
| robot.fire(); | |
| robot.back(10); | |
| //robot.turn(-20); | |
| lastFound = 0; | |
| }; | |
| return Robot; | |
| }; | |
| var Robot = SexMachine(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment