Created
December 4, 2012 23:07
-
-
Save michaltaberski/4210072 to your computer and use it in GitHub Desktop.
Zolmeister
This file contains 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
//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