Skip to content

Instantly share code, notes, and snippets.

@michaltaberski
Created December 4, 2012 23:07
Show Gist options
  • Save michaltaberski/4210072 to your computer and use it in GitHub Desktop.
Save michaltaberski/4210072 to your computer and use it in GitHub Desktop.
Zolmeister
//FightCode can only understand your robot
//if its class is called Robot
var go=120;
var Robot = function(robot) {
};
Robot.prototype.onIdle = function(ev) {
var robot = ev.robot;
var clo =0
robot.clone();
if(robot.parentId!=null){
clo=-240;
}
robot.id=2
robot.rotateCannon(90);
robot = ev.robot;
if(.6>Math.random()){
robot.ahead(go+clo);
robot.turn(95);
}
};
Robot.prototype.onScannedRobot = function(ev) {
var sr = ev.scannedRobot;
var robot = ev.robot;
var bFriendly = ( robot.parentId !=null && robot.parentId==sr.id);
bFriendly |= ( sr.parentId !=null && sr.parentId==robot.id);
if(bFriendly){
robot.back(50);
}
if(!bFriendly){
robot.fire();
robot.fire();
robot.rotateCannon(-15);
robot.fire();
robot.fire();
robot.rotateCannon(-10);
}
};
Robot.prototype.onWallCollision= function(ev){
var robot = ev.robot;
go=go*-1;
robot.back(go);
robot.rotateCannon(90);
robot.back(go);
robot.rotateCannon(90);
}
Robot.prototype.onHitByBullet = function(ev) {
var robot = ev.robot;
if(robot.parentId!=null){
robot.turn(ev.bearing);
robot.fire();
robot.fire();
robot.fire();
robot.fire();
robot.fire();
}
};
Robot.prototype.onRobotCollision = function(ev) {
var robot = ev.robot;
robot.turn(20);
robot.ahead(100); // trying to run away
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment