Skip to content

Instantly share code, notes, and snippets.

@kspe
Created December 4, 2012 17:02
Show Gist options
  • Save kspe/4206239 to your computer and use it in GitHub Desktop.
Save kspe/4206239 to your computer and use it in GitHub Desktop.
fikufik
//FightCode can only understand your robot
//if its class is called Robot
var Robot = function(robot) {
};
Robot.prototype.onIdle = function(ev) {
var robot = ev.robot;
robot.ahead(pseudoRandom(robot.position.x,100));
robot.rotateCannon(90);
robot.back(pseudoRandom(robot.position.y,100));
robot.rotateCannon(90);
};
Robot.prototype.onScannedRobot = function(ev) {
var robot = ev.robot;
robot.fire();
};
function pseudoRandom( seed, maximum ){
n = (314159265 * seed + 2718281) % 65536;
c = Math.round( ((n / 65536) * 100) % 100 );
output = Math.floor( c/100 * maximum );
return output;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment