Skip to content

Instantly share code, notes, and snippets.

@PycKamil
Created December 4, 2012 11:59
Show Gist options
  • Save PycKamil/4203062 to your computer and use it in GitHub Desktop.
Save PycKamil/4203062 to your computer and use it in GitHub Desktop.
Pyciu
//FightCode can only understand your robot
//if its class is called Robot
var Robot = function(robot) {
};
Robot.prototype.lastHitAngle = -1;
Robot.prototype.radius = 20;
Robot.prototype.hit = 0;
Robot.prototype.onIdle = function(ev) {
var robot = ev.robot;
this.hit = 0;
if (this.lastHitAngle < 0) {
for (var i=0; this.hit == 0 && i < 10;++i) {
robot.rotateCannon(360/10);
robot.ahead(5 + i/3);
robot.turn(360/10 + i/4);
}
}
if (this.lastHitAngle - robot.cannonAbsoluteAngle > 10) {
robot.rotateCannon(this.lastHitAngle - robot.cannonAbsoluteAngle);
}
robot.rotateCannon(this.radius);
this.radius = (-2*this.radius)%360;
if (this.hit==0) {
this.lastHitAngle = -1;
console.log("nie ma niczego");
}
robot.turn(25);
robot.ahead(60);
robot.rotateCannon(-25);
};
Robot.prototype.onScannedRobot = function(ev) {
var robot = ev.robot;
robot.fire();
};
Robot.prototype.onScannedRobot = function(ev) {
var robot = ev.robot;
robot.fire();
this.lastHitAngle = robot.cannonAbsoluteAngle;
this.radius = 10;
this.hit = this.hit +1 ;};
Robot.prototype.onHitByBullet = function(ev) {
var robot;
robot = ev.robot;
robot.turn(90 - ev.bulletBearing);
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment