Skip to content

Instantly share code, notes, and snippets.

@HugoLnx
Created December 5, 2012 15:18
Show Gist options
  • Select an option

  • Save HugoLnx/4216453 to your computer and use it in GitHub Desktop.

Select an option

Save HugoLnx/4216453 to your computer and use it in GitHub Desktop.
SEXMACHINE (JESSE)
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