MY ROBOTS

ABSOLUTELY EVERYTHING ABOUT YOUR ARMY OF ROBOTS
  • # 23205
    2
    created 03/24/13 119 code lines fork
    -43 SCORE
    0 KILLS
    10 SHOTS
    2 HITS
    18.18%
    AVERAGE HITS/SHOT
    SCORE OVER TIME
    var cloned = false; var C = false; var first = 1; var direction = 0; function Robot(robot) {} // well, we need to do something... // whenever our robot is idle, this method gets called. Robot.prototype.onIdle = function(ev) { var robot = ev.robot; robot = ev.robot; if (!C) { robot.ahead(800); first = true; } if(direction = 1) { if (C) { if((robot.gunCoolDownTime) === 0) { robot.fire(); } else { robot.ahead(1); } } } if(direction = 0){ if (C) { if((robot.gunCoolDownTime) === 0) { robot.fire(); } else { robot.ahead(1); } } } }; // this method gets called whenever we hit another robot... Robot.prototype.onRobotCollision = function(ev) { robot = ev.robot; robot.back(100); robot.rotateCannon(90); robot.rotateCannon(-180); robot.rotateCannon(90); }; // this method gets called whenever we hit a wall... Robot.prototype.onWallCollision = function(ev) { robot = ev.robot; C = true; if (first == 1){ robot.turn(ev.bearing); robot.turn(90); robot.rotateCannon(90); first = 0; } if(direction == 1) { robot.ahead(1000); direction = 0; } if(direction == 0) { robot.back(1000); direction = 1; } }; // yay we see another robot! time to wreak some havoc... Robot.prototype.onScannedRobot = function(ev) { var robot = ev.robot; robot.fire(1); robot.back(30); robot.ahead(30); }; // ohhh... we were hit by another robot... Robot.prototype.onHitByBullet = function(ev) { var robot; robot = ev.robot; robot.back(300); };
  • # 2321
    AchotBrouillon
    created 03/24/13 19 code lines
    1570 SCORE
    68 KILLS
    1,818 SHOTS
    616 HITS
    33.87%
    AVERAGE HITS/SHOT
    SCORE OVER TIME
  • # 1213
    AchotecEssai
    created 02/03/13 57 code lines
    1599 SCORE
    398 KILLS
    15,134 SHOTS
    3,796 HITS
    25.08%
    AVERAGE HITS/SHOT
    SCORE OVER TIME
  • # 4693
    AchotecRobot
    created 02/26/13 85 code lines
    1503 SCORE
    520 KILLS
    15,773 SHOTS
    4,704 HITS
    29.82%
    AVERAGE HITS/SHOT
    SCORE OVER TIME
  • # 3621
    achotecSimple
    created 02/03/13 55 code lines
    1534 SCORE
    196 KILLS
    5,955 SHOTS
    1,954 HITS
    32.81%
    AVERAGE HITS/SHOT
    SCORE OVER TIME
  • # 2480
    AchotecTrial
    created 02/17/13 83 code lines
    1563 SCORE
    756 KILLS
    25,866 SHOTS
    7,192 HITS
    27.80%
    AVERAGE HITS/SHOT
    SCORE OVER TIME
  • # 22992
    ActionQueue
    created 03/24/13 60 code lines fork
    -15 SCORE
    0 KILLS
    241 SHOTS
    4 HITS
    1.65%
    AVERAGE HITS/SHOT
    SCORE OVER TIME
    //FightCode can only understand your robot //if its class is called Robot var Robot = function(robot) { this.currentTime = 0; var privateQueue = []; this.actionQueue = { add : function(inAction,inTime) { privateQueue.push( {sAction : inAction, time : inTime} ); }, tick : function(robot,inTime) { var action,time; while (inTime > 0 && privateQueue.length > 0) { action = privateQueue[0]; time = Math.min(action.time,inTime); robot[action.sAction](time); action.time -= time; if (action.time <= 0) { privateQueue.shift(); } inTime -= time; }; }, empty : function() { return privateQueue.length === 0; } }; }; Robot.prototype.onIdle = function(ev) { var robot = ev.robot; var actions = robot.gunCoolDownTime; robot.log("currentTime: " + this.currentTime); // Always fire when we can so we can keep track of time with gunCoolDownTime if(actions === 0) { robot.fire(); } else { this.currentTime += actions; // Add new actions to the queue if (this.actionQueue.empty()) { this.actionQueue.add("ahead",100); this.actionQueue.add("rotateCannon",180); this.actionQueue.add("back",100); this.actionQueue.add("rotateCannon",180); } } this.actionQueue.tick(robot,actions); }; Robot.prototype.onScannedRobot = function(ev) { var robot = ev.robot; robot.fire(); };
  • # 23094
    avlidienbrunn
    created 02/04/13 46 code lines fork
    -27 SCORE
    7 KILLS
    245 SHOTS
    55 HITS
    22.36%
    AVERAGE HITS/SHOT
    SCORE OVER TIME
    //FightCode can only understand your robot //if its class is called Robot var Robot = function(robot) { robot.rotateCannon(60); }; Robot.prototype.onIdle = function(ev) { var robot = ev.robot; robot.ahead(66); robot.fire(); robot.ahead(66); robot.turn(75); robot.rotateCannon(1); }; Robot.prototype.onScannedRobot = function(ev) { var robot = ev.robot; robot.fire(); robot.ahead(15); robot.fire(); robot.ahead(15); robot.fire(); robot.ahead(15); robot.fire(); robot.ahead(15); }; Robot.prototype.onRobotCollision = function(ev) { var robot = ev.robot; robot.fire(); robot.ahead(10); robot.fire(); }; Robot.prototype.onWallCollision = function(ev) { var robot = ev.robot; robot.rotateCannon(25); robot.turn(120); robot.fire(); robot.ahead(120); }; Robot.prototype.onHitByBullet = function(ev) { robot.back(25); robot.fire(); }
  • # 21006
    BARDICHE
    created 03/06/13 120 code lines fork
    14 SCORE
    4 KILLS
    126 SHOTS
    32 HITS
    25.20%
    AVERAGE HITS/SHOT
    SCORE OVER TIME
    var cannonR = 1; var cannonRC = 1; var cID; var turning = false; var tankColl = false; var tPre = 85; var tCancel = 40; //FightCode can only understand your robot //if its class is called Robot var Robot = function(robot) { }; Robot.prototype.onRobotCollision = function(ev) { var robot = ev.robot; var collidedRobot = ev.collidedRobot; if(collidedRobot.id!=robot.parentId&&collidedRobot.id!=cID){ tankColl= true; var cannonD = robot.angle+90-robot.cannonAbsoluteAngle; if(cannonD>180){ cannonD=180-cannonD; } robot.rotateCannon(robot.angle+90-robot.cannonAbsoluteAngle); robot.fire(5); tankColl = false; }else{ tankColl= true; robot.back(100); robot.rotateCannon(-90); tankColl= false; } //robot.turn(90); }; Robot.prototype.onWallCollision = function(ev) { var robot = ev.robot; //robot.ahead(-100); if(robot.angle%90==0){ robot.turn(90); robot.rotateCannon(20); } }; Robot.prototype.onIdle = function(ev) { var robot = ev.robot; robot.clone(); if(robot.parentId){ cID = robot.id; } if(!turning&& ((robot.angle==90&& robot.arenaWidth-robot.position.xtCancel) ||(robot.angle==180&&robot.arenaHeight-robot.position.ytCancel) ||(robot.angle==270&&robot.position.xtCancel) ||(robot.angle==0&&robot.position.ytCancel) )){ turning=true; robot.ahead(10); robot.turn(30); robot.ahead(30); robot.turn(30); robot.ahead(10); robot.turn(30); turning=false; }else if(!turning){ robot.ahead(30); if (robot.cannonRelativeAngle>=180){ if(cID == robot.id){ cannonRC = 1; }else{ cannonR = 1; } } else if (robot.cannonRelativeAngle<=0){ if(cID == robot.id){ cannonRC = -1; }else{ cannonR = -1; } } if(cID == robot.id){ robot.rotateCannon(cannonRC*20); }else{ robot.rotateCannon(cannonR*20); } if(robot.angle%90!=0){ if (robot.id==cID) { robot.turn(90-(robot.angle%90)); }else{ robot.turn(-(robot.angle%90)); } } } }; Robot.prototype.onScannedRobot = function(ev) { var robot = ev.robot; var scannedRobot = ev.scannedRobot; if(scannedRobot.id!=robot.parentId&&scannedRobot.id!=cID){ robot.fire(1); if(cID == robot.id){ robot.rotateCannon(cannonRC*-20); }else{ robot.rotateCannon(cannonR*-20); } } }; Robot.prototype.onHitByBullet = function(ev) { var robot; robot = ev.robot; if(robot.life<=40){ robot.clone(); } };
  • # 22558
    [CAELUM TEAM]Megatron
    created 02/05/13 0 code lines fork
    -13 SCORE
    6 KILLS
    359 SHOTS
    79 HITS
    21.94%
    AVERAGE HITS/SHOT
    SCORE OVER TIME
    //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.clone(); robot.ahead(100); robot.rotateCannon(360); robot.back(100); robot.rotateCannon(360); }; Robot.prototype.onScannedRobot = function(ev) { var robot = ev.robot; var scanned =ev.scannedRobot; if(scanned.id !== robot.parentId && scanned.parentId !== robot.id) { robot.fire(); robot.rotateCannon(-3); robot.rotateCannon(-30); }else{ robot.ahead(30); } }; Robot.prototype.onHitByBullet = function(ev) { var robot; robot = ev.robot; robot.turn(90 - ev.bulletBearing); robot.ahead(-50); robot.turn(60 - ev.bulletBearing); robot.back(90); }; Robot.prototype.onRobotCollision = function(ev) { var robot = ev.robot; robot.ahead(robot.position+5); robot.ahead(robot.position-15); // trying to run away };
  • # 23137
    Cannabis Lov3r
    created 02/04/13 35 code lines fork
    -30 SCORE
    0 KILLS
    6 SHOTS
    4 HITS
    57.14%
    AVERAGE HITS/SHOT
    SCORE OVER TIME
    function Robot(robot) {} // well, we need to do something... // whenever our robot is idle, this method gets called. Robot.prototype.onIdle = function(ev) { var robot; robot = ev.robot; robot.ahead(150); robot.rotateCannon(360); robot.back(100); robot.rotateCannon(360); robot.turn(20); }; // this method gets called whenever we hit another robot... Robot.prototype.onRobotCollision = function(ev) {}; // this method gets called whenever we hit a wall... Robot.prototype.onWallCollision = function(ev) {}; // yay we see another robot! time to wreak some havoc... Robot.prototype.onScannedRobot = function(ev) { var robot; robot = ev.robot; robot.fire(1); }; // ohhh... we were hit by another robot... Robot.prototype.onHitByBullet = function(ev) { var robot; robot = ev.robot; robot.turn(90 - ev.bulletBearing); };
  • # 20275
    CIRBOT
    created 02/08/13 43 code lines fork
    147 SCORE
    21 KILLS
    408 SHOTS
    178 HITS
    43.52%
    AVERAGE HITS/SHOT
    SCORE OVER TIME
    var Robot = function(robot) { }; Robot.prototype.onIdle = function(ev) { var robot = ev.robot; robot.clone(); robot.ahead(Math.floor((Math.random()*7)+4)); robot.turn(10); }; Robot.prototype.onScannedRobot = function(ev) { var robot = ev.robot; var enemy = ev.scannedRobot; var bFriendly = ( robot.parentId !=null && robot.parentId==enemy.id); bFriendly |= ( enemy.parentId !=null && enemy.parentId==robot.id); if(!bFriendly) { robot.turn(1); robot.fire(); robot.turn(-33); } }; Robot.prototype.onWallCollision = function(ev) { var robot = ev.robot; robot.turn(90 +ev.bearing); }; Robot.prototype.onRobotCollision = function(ev) { var robot = ev.robot; var enemy = ev.scannedRobot; var bFriendly = ( robot.parentId !=null && robot.parentId==enemy.id); bFriendly |= ( enemy.parentId !=null && enemy.parentId==robot.id); if(!bFriendly){ robot.fire(1); robot.fire(1); } if(bFriendly){ robot.back(Math.floor((Math.random()*55)+11)); } robot.turn(-38); }; Robot.prototype.onHitByBullet = function(ev) { var robot = ev.robot; robot.ahead(50); };
  • none
    DeathAng3l2
    created 02/04/13 269 code lines fork
    0 SCORE
    0 KILLS
    0 SHOTS
    0 HITS
    0.00%
    AVERAGE HITS/SHOT
    SCORE OVER TIME
    // Conventions: // We use angles in degrees in clock-wise fashion RobotHelpers = {}; MathHelpers = {}; RobotHelpers.cannon_rotation_direction = {}; RobotHelpers.shoot = {}; RobotHelpers.target = {}; RobotHelpers.moving_direction = {}; RobotHelpers.init = function(robot) { // Initialize helper for robot if (RobotHelpers.cannon_rotation_direction[robot.id] == undefined) { if (robot.parentId) { RobotHelpers.cannon_rotation_direction[robot.id] = -1; } else { RobotHelpers.cannon_rotation_direction[robot.id] = 1; } } if (RobotHelpers.shoot[robot.id] == undefined) { RobotHelpers.shoot[robot.id] = 0; } if (RobotHelpers.moving_direction[robot.id] == undefined) { if (robot.parentId) { RobotHelpers.moving_direction[robot.id] = -1; } else { RobotHelpers.moving_direction[robot.id] = 1; } } if (!(robot.id in RobotHelpers.target)) { RobotHelpers.target[robot.id] = undefined; } }; RobotHelpers.aim_at = function(robot, target) { // We are rotating the cannon to aim at the target // Create the "cannon line" var cannon_point = {}; cannon_point.x = robot.position.x - 1; cannon_point.y = robot.position.y; cannon_point = MathHelpers.rotate_point(robot.position, cannon_point, robot.cannonAbsoluteAngle); // Calculate angle between canon and the target var cannon_target_angle = MathHelpers.signed_angle([robot.position, cannon_point], [robot.position, target]); // Rotate cannon - rotation is done in the shortest possible path if (cannon_target_angle > 0) { robot.rotateCannon(1); RobotHelpers.cannon_rotation_direction[robot.id] = 1; } if (cannon_target_angle < 0) { robot.rotateCannon(-1); RobotHelpers.cannon_rotation_direction[robot.id] = -1; } } RobotHelpers.approach_target = function(robot, target, angle) { // We are turning to approach target at specified angle // Create the "up line" var up_point = {}; up_point.x = robot.position.x; up_point.y = robot.position.y - 1; up_point = MathHelpers.rotate_point(robot.position, up_point, robot.angle); // Calculate angle between roboto and the target var robot_target_angle = MathHelpers.signed_angle([robot.position, up_point], [robot.position, target]); // Rotate robot - rotation is done in the shortest possible path // Ugly copy and paste engineering if (Math.abs(robot_target_angle) < angle) { if (robot_target_angle > 0) { robot.turn(-1); } if (robot_target_angle < 0) { robot.turn(1); } } if (Math.abs(robot_target_angle) > angle) { if (robot_target_angle > 0) { robot.turn(1); } if (robot_target_angle < 0) { robot.turn(-1); } } } RobotHelpers.search_and_destroy = function(robot) { if (RobotHelpers.target[robot.id]) { // Aim at target RobotHelpers.aim_at(robot, RobotHelpers.target[robot.id]); var robot_target_dist = MathHelpers.euclidean_distance(robot.position, RobotHelpers.target[robot.id]); // We try to approach him fast, and finish slowly if (robot_target_dist > 300) { if (RobotHelpers.moving_direction[robot.id] > 0) { RobotHelpers.approach_target(robot, RobotHelpers.target[robot.id], 60); } else { RobotHelpers.approach_target(robot, RobotHelpers.target[robot.id], 240); } } else { if (RobotHelpers.moving_direction[robot.id] > 0) { RobotHelpers.approach_target(robot, RobotHelpers.target[robot.id], 110); } else { RobotHelpers.approach_target(robot, RobotHelpers.target[robot.id], 290); } } } else { robot.rotateCannon(RobotHelpers.cannon_rotation_direction[robot.id]); robot.turn(RobotHelpers.cannon_rotation_direction[robot.id]); } if (RobotHelpers.shoot[robot.id] == 0) { RobotHelpers.target[robot.id] = undefined; } else { if (robot.gunCoolDownTime == 0) { --RobotHelpers.shoot[robot.id]; robot.fire(); } } }; RobotHelpers.move = function(robot, distance) { if (RobotHelpers.moving_direction[robot.id] > 0) { robot.ahead(distance); } if (RobotHelpers.moving_direction[robot.id] < 0) { robot.back(distance); } }; MathHelpers.__pi_over_180 = 0.01745329251; MathHelpers.__180_over_pi = 57.2957795131; MathHelpers.deg2rad = function(angle) { return angle * MathHelpers.__pi_over_180; }; MathHelpers.rad2deg = function(angle) { return angle * MathHelpers.__180_over_pi; }; MathHelpers.euclidean_distance = function(p1, p2) { return Math.sqrt(Math.pow(p1.x - p2.x, 2) + Math.pow(p1.y - p2.y, 2) ); }; MathHelpers.signed_angle = function(line1, line2) { // Use Perp-Dot Product var a = {x: line1[1].x - line1[0].x, y: line1[1].y - line1[0].y}; var b = {x: line2[1].x - line2[0].x, y: line2[1].y - line2[0].y}; return MathHelpers.rad2deg(Math.atan2(a.x * b.y - a.y * b.x, a.x * b.x + a.y * b.y)); }; MathHelpers.rotate_point = function(o, p, angle) { var theta = MathHelpers.deg2rad(angle); var x = Math.cos(theta) * (p.x - o.x) - Math.sin(theta) * (p.y - o.y) + o.x; var y = Math.sin(theta) * (p.x - o.x) + Math.cos(theta) * (p.y - o.y) + o.y; return {x: x, y: y}; }; var Robot = function(robot) { robot.clone(); }; Robot.prototype.onIdle = function(ev) { var robot = ev.robot; RobotHelpers.init(robot); // Slow movement, fast rotation when no target if (RobotHelpers.target[robot.id]) { RobotHelpers.move(robot, 3); } else { // Fast movement when target locked RobotHelpers.move(robot, 1); } RobotHelpers.search_and_destroy(robot); }; Robot.prototype.onRobotCollision = function(ev) { var robot = ev.robot; var collided_robot = ev.collidedRobot; robot.ignore('onRobotCollision'); RobotHelpers.moving_direction[robot.id] *= -1; if (collided_robot.parentId != robot.id && collided_robot.id != robot.parentId) { for (var robot_id in RobotHelpers.target) { // If someone robot does not have target then show one to it if (RobotHelpers.target[robot_id] == undefined || robot_id == robot.id) { RobotHelpers.target[robot_id] = collided_robot.position; } } } robot.listen('onRobotCollision'); }; Robot.prototype.onWallCollision = function(ev) { var robot = ev.robot; robot.ignore('onWallCollision'); RobotHelpers.moving_direction[robot.id] *= -1; if (ev.bearing > 0) { robot.turn(-30 * RobotHelpers.moving_direction[robot.id]); //robot.rotateCannon(30 * RobotHelpers.moving_direction[robot.id]); } else { robot.turn(30 * RobotHelpers.moving_direction[robot.id]); //robot.rotateCannon(-30 * RobotHelpers.moving_direction[robot.id]); } RobotHelpers.move(robot, 100); robot.listen('onWallCollision'); }; Robot.prototype.onScannedRobot = function(ev) { var robot = ev.robot; var scanned_robot = ev.scannedRobot; if (scanned_robot.parentId != robot.id && scanned_robot.id != robot.parentId) { for (var robot_id in RobotHelpers.target) { // If someone robot does not have target then show one to it if (RobotHelpers.target[robot_id] == undefined || robot_id == robot.id) { RobotHelpers.target[robot_id] = scanned_robot.position; } RobotHelpers.shoot[robot.id] = 2; } } }; Robot.prototype.onHitByBullet = function(ev) { var robot = ev.robot; robot.ignore('onHitByBullet'); if (ev.bearing > 0) { robot.turn(-30 * RobotHelpers.moving_direction[robot.id]); //robot.rotateCannon(30 * RobotHelpers.moving_direction[robot.id]); } else { robot.turn(30 * RobotHelpers.moving_direction[robot.id]); //robot.rotateCannon(-30 * RobotHelpers.moving_direction[robot.id]); } RobotHelpers.move(robot, 100); robot.listen('onHitByBullet'); };
  • # 23239
    Def X
    created 02/17/13 54 code lines fork
    -46 SCORE
    1 KILLS
    47 SHOTS
    19 HITS
    39.58%
    AVERAGE HITS/SHOT
    SCORE OVER TIME
    //FightCode can only understand your robot //if its class is called Robot var Robot = function(robot) { robot.clone(); robot.turn(45); robot.ahead(200); robot.turn(85); robot.ahead(100); }; Robot.prototype.onIdle = function(ev) { var robot = ev.robot; robot.turnRight(1); robot.ahead(5); }; Robot.prototype.onScannedRobot = function(ev) { var robot = ev.robot; var enemy = ev.scannedRobot; if (robot.id == enemy.parentId || robot.parentId == enemy.id) { return; } robot.fire(); robot.turnLeft(24); }; Robot.prototype.onRobotCollision = function(ev) { var robot = ev.robot; robot.fire(); robot.back(100); robot.rotateCannon(15); robot.fire(); robot.rotateCannon(-15); robot.turn(115); }; Robot.prototype.onWallCollision = function(ev) { var robot = ev.robot; robot.turn(180); }; Robot.prototype.onHitByBullet = function(ev) { var robot; robot = ev.robot; robot.back(100); robot.turn(90); robot.ahead(50); };
  • # 20521
    DELETE
    created 03/17/13 1 code lines fork
    52 SCORE
    6 KILLS
    80 SHOTS
    45 HITS
    55.56%
    AVERAGE HITS/SHOT
    SCORE OVER TIME
    function Robot() {} Robot.prototype.onIdle = function(ev) { var robot; robot = ev.robot; if (robot.availableClones >= 1) { robot.clone(); robot.ahead(50); } robot.ahead(1); robot.turn(1); robot.rotateCannon(1); }; Robot.prototype.onScannedRobot = function(ev) { var robot = ev.robot var scannedRobot = ev.scannedRobot; if (robot.parentId != scannedRobot.id && scannedRobot.parentId != robot.id) { robot.fire(); robot.rotateCannon(-10); robot.ahead(30); } }; Robot.prototype.onRobotCollision = function(ev) { var robot = ev.robot; robot.turn(20); robot.back(100); }; Robot.prototype.onWallCollision = function(ev) { var robot = ev.robot; robot.turn(20); robot.back(100); };
  • # 20336
    DELETE
    created 03/04/13 1 code lines fork
    91 SCORE
    18 KILLS
    505 SHOTS
    162 HITS
    32.02%
    AVERAGE HITS/SHOT
    SCORE OVER TIME
    function Robot() {} Robot.prototype.onIdle = function(ev) { var robot; robot = ev.robot; if (robot.availableClones >= 1) { robot.clone(); robot.ahead(50); } robot.ahead(1); robot.turn(1); robot.rotateCannon(1); }; Robot.prototype.onScannedRobot = function(ev) { var robot = ev.robot var scannedRobot = ev.scannedRobot; if (robot.parentId != scannedRobot.id && scannedRobot.parentId != robot.id) { robot.fire(); robot.rotateCannon(-10); robot.ahead(30); } }; Robot.prototype.onRobotCollision = function(ev) { var robot = ev.robot; robot.turn(20); robot.back(100); }; Robot.prototype.onWallCollision = function(ev) { var robot = ev.robot; robot.turn(20); robot.back(100); };
  • # 21056
    derp
    created 02/17/13 0 code lines fork
    5 SCORE
    15 KILLS
    386 SHOTS
    124 HITS
    32.04%
    AVERAGE HITS/SHOT
    SCORE OVER TIME
    var Robot = function(robot){ robot.turnLeft(robot.angle % 90); }; Robot.prototype.onIdle = function(ev) { var robot = ev.robot; if (robot.parentId) { robot.ahead(1); robot.turnGunRight(1); } else { robot.ahead(-1); robot.turnGunLeft(1); } }; Robot.prototype.onWallCollision = function(ev) { var robot = ev.robot; if(!robot.parentId) { robot.turnRight(ev.bearing - 90); } else { robot.turnRight(ev.bearing + 90); } }; Robot.prototype.onRobotCollision = function(ev) { var robot = ev.robot, collidedRobot = ev.collidedRobot; robot.ignore('onRobotCollision') if (ev.bearing > -90 && ev.bearing < 90) { robot.back(100); } else { robot.ahead(100); } if (robot.id != collidedRobot.parentId && robot.parentId != collidedRobot.id) { robot.turnGunRight(ev.bearing - robot.cannonRelativeAngle); robot.turnGunLeft(ev.bearing - robot.cannonRelativeAngle); } robot.listen('onRobotCollision') }; Robot.prototype.onHitByBullet = function(ev) { var robot; robot.clone() robot = ev.robot; robot.turn(45 - ev.bulletBearing); robot.ahead(-50); robot.turn(45 - ev.bulletBearing); robot.back(90); }; Robot.prototype.onScannedRobot = function(ev) { var robot = ev.robot, scannedRobot = ev.scannedRobot; if (robot.id == scannedRobot.parentId || robot.parentId == scannedRobot.id) { return; } robot.fire(); robot.turnGunRight(30); };
  • # 22560
    DESTROJER 2.0
    created 03/15/13 39 code lines fork
    -14 SCORE
    12 KILLS
    246 SHOTS
    90 HITS
    36.44%
    AVERAGE HITS/SHOT
    SCORE OVER TIME
    var Robot = function(robot) { }; Robot.prototype.onIdle = function(ev) { var robot = ev.robot; robot.rotateCannon(5); robot.ahead(5); }; Robot.prototype.onScannedRobot = function(ev) { var robot = ev.robot; var enemy = ev.scannedRobot; var bFriendly = ( robot.parentId !=null && robot.parentId==enemy.id); bFriendly |= ( enemy.parentId !=null && enemy.parentId==robot.id); if(!bFriendly){ robot.fire(); robot.rotateCannon(-25); }; }; Robot.prototype.onHitByBullet = function(ev) { var robot = ev.robot; robot.clone(); robot.turn(ev.bearing+90); robot.back(150); }; Robot.prototype.onWallCollision = function(ev) { var robot = ev.robot; robot.turn(ev.bearing+90); }; Robot.prototype.onRobotCollision = function(ev) { var robot = ev.robot; robot.turn(ev.bearing+90); };
  • # 23074
    DOJOBOT_0.1
    created 02/04/13 87 code lines fork
    -22 SCORE
    8 KILLS
    431 SHOTS
    87 HITS
    20.14%
    AVERAGE HITS/SHOT
    SCORE OVER TIME
    //FightCode can only understand your robot //if its class is called Robot var Robot = function(robot) { this.state = 'procurando'; }; Robot.prototype.onIdle = function(ev) { var robot = ev.robot; //robot.clone(); if(this.state=='procurando'){ robot.rotateCannon(30); robot.fire(2); } else if (this.state=='quicando') { var divide = 5; var p1 = (0.0+this.angulo_carro)/divide; var p2 = (0.0+this.angulo_arma)/divide; robot.turn(p1); robot.rotateCannon(p2); this.angulo_carro_virado += p1; this.angulo_arma_virado += p2; if(Math.abs(this.angulo_carro)<=Math.abs(this.angulo_carro_virado)){ this.state = 'procurando'; } } else{ robot.rotateCannon(-30); this.state='procurando'; } robot.ahead(20); //robot.ahead(30); //robot.turn(30); //robot.rotateCannon(30); //robot.back(100); //robot.rotateCannon(360); //robot.clone(); }; Robot.prototype.onScannedRobot = function(ev) { var robot = ev.robot; this.state = 'frau'; robot.fire(2); //robot.rotateCannon(10); }; Robot.prototype.onHitByBullet = function(ev) { var robot; robot = ev.robot; //robot.ahead(30); //robot.turn(90 - ev.bulletBearing); }; Robot.prototype.onWallCollision = function(ev) { var robot = ev.robot; //robot.turn(180-ev.bearing); //robot.rotateCannon(ev.bearing) if (this.state != 'quicando') { var angulo; if(ev.bearing>0) angulo = -180+2*ev.bearing; else angulo = +180+2*ev.bearing; this.state = 'quicando'; this.angulo_carro = angulo; this.angulo_arma = -angulo; this.angulo_carro_virado = 0.0; this.angulo_arma_virado = 0.0; robot.log(this.angulo_carro); } };
  • # 21047
    DOJOBOT_0.1
    created 02/04/13 87 code lines fork
    6 SCORE
    14 KILLS
    1,202 SHOTS
    179 HITS
    14.88%
    AVERAGE HITS/SHOT
    SCORE OVER TIME
    //FightCode can only understand your robot //if its class is called Robot var Robot = function(robot) { this.state = 'procurando'; }; Robot.prototype.onIdle = function(ev) { var robot = ev.robot; //robot.clone(); if(this.state=='procurando'){ robot.rotateCannon(30); robot.fire(2); } else if (this.state=='quicando') { var divide = 5; var p1 = (0.0+this.angulo_carro)/divide; var p2 = (0.0+this.angulo_arma)/divide; robot.turn(p1); robot.rotateCannon(p2); this.angulo_carro_virado += p1; this.angulo_arma_virado += p2; if(Math.abs(this.angulo_carro)<=Math.abs(this.angulo_carro_virado)){ this.state = 'procurando'; } } else{ robot.rotateCannon(-30); this.state='procurando'; } robot.ahead(20); //robot.ahead(30); //robot.turn(30); //robot.rotateCannon(30); //robot.back(100); //robot.rotateCannon(360); //robot.clone(); }; Robot.prototype.onScannedRobot = function(ev) { var robot = ev.robot; this.state = 'frau'; robot.fire(2); //robot.rotateCannon(10); }; Robot.prototype.onHitByBullet = function(ev) { var robot; robot = ev.robot; //robot.ahead(30); //robot.turn(90 - ev.bulletBearing); }; Robot.prototype.onWallCollision = function(ev) { var robot = ev.robot; //robot.turn(180-ev.bearing); //robot.rotateCannon(ev.bearing) if (this.state != 'quicando') { var angulo; if(ev.bearing>0) angulo = -180+2*ev.bearing; else angulo = +180+2*ev.bearing; this.state = 'quicando'; this.angulo_carro = angulo; this.angulo_arma = -angulo; this.angulo_carro_virado = 0.0; this.angulo_arma_virado = 0.0; robot.log(this.angulo_carro); } };
  • # 23224
    Dr_doom
    created 02/04/13 56 code lines fork
    -44 SCORE
    0 KILLS
    0 SHOTS
    0 HITS
    0.00%
    AVERAGE HITS/SHOT
    SCORE OVER TIME
    //FightCode can only understand your robot //if its class is called Robot var Robot = function(robot) { robot.rotateCannon(60); robot.forward = false; var walled = false; }; Robot.prototype.onIdle = function(ev) { var robot = ev.robot; for(i=0;i<100;i++){ robot.ahead(2); if(this.walled){ if(robot.cannonRelativeAngle >= 180){ robot.rotateCannon(-1); }else{ robot.rotateCannon(1); } }else{ robot.rotateCannon(2); } } }; Robot.prototype.onScannedRobot = function(ev) { var robot = ev.robot; var scanned = ev.scannedRobot; if(scanned.id != robot.parentId && scanned.parentId != robot.id){ robot.ignore("onWallCollision"); robot.fire(); robot.ahead(15); robot.fire(); robot.back(25); robot.fire(); robot.ahead(15); robot.listen("onWallCollision"); } }; Robot.prototype.onRobotCollision = function(ev) { var robot = ev.robot; robot.back(20); robot.fire(); }; Robot.prototype.onWallCollision = function(ev) { var robot = ev.robot; robot.turn(ev.bearing + 90); robot.ahead(20); this.walled = true; }; Robot.prototype.onHitByBullet = function(ev) { robot.clone(); }
  • # 20373
    Fanta Uva
    created 03/06/13 42 code lines fork
    77 SCORE
    9 KILLS
    193 SHOTS
    49 HITS
    25.26%
    AVERAGE HITS/SHOT
    SCORE OVER TIME
    var Robot = function(robot) { // var robot = ev.robot; } Robot.prototype.onIdle = function(ev) { var robot = ev.robot; robot.clone(); robot.rotateCannon(360); robot.turn(360) // robot.ahead(100); // robot.back(100) }; Robot.prototype.onScannedRobot = function(ev) { var robot = ev.robot; var scanned =ev.scannedRobot; if(scanned.id !== robot.parentId && scanned.parentId !== robot.id) { robot.fire(); robot.rotateCannon(-25); robot.ahead(10); }else{ // robot.back(50); } }; Robot.prototype.onHitByBullet = function(ev) { var robot; robot = ev.robot; robot.turn(90 - ev.bulletBearing); robot.ahead(30); }; Robot.prototype.onWallCollision = function(ev) { var robot = ev.robot; robot.turn(ev.bearing); // turn enought to be in a straight robot.back(100); // angle with the wall. };
  • # 20299
    Fanta Uva
    created 03/08/13 42 code lines fork
    119 SCORE
    23 KILLS
    730 SHOTS
    205 HITS
    28.04%
    AVERAGE HITS/SHOT
    SCORE OVER TIME
    var Robot = function(robot) { // var robot = ev.robot; } Robot.prototype.onIdle = function(ev) { var robot = ev.robot; robot.clone(); robot.rotateCannon(360); robot.turn(360) // robot.ahead(100); // robot.back(100) }; Robot.prototype.onScannedRobot = function(ev) { var robot = ev.robot; var scanned =ev.scannedRobot; if(scanned.id !== robot.parentId && scanned.parentId !== robot.id) { robot.fire(); robot.rotateCannon(-25); robot.ahead(10); }else{ // robot.back(50); } }; Robot.prototype.onHitByBullet = function(ev) { var robot; robot = ev.robot; robot.turn(90 - ev.bulletBearing); robot.ahead(30); }; Robot.prototype.onWallCollision = function(ev) { var robot = ev.robot; robot.turn(ev.bearing); // turn enought to be in a straight robot.back(100); // angle with the wall. };
  • # 20430
    Fanta Uva
    created 03/08/13 42 code lines fork
    64 SCORE
    14 KILLS
    423 SHOTS
    109 HITS
    25.71%
    AVERAGE HITS/SHOT
    SCORE OVER TIME
    var Robot = function(robot) { // var robot = ev.robot; } Robot.prototype.onIdle = function(ev) { var robot = ev.robot; robot.clone(); robot.rotateCannon(360); robot.turn(360) // robot.ahead(100); // robot.back(100) }; Robot.prototype.onScannedRobot = function(ev) { var robot = ev.robot; var scanned =ev.scannedRobot; if(scanned.id !== robot.parentId && scanned.parentId !== robot.id) { robot.fire(); robot.rotateCannon(-25); robot.ahead(10); }else{ // robot.back(50); } }; Robot.prototype.onHitByBullet = function(ev) { var robot; robot = ev.robot; robot.turn(90 - ev.bulletBearing); robot.ahead(30); }; Robot.prototype.onWallCollision = function(ev) { var robot = ev.robot; robot.turn(ev.bearing); // turn enought to be in a straight robot.back(100); // angle with the wall. };
  • # 21905
    GrosBoss
    created 04/06/13 38 code lines
    0 SCORE
    2 KILLS
    225 SHOTS
    22 HITS
    9.74%
    AVERAGE HITS/SHOT
    SCORE OVER TIME
  • # 20504
    IsinBot
    created 03/24/13 94 code lines fork
    57 SCORE
    11 KILLS
    310 SHOTS
    83 HITS
    26.69%
    AVERAGE HITS/SHOT
    SCORE OVER TIME
    /* * It would be great if you fork & upgrade * created by; Zolmeister * edited by: Isinlor * - added clone * - upgrade of aim - for cloned robot * - upgrade of aim - counting missed attack and adaptation * - upgrade of dodge - move according to the hp * edited by: type your nickname * - what you changed - description * TODO; RobotCollision - it sucks * shooting when you are next to wall and in front of enemy * shooting when enemy robot is going around in wrong direction * upgrade of dodge of enemy attacks when robots are facing each other */ var count = 0; var savedEnemyLife = 0; var turnDirections = 1; var Robot = function(robot){ robot.clone(); robot.turnLeft(robot.angle % 90); }; Robot.prototype.onIdle = function(ev) { var robot = ev.robot; if (robot.parentId) { robot.ahead(1*turnDirections); robot.turnGunRight(1*turnDirections); } else { robot.ahead(-1*turnDirections); robot.turnGunLeft(1*turnDirections); } }; Robot.prototype.onWallCollision = function(ev) { var robot = ev.robot; if(!robot.parentId) { robot.turnRight(ev.bearing - 90); } else { robot.turnRight(ev.bearing + 90); } }; Robot.prototype.onRobotCollision = function(ev) { var robot = ev.robot, collidedRobot = ev.collidedRobot; robot.ignore('onRobotCollision'); if (ev.bearing > -90 && ev.bearing < 90) { robot.back(100); } else { robot.ahead(100); } if (robot.id != collidedRobot.parentId && robot.parentId != collidedRobot.id) { robot.turnGunRight(ev.bearing - robot.cannonRelativeAngle); robot.turnGunLeft(ev.bearing - robot.cannonRelativeAngle); } robot.listen('onRobotCollision') }; Robot.prototype.onHitByBullet = function(ev) { var robot; robot = ev.robot; robot.ahead(120-robot.life); // robot.turn(45 - ev.bulletBearing); // robot.ahead(-50); // robot.turn(45 - ev.bulletBearing); // robot.back(90); }; Robot.prototype.onScannedRobot = function(ev) { var robot = ev.robot, scannedRobot = ev.scannedRobot; if (robot.id == scannedRobot.parentId || robot.parentId == scannedRobot.id) { return; } if(count > 5){ count = 0; robot.log('5 miss'); if (robot.parentId) { robot.turnGunRight(7); } else { robot.turnGunLeft(7); } } robot.fire(); if(savedEnemyLife == scannedRobot.life){ count +=1; } else { count = 0; } savedEnemyLife = scannedRobot.life; if (robot.parentId) { robot.turnGunLeft(30); } else { robot.turnGunRight(30); } };
  • # 22503
    Merry Go round
    created 02/17/13 0 code lines fork
    -4 SCORE
    16 KILLS
    336 SHOTS
    171 HITS
    50.74%
    AVERAGE HITS/SHOT
    SCORE OVER TIME
    //FightCode can only understand your robot //if its class is called Robot var Robot = function(robot){ //robot.clone(); this.robotOptions = { clone: { canStartFight: false, goBackOnCollision: false } }; }; Robot.prototype.onIdle = function(ev) { var robot = ev.robot; if (robot.parentId == null) { robot.turn(1); } else { if (this.robotOptions.clone.canStartFight) { robot.turn(1); } else { robot.back(100); this.robotOptions.clone.canStartFight = true; } } }; Robot.prototype.onScannedRobot = function(ev) { var robot = ev.robot, scannedRobot = ev.scannedRobot; //if (robot.id == scannedRobot.parentId || robot.parentId == scannedRobot.id) { //return; //} for (var i=0; i<5; i++) { robot.fire(); robot.ahead(10); } }; Robot.prototype.onWallCollision = function(ev) { ev.robot.turn(10); }; Robot.prototype.onRobotCollided = function(ev) { if (ev.robot.parentId == null) { ev.robot.back(20); } else { ev.robot.ahead(20); } }; Robot.prototype.onHitByBullet = function(ev) { ev.robot.turn(ev.bearing); };
  • # 20281
    M.O.N.S.T.E.R
    created 02/26/13 224 code lines fork
    140 SCORE
    38 KILLS
    1,837 SHOTS
    355 HITS
    19.31%
    AVERAGE HITS/SHOT
    SCORE OVER TIME
    var x_target = -1; var y_target = -1; var target_valid = false; var idle_counter = 0; var time_frame = 0; var last_reverse = -10000; var last_turn = -10000; var at_wall = false; var clockwise = true; var first_run = true; var cannon_clockwise_scan = false; var last_cannon_clockwise_scan = false; var scan_count = 0; var debug = 0; var Robot = function(robot) { if(!debug) robot.clone(); }; Robot.prototype.ndeg=function(deg) { return (deg%360+360)%360; }; Robot.prototype.in_range=function(deg, deg_start, deg_end) { return this.ndeg(deg - deg_start) <= this.ndeg(deg_end - deg_start); }; Robot.prototype.onIdle = function(ev) { var robot = ev.robot; if(first_run && robot.parentId != null) { robot.turn(90); first_run = false; } //robot.rotateCannon(-0.0005); //i'll add a clone but i need to refactor collision //robot.clone(); var x = robot.position.x; var y = robot.position.y; var pi = Math.PI; var dx = x_target - x; var dy = y_target - y; //var degree = Math.atan2(dy,dx)*180/pi; var distance = Math.sqrt(dx*dx+dy*dy); var angle = Math.atan2(dx,-dy)*180/pi; var canon_angle = robot.cannonAbsoluteAngle - 90; if(idle_counter > 60) { target_valid = false; idle_counter = 0; } if(!at_wall && robot.parentId == null) { //x_target = robot.arenaWidth / 2; //y_target = robot.arenaHeight / 2; var width = robot.arenaWidth; var height = robot.arenaHeight; x_ahead = x <= width / 2; y_ahead = y <= height / 2; var cos = Math.cos(robot.angle); var sin = Math.sin(robot.angle); var disX = (x_ahead ? x : (width - x)) / Math.abs(sin); var disY = (y_ahead ? y : (height - y)) / Math.abs(cos); //clockwise = (disX < disY) ? (x_ahead ^ (sin<0)) :(y_ahead ^ (cos<0)); clockwise = (disX < disY) ? (!x_ahead) :(!y_ahead); //console.log(clockwise,(disX < disY),x,y,robot.angle,disX,disY); robot.log(clockwise,(disX < disY)); //robot.turn(-robot.angle+180); clockwise ? robot.back(500) : robot.ahead(500); } else { clockwise ? robot.back() : robot.ahead(); } if(!target_valid ||debug) { if(x_target != -1 && scan_count < 2 || debug) { //search in range var range_width = 500/2 + 200*scan_count; var range_degree = Math.atan(range_width/distance)*180/pi; var max_deg = this.ndeg(angle + range_degree); var min_deg = this.ndeg(angle - range_degree); var th_deg = this.ndeg(angle + 180); if(this.in_range(canon_angle, max_deg, th_deg)) { //over max range cannon_clockwise_scan = false; //robot.log(max_deg,min_deg,th_deg); } else if(this.in_range(canon_angle, th_deg, min_deg)) { cannon_clockwise_scan = true; //robot.log(max_deg,min_deg,th_deg,"max"); } if(last_cannon_clockwise_scan != cannon_clockwise_scan) scan_count++; last_cannon_clockwise_scan = cannon_clockwise_scan; } //x_target = robot.arenaWidth / 2; //y_target = robot.arenaHeight / 2; /*if(x<20 && robot.cannonAbsoluteAngle >= 135 && robot.cannonAbsoluteAngle <= 135+90) { robot.rotateCannon(-90); } */ robot.rotateCannon(cannon_clockwise_scan ? 1 : -1); } else { //var ddeg = (degree+180-robot.cannonAbsoluteAngle+180 + 360*10)%360-180; var ddeg = this.ndeg(angle-canon_angle+180)-180; robot.rotateCannon(ddeg); idle_counter++; } //if(!debug && at_wall && x_target != -1) // robot.fire(); time_frame++; //if (ddeg > 10 || ddeg < 10) // console.log(ddeg,idle_counter); }; Robot.prototype.onScannedRobot = function(ev) { var robot = ev.robot; var scanned =ev.scannedRobot; if(scanned.id !== robot.parentId && scanned.parentId !== robot.id) { if(!debug)robot.fire(); //robot.rotateCannon(-10); //robot.rotateCannon(15); if(scanned.parentId == null) { x_target = scanned.position.x; y_target = scanned.position.y; target_valid = true; scan_count = 0; idle_counter = 0; } }else{ } time_frame++; }; Robot.prototype.onHitByBullet = function(ev) { var robot = ev.robot; if (this.in_range(ev.bearing, -15, 15) || this.in_range(ev.bearing+180, -15, 15)) { //var turndeg = (ev.bearing+45+180+360*10)%360-180 var bearing_angle = this.ndeg(ev.bearing+180)-180; //if(Math.abs(bearing_angle)>90) bearing_angle %= 90; var turn_angle = bearing_angle > 0 ? -90+bearing_angle : 90+bearing_angle; robot.turn(turn_angle); robot.log('ct', ev.bearing); } else robot.log('nct', this.ndeg(ev.bearing)); if(robot.parentId == null && time_frame - last_reverse > 100 && time_frame - last_turn > 150) { clockwise = !clockwise; last_reverse = time_frame; } if(at_wall) { clockwise ? robot.back(150) : robot.ahead(150); } else { clockwise ? robot.back(150) : robot.ahead(150); } }; Robot.prototype.onRobotCollision = function(ev) { var robot = ev.robot; //robot.rotateCannon(90); //if(ev.myFault) if(robot.parentId == null) clockwise = -clockwise; }; Robot.prototype.onWallCollision = function(ev) { var robot = ev.robot; //robot.turn(-90+ev.bearing); var turn_angle = this.ndeg(-90+ev.bearing+180)-180; if(Math.abs(turn_angle) > 90) turn_angle %= 90; robot.turn(turn_angle); robot.log('wall', clockwise, turn_angle); if(at_wall) last_turn = time_frame; at_wall = true; };
  • # 23142
    M.O.N.S.T.E.R
    created 03/24/13 224 code lines fork
    -30 SCORE
    0 KILLS
    22 SHOTS
    7 HITS
    30.44%
    AVERAGE HITS/SHOT
    SCORE OVER TIME
    var x_target = -1; var y_target = -1; var target_valid = false; var idle_counter = 0; var time_frame = 0; var last_reverse = -10000; var last_turn = -10000; var at_wall = false; var clockwise = true; var first_run = true; var cannon_clockwise_scan = false; var last_cannon_clockwise_scan = false; var scan_count = 0; var debug = 0; var Robot = function(robot) { if(!debug) robot.clone(); }; Robot.prototype.ndeg=function(deg) { return (deg%360+360)%360; }; Robot.prototype.in_range=function(deg, deg_start, deg_end) { return this.ndeg(deg - deg_start) <= this.ndeg(deg_end - deg_start); }; Robot.prototype.onIdle = function(ev) { var robot = ev.robot; if(first_run && robot.parentId != null) { robot.turn(90); first_run = false; } //robot.rotateCannon(-0.0005); //i'll add a clone but i need to refactor collision //robot.clone(); var x = robot.position.x; var y = robot.position.y; var pi = Math.PI; var dx = x_target - x; var dy = y_target - y; //var degree = Math.atan2(dy,dx)*180/pi; var distance = Math.sqrt(dx*dx+dy*dy); var angle = Math.atan2(dx,-dy)*180/pi; var canon_angle = robot.cannonAbsoluteAngle - 90; if(idle_counter > 60) { target_valid = false; idle_counter = 0; } if(!at_wall && robot.parentId == null) { //x_target = robot.arenaWidth / 2; //y_target = robot.arenaHeight / 2; var width = robot.arenaWidth; var height = robot.arenaHeight; x_ahead = x <= width / 2; y_ahead = y <= height / 2; var cos = Math.cos(robot.angle); var sin = Math.sin(robot.angle); var disX = (x_ahead ? x : (width - x)) / Math.abs(sin); var disY = (y_ahead ? y : (height - y)) / Math.abs(cos); //clockwise = (disX < disY) ? (x_ahead ^ (sin<0)) :(y_ahead ^ (cos<0)); clockwise = (disX < disY) ? (!x_ahead) :(!y_ahead); //console.log(clockwise,(disX < disY),x,y,robot.angle,disX,disY); robot.log(clockwise,(disX < disY)); //robot.turn(-robot.angle+180); clockwise ? robot.back(500) : robot.ahead(500); } else { clockwise ? robot.back() : robot.ahead(); } if(!target_valid ||debug) { if(x_target != -1 && scan_count < 2 || debug) { //search in range var range_width = 500/2 + 200*scan_count; var range_degree = Math.atan(range_width/distance)*180/pi; var max_deg = this.ndeg(angle + range_degree); var min_deg = this.ndeg(angle - range_degree); var th_deg = this.ndeg(angle + 180); if(this.in_range(canon_angle, max_deg, th_deg)) { //over max range cannon_clockwise_scan = false; //robot.log(max_deg,min_deg,th_deg); } else if(this.in_range(canon_angle, th_deg, min_deg)) { cannon_clockwise_scan = true; //robot.log(max_deg,min_deg,th_deg,"max"); } if(last_cannon_clockwise_scan != cannon_clockwise_scan) scan_count++; last_cannon_clockwise_scan = cannon_clockwise_scan; } //x_target = robot.arenaWidth / 2; //y_target = robot.arenaHeight / 2; /*if(x<20 && robot.cannonAbsoluteAngle >= 135 && robot.cannonAbsoluteAngle <= 135+90) { robot.rotateCannon(-90); } */ robot.rotateCannon(cannon_clockwise_scan ? 1 : -1); } else { //var ddeg = (degree+180-robot.cannonAbsoluteAngle+180 + 360*10)%360-180; var ddeg = this.ndeg(angle-canon_angle+180)-180; robot.rotateCannon(ddeg); idle_counter++; } //if(!debug && at_wall && x_target != -1) // robot.fire(); time_frame++; //if (ddeg > 10 || ddeg < 10) // console.log(ddeg,idle_counter); }; Robot.prototype.onScannedRobot = function(ev) { var robot = ev.robot; var scanned =ev.scannedRobot; if(scanned.id !== robot.parentId && scanned.parentId !== robot.id) { if(!debug)robot.fire(); //robot.rotateCannon(-10); //robot.rotateCannon(15); if(scanned.parentId == null) { x_target = scanned.position.x; y_target = scanned.position.y; target_valid = true; scan_count = 0; idle_counter = 0; } }else{ } time_frame++; }; Robot.prototype.onHitByBullet = function(ev) { var robot = ev.robot; if (this.in_range(ev.bearing, -15, 15) || this.in_range(ev.bearing+180, -15, 15)) { //var turndeg = (ev.bearing+45+180+360*10)%360-180 var bearing_angle = this.ndeg(ev.bearing+180)-180; //if(Math.abs(bearing_angle)>90) bearing_angle %= 90; var turn_angle = bearing_angle > 0 ? -90+bearing_angle : 90+bearing_angle; robot.turn(turn_angle); robot.log('ct', ev.bearing); } else robot.log('nct', this.ndeg(ev.bearing)); if(robot.parentId == null && time_frame - last_reverse > 100 && time_frame - last_turn > 150) { clockwise = !clockwise; last_reverse = time_frame; } if(at_wall) { clockwise ? robot.back(150) : robot.ahead(150); } else { clockwise ? robot.back(150) : robot.ahead(150); } }; Robot.prototype.onRobotCollision = function(ev) { var robot = ev.robot; //robot.rotateCannon(90); //if(ev.myFault) if(robot.parentId == null) clockwise = -clockwise; }; Robot.prototype.onWallCollision = function(ev) { var robot = ev.robot; //robot.turn(-90+ev.bearing); var turn_angle = this.ndeg(-90+ev.bearing+180)-180; if(Math.abs(turn_angle) > 90) turn_angle %= 90; robot.turn(turn_angle); robot.log('wall', clockwise, turn_angle); if(at_wall) last_turn = time_frame; at_wall = true; };
  • # 23238
    MrC
    created 02/04/13 0 code lines fork
    -45 SCORE
    1 KILLS
    60 SHOTS
    24 HITS
    39.34%
    AVERAGE HITS/SHOT
    SCORE OVER TIME
    //FightCode can only understand your robot //if its class is called Robot var cloned=false; var Robot = function(robot) { }; Robot.prototype.onIdle = function(ev) { var robot = ev.robot; if (!cloned) { robot.ahead(100); robot.clone(); cloned = true; robot.ahead(100); } if (robot.gunCoolDownTime>0){ robot.rotateCannon(-30); robot.rotateCannon(30); } robot.turn(10); robot.ahead(5); // robot.ahead(50); // robot.rotateCannon(360); // robot.turn(90); //robot.ahead(50); // robot.rotateCannon(360); }; Robot.prototype.onScannedRobot = function(ev) { var robot = ev.robot; var scannedRobot = ev.scannedRobot; if ((robot.id===scannedRobot.parentId) || (robot.parentID === scannedRobot.id)) { //robot.fire(); } else {robot.fire();} }; Robot.prototype.onWallCollision=function(ev) { var robot = ev.robot; robot.turn(160); robot.ahead(10); } Robot.prototype.onRobotCollision = function(ev) { var robot=ev.robot; robot.turn(145); robot.ahead(10); }; Robot.prototype.onHitByBullet = function(ev) { var robot; robot = ev.robot; robot.turn(90 - ev.bulletBearing); robot.ahead(100); };
  • # 21068
    NewBoss
    created 02/26/13 56 code lines fork
    2 SCORE
    4 KILLS
    113 SHOTS
    37 HITS
    32.46%
    AVERAGE HITS/SHOT
    SCORE OVER TIME
    //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; if (robot.cannonRelativeAngle != 0 ) { robot.rotateCannon(-90); } robot.ahead(2000); }; Robot.prototype.onHitByBullet = function(ev) { var robot; robot = ev.robot; robot.clone(); robot.turn(45); robot.fire(); robot.ahead(3000); robot.fire(); }; Robot.prototype.onScannedRobot = function(ev) { var robot = ev.robot; robot.clone(); var scanned =ev.scannedRobot; if(scanned.id !== robot.parentId && scanned.parentId !== robot.id) { robot.fire(); robot.back(20);robot.ahead(30);robot.back(20); }}; Robot.prototype.onWallCollision = function(ev) { var robot = ev.robot; robot.turn(ev.bearing); robot.turn(-90); robot.ahead(1000); }; Robot.prototype.onRobotCollision = function(ev) { var robot = ev.robot; robot.back(100); robot.turn(10); robot.ahead(100); // trying to run away };
  • # 20529
    Oranguntan ++
    created 03/17/13 57 code lines fork
    47 SCORE
    6 KILLS
    262 SHOTS
    58 HITS
    22.05%
    AVERAGE HITS/SHOT
    SCORE OVER TIME
    //FightCode can only understand your robot //if its class is called Robot var Robot = function(robot) { }; var ad = 1 var walk = 8 var mi var cloned = false var miRobot Robot.prototype.onIdle = function(ev) { var robot = ev.robot; if (!mi) {mi = robot.id}else{robot.turn(35) ; robot.ahead(walk*8)} if (!miRobot) { miRobot = robot miRobot.clone() cloned = true } for (var i = 0; i< 28; i++){ robot.ahead(walk); robot.turn(6) robot.rotateCannon(3); } }; Robot.prototype.onScannedRobot = function(ev) { var robot = ev.robot; var rid = ev.scannedRobot.id if ( ev.scannedRobot.parentId) rid= ev.scannedRobot.parentId if (rid != mi){ robot.fire(); robot.rotateCannon(5); robot.fire(); robot.rotateCannon(-35); } }; Robot.prototype.onWallCollision = function(ev) { var robot = ev.robot; robot.turn(35); robot.ahead(walk*4); }; Robot.prototype.onRobotCollision = function(ev) { var robot = ev.robot; robot.turn(45) robot.back(walk*8); robot.rotateCannon(ev.collidedRobot.cannonAngle) }; Robot.prototype.onHitByBullet = function(ev) { var robot = ev.robot; if (robot.availableDisappears) robot.disappear() robot.turn(45) robot.ahead(walk*8); };
  • # 23179
    Out Of Cheese Error v2.0
    created 03/16/13 0 code lines fork
    -37 SCORE
    7 KILLS
    120 SHOTS
    57 HITS
    47.11%
    AVERAGE HITS/SHOT
    SCORE OVER TIME
    //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(90); robot.turn(80); robot.rotateCannon(90); }; Robot.prototype.onScannedRobot = function(ev) { var robot = ev.robot; robot.stop(); robot.fire(3); robot.fire(5); robot.rotateCannon(-30); };
  • # 20641
    [qx3] HAL-9000
    created 03/08/13 0 code lines fork
    34 SCORE
    6 KILLS
    131 SHOTS
    55 HITS
    41.67%
    AVERAGE HITS/SHOT
    SCORE OVER TIME
    //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.clone(); robot.rotateCannon(robot.bearing); robot.ahead(50); robot.turn(50); robot.rotateCannon(180); robot.back(50); robot.rotateCannon(180); }; Robot.prototype.onScannedRobot = function(ev) { var robot = ev.robot; var scanned =ev.scannedRobot; if(scanned.id !== robot.parentId && scanned.parentId !== robot.id) { robot.fire(); robot.rotateCannon(-5); robot.rotateCannon(-30); } }; Robot.prototype.onRobotCollision = function(ev) { var robot = ev.robot; robot.ahead(robot.position+5); robot.ahead(robot.position-15); robot.fire(); }; Robot.prototype.onHitByBullet = function(ev) { var robot; robot = ev.robot; robot.turn(90 - ev.bulletBearing); };
  • # 21033
    ROBOBOCA
    created 03/04/13 70 code lines fork
    13 SCORE
    3 KILLS
    208 SHOTS
    42 HITS
    20.10%
    AVERAGE HITS/SHOT
    SCORE OVER TIME
    //FightCode can only understand your robot //if its class is called Robot var Robot = function(robot) { robot.clone(); }; var girar = 1; var count = 0; var cw = 1; Robot.prototype.onIdle = function(ev) { var robot = ev.robot; if(robot.parentId != null){ if(girar == 1){ robot.rotateCannon(90); robot.turn(120); girar = 0; }else{ robot.ahead(5); robot.turn(2); robot.rotateCannon(5); count += 1; if(count == 90){ count = 0; girar = 1; } } }else{ robot.ahead(5); if(cw){ robot.rotateCannon(5); if(robot.cannonRelativeAngle > 180) cw = 1; }else{ robot.rotateCannon(-5); if(robot.cannonRelativeAngle == 0) cw = 0; } } }; Robot.prototype.onScannedRobot = function(ev) { var robot = ev.robot; if(!(ev.scannedRobot.parentId == robot.id) && !(ev.scannedRobot.id == robot.parentId)){ robot.fire(); robot.gunCoolDownTime = 0; robot.rotateCannon(-25); } }; Robot.prototype.onWallCollision = function(ev) { var robot = ev.robot; if(robot.parentId != null) robot.back(30); else robot.turn(3); }; Robot.prototype.onHitByBullet = function(ev) { var robot = ev.robot; robot.turn(15); robot.ahead(90); robot.rotateCannon(ev.bearing); // Turn to wherever the bullet was fired // so we can see who shot it };
  • # 22885
    Shipow#001
    created 02/17/13 0 code lines fork
    -15 SCORE
    0 KILLS
    12 SHOTS
    5 HITS
    38.46%
    AVERAGE HITS/SHOT
    SCORE OVER TIME
    var Robot = function(robot) { robot.rotateCannon(-90); }; Robot.prototype.onIdle = function(ev) { var robot = ev.robot; robot.ahead(); //i'll add a clone but i need to refactor collision //robot.clone(); }; Robot.prototype.onScannedRobot = function(ev) { var robot = ev.robot; var scanned =ev.scannedRobot; if(scanned.id !== robot.parentId && scanned.parentId !== robot.id) { robot.fire(); robot.rotateCannon(-15); robot.rotateCannon(15); }else{ } }; Robot.prototype.onHitByBullet = function(ev) { var robot; }; Robot.prototype.onRobotCollision = function(ev) { var robot = ev.robot; robot.rotateCannon(90); }; Robot.prototype.onWallCollision = function(ev) { var robot = ev.robot; robot.turn(-90+ev.bearing); };
  • # 22509
    Shipow#001
    created 02/17/13 0 code lines fork
    -6 SCORE
    4 KILLS
    119 SHOTS
    32 HITS
    26.67%
    AVERAGE HITS/SHOT
    SCORE OVER TIME
    var Robot = function(robot) { robot.rotateCannon(-90); }; Robot.prototype.onIdle = function(ev) { var robot = ev.robot; robot.ahead(); //i'll add a clone but i need to refactor collision //robot.clone(); }; Robot.prototype.onScannedRobot = function(ev) { var robot = ev.robot; var scanned =ev.scannedRobot; if(scanned.id !== robot.parentId && scanned.parentId !== robot.id) { robot.fire(); robot.rotateCannon(-15); robot.rotateCannon(15); }else{ } }; Robot.prototype.onHitByBullet = function(ev) { var robot; }; Robot.prototype.onRobotCollision = function(ev) { var robot = ev.robot; robot.rotateCannon(90); }; Robot.prototype.onWallCollision = function(ev) { var robot = ev.robot; robot.turn(-90+ev.bearing); };
  • # 20783
    Shipow#001
    created 03/04/13 0 code lines fork
    24 SCORE
    7 KILLS
    114 SHOTS
    43 HITS
    37.39%
    AVERAGE HITS/SHOT
    SCORE OVER TIME
    var Robot = function(robot) { robot.rotateCannon(-90); }; Robot.prototype.onIdle = function(ev) { var robot = ev.robot; robot.ahead(); //i'll add a clone but i need to refactor collision //robot.clone(); }; Robot.prototype.onScannedRobot = function(ev) { var robot = ev.robot; var scanned =ev.scannedRobot; if(scanned.id !== robot.parentId && scanned.parentId !== robot.id) { robot.fire(); robot.rotateCannon(-15); robot.rotateCannon(15); }else{ } }; Robot.prototype.onHitByBullet = function(ev) { var robot; }; Robot.prototype.onRobotCollision = function(ev) { var robot = ev.robot; robot.rotateCannon(90); }; Robot.prototype.onWallCollision = function(ev) { var robot = ev.robot; robot.turn(-90+ev.bearing); };
  • # 22510
    Shipow#001
    created 03/16/13 0 code lines fork
    -6 SCORE
    2 KILLS
    74 SHOTS
    21 HITS
    28.00%
    AVERAGE HITS/SHOT
    SCORE OVER TIME
    var Robot = function(robot) { robot.rotateCannon(-90); }; Robot.prototype.onIdle = function(ev) { var robot = ev.robot; robot.ahead(); //i'll add a clone but i need to refactor collision //robot.clone(); }; Robot.prototype.onScannedRobot = function(ev) { var robot = ev.robot; var scanned =ev.scannedRobot; if(scanned.id !== robot.parentId && scanned.parentId !== robot.id) { robot.fire(); robot.rotateCannon(-15); robot.rotateCannon(15); }else{ } }; Robot.prototype.onHitByBullet = function(ev) { var robot; }; Robot.prototype.onRobotCollision = function(ev) { var robot = ev.robot; robot.rotateCannon(90); }; Robot.prototype.onWallCollision = function(ev) { var robot = ev.robot; robot.turn(-90+ev.bearing); };
  • # 20614
    [SRV TEAM] D3stroy3r.
    created 02/04/13 50 code lines fork
    43 SCORE
    8 KILLS
    161 SHOTS
    59 HITS
    36.42%
    AVERAGE HITS/SHOT
    SCORE OVER TIME
    //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.clone(); robot.ahead(100); robot.rotateCannon(360); robot.back(100); robot.rotateCannon(360); }; Robot.prototype.onScannedRobot = function(ev) { var robot = ev.robot; var scanned =ev.scannedRobot; if(scanned.id !== robot.parentId && scanned.parentId !== robot.id) { robot.fire(); robot.rotateCannon(-3); robot.rotateCannon(-30); }else{ robot.ahead(30); } }; Robot.prototype.onHitByBullet = function(ev) { var robot; robot = ev.robot; robot.turn(90 - ev.bulletBearing); robot.ahead(-50); robot.turn(60 - ev.bulletBearing); robot.back(90); }; Robot.prototype.onRobotCollision = function(ev) { var robot = ev.robot; robot.ahead(robot.position+5); robot.ahead(robot.position-15); // trying to run away };
  • none
    TANK-BOOM
    created 03/29/13 40 code lines fork
    0 SCORE
    0 KILLS
    0 SHOTS
    0 HITS
    0.00%
    AVERAGE HITS/SHOT
    SCORE OVER TIME
    //FightCode can only understand your robot //if its class is called Robot var Robot = function(r) { }; Robot.prototype.onIdle = function(ev) { var r = ev.robot; r.clone(); r.rotateCannon(360); r.ahead(150); r.turn(30); r.ahead(150); }; Robot.prototype.onScannedRobot = function(ev) { var r = ev.robot; if (ev.scannedRobot.parentId == r.id || ev.scannedRobot.id == r.parentId) { return; }; r.rotateCannon(2); r.fire(); r.turn(8); r.rotateCannon(-20); r.ahead(15); }; Robot.prototype.onHitByBullet = function(ev) { var r = ev.robot; r.disappear(); }; Robot.prototype.onWallCollision = function(ev) { var r = ev.robot; r.back(50); }; Robot.prototype.onRobotCollision = function(ev) { var r = ev.robot; r.back(30); };
  • # 22489
    TestBed0
    created 03/17/13 36 code lines fork
    -1 SCORE
    6 KILLS
    152 SHOTS
    52 HITS
    33.99%
    AVERAGE HITS/SHOT
    SCORE OVER TIME
    var Robot = function(robot) { robot.rotateCannon(-90); }; Robot.prototype.onIdle = function(ev) { var robot = ev.robot; robot.ahead(); //i'll add a clone but i need to refactor collision //robot.clone(); }; Robot.prototype.onScannedRobot = function(ev) { var robot = ev.robot; var scanned =ev.scannedRobot; if(scanned.id !== robot.parentId && scanned.parentId !== robot.id) { robot.fire(); robot.rotateCannon(-15); robot.rotateCannon(15); }else{ } }; Robot.prototype.onHitByBullet = function(ev) { var robot; }; Robot.prototype.onRobotCollision = function(ev) { var robot = ev.robot; robot.rotateCannon(90); }; Robot.prototype.onWallCollision = function(ev) { var robot = ev.robot; robot.turn(-90+ev.bearing); };
  • # 20557
    TestBed1
    created 03/17/13 36 code lines fork
    44 SCORE
    5 KILLS
    122 SHOTS
    31 HITS
    25.20%
    AVERAGE HITS/SHOT
    SCORE OVER TIME
    var Robot = function(robot) { robot.rotateCannon(-90); }; Robot.prototype.onIdle = function(ev) { var robot = ev.robot; robot.ahead(); //i'll add a clone but i need to refactor collision //robot.clone(); }; Robot.prototype.onScannedRobot = function(ev) { var robot = ev.robot; var scanned =ev.scannedRobot; if(scanned.id !== robot.parentId && scanned.parentId !== robot.id) { robot.fire(); robot.rotateCannon(-15); robot.rotateCannon(15); }else{ } }; Robot.prototype.onHitByBullet = function(ev) { var robot; }; Robot.prototype.onRobotCollision = function(ev) { var robot = ev.robot; robot.rotateCannon(90); }; Robot.prototype.onWallCollision = function(ev) { var robot = ev.robot; robot.turn(-90+ev.bearing); };
  • # 21103
    testo
    created 02/26/13 50 code lines fork
    0 SCORE
    9 KILLS
    148 SHOTS
    67 HITS
    44.97%
    AVERAGE HITS/SHOT
    SCORE OVER TIME
    //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; if (robot.cannonRelativeAngle != 0 ) { robot.rotateCannon(-90); } robot.ahead(2000); }; Robot.prototype.onHitByBullet = function(ev) { var robot; robot = ev.robot; robot.clone(); robot.turn(90 - ev.bulletBearing); }; Robot.prototype.onScannedRobot = function(ev) { var robot = ev.robot; robot.clone(); var scanned =ev.scannedRobot; if(scanned.id !== robot.parentId && scanned.parentId !== robot.id) {robot.fire(2); robot.back(20);robot.ahead(30); }}; Robot.prototype.onWallCollision = function(ev) { var robot = ev.robot; robot.turn(ev.bearing); robot.turn(-90); robot.ahead(1000); }; Robot.prototype.onRobotCollision = function(ev) { var robot = ev.robot; robot.clone(); robot.back(100); robot.turn(10); robot.ahead(100); // trying to run away };
  • # 23169
    Turin
    created 02/08/13 81 code lines fork
    -30 SCORE
    3 KILLS
    108 SHOTS
    38 HITS
    34.86%
    AVERAGE HITS/SHOT
    SCORE OVER TIME
    // // Turin.js 2.0.7b // @author Bruno Dias // // Damn...events should never block!! // TODO: a lot... var clone; var Robot = function(robot) { this.targetAquired = false; this.targetX = 0; this.targetY = 0; clone = robot.clone(); }; function isTurim(r1,r2) { if ( r1.id===r2.parentId || r1.parentId===r2.id ) { return true; } return false; } Robot.prototype.onIdle = function(ev) { var robot = ev.robot, rC = 1; robot.ahead(10); if (robot.parentId) { robot.turn(20); } if (!this.targetAquired) { rC = (robot.position.x < this.targetX) ? -1 : 1; robot.rotateCannon( rC * 180 * Math.sin(robot.position.x) * Math.cos(robot.position.y) ); } //robot.fire(1 ); }; Robot.prototype.onScannedRobot = function(ev) { var robot = ev.robot; if ( isTurim(robot, ev.scannedRobot) ) return; //robot.turn(40); this.targetAquired = true; this.targetX = ev.scannedRobot.position.x; this.targetY = ev.scannedRobot.position.y; robot.fire( 1 ); robot.fire( 1 ); robot.fire( 1 ); robot.ahead( 40 ); robot.fire( 1 ); this.targetAquired = false; //robot.rotateCannon(360); robot.fire( 1 ); }; Robot.prototype.onRobotCollision = function(ev) { var robot = ev.robot; robot.turn(20); robot.back(10); robot.ahead(100); // trying to run away }; // this method gets called whenever we hit a wall... Robot.prototype.onWallCollision = function(ev) { var robot = ev.robot; // testing robot.ignore('onWallCollision'); robot.turn(60); robot.back(10); robot.ahead(100); robot.listen('onWallCollision'); }; // this method gets called whenever we hit a wall... Robot.prototype.onHitByBullet = function(ev) { var robot = ev.robot; robot.ignore('onHitByBullet'); robot.turn( 50 ); robot.ahead( 104 ); robot.rotateCannon(-robot.cannonAbsoluteAngle+ev.bulletBearing); robot.listen('onHitByBullet'); };
  • # 20478
    vagina
    created 03/24/13 153 code lines fork
    59 SCORE
    12 KILLS
    317 SHOTS
    86 HITS
    27.04%
    AVERAGE HITS/SHOT
    SCORE OVER TIME
    var targeting = {}; var targetLocation = {}; var scanDirection = {}; var moveDirection = {}; var skipShoot = {}; var Robot = function (a) {}; function angle_to(a, b) { var c = a.position.x; var d = a.position.y; var e = b.x; var f = b.y; var g = Math.atan2(e - c, d - f) * 180 / Math.PI; if (g < 0) g += 360; return g; } function get_cannon_angle(a) { var b = a.cannonAbsoluteAngle + 270; if (b > 360) b -= 360; return b; } function aim_at(a, b) { var c = angle_to(a, b); var d = get_cannon_angle(a); var e = adjust_angle(d, c); if (e > 0) scanDirection[a.id] = 20; else scanDirection[a.id] = -20; } function aim_towards(a, b) { var c = get_cannon_angle(a); var d = adjust_angle(c, b); a.rotateCannon(d); } function adjust_angle(a, b) { var c = (b - a); if (c < -180) c += 360; else if (c > 180) c -= 360; return c; } function turn_towards(a, b) { var c = adjust_angle(a.angle, b); a.turn(Math.min(15, Math.max(-15, c))); } function distance_to(a, b) { return Math.sqrt(Math.pow(Math.abs(a.x - b.x), 2) + Math.pow(Math.abs(a.y - b.y), 2)); } function drive_towards(a, b) { turn_towards(a, angle_to(a, b)); move(a, 10); } function placement(a) { var b = angle_to(a, targetLocation[a.id]); var c = adjust_angle(a.angle, b); if (c > 0) a.turn(Math.max(-10, Math.min(10, c - 90))); else a.turn(Math.max(-10, Math.min(10, c + 90))); } function next_corner(a) { var b = { x: 0, y: 0 }; var c = { x: a.arenaWidth, y: 0 }; var d = { x: a.arenaWidth, y: a.arenaHeight }; var e = { x: 0, y: a.arenaHeight }; var f = distance(a.position, b); var g = distance(a.position, c); var h = distance(a.position, d); var i = distance(a.position, e); if (f < g && f < i) return c; if (g < f && g < h) return d; if (h < g && h < i) return e; return b; } function engage(a) { wander(a); if (targeting[a.id] > 0) { placement(a); aim_at(a, targetLocation[a.id]); a.rotateCannon(scanDirection[a.id]); var b = Math.abs(get_cannon_angle(a) - angle_to(a, targetLocation[a.id])); if (b < 30) if (!skipShoot[a.id] > 0) a.fire(); targeting[a.id] -= 5; if (targeting[a.id] <= 0) { aim_at(a, targetLocation[a.id]); targetLocation[a.id] = null; } } else { a.rotateCannon(scanDirection[a.id]); drive_towards(next_corner(a)); } if (skipShoot[a.id] > 0) skipShoot[a.id] -= 1; } function move(a, b) { if (moveDirection[a.id] > 0) a.ahead(b); else a.back(b); } function wander(a) { move(a, 35); } Robot.prototype.onIdle = function (a) { var b = a.robot; if (scanDirection[b.id] == undefined) { scanDirection[b.id] = 20; moveDirection[b.id] = 1; targeting[b.id] = 0; targetLocation[b.id] = null; skipShoot[b.id] = 0; } if (b.availableClones > 0) { b.clone(); if (b.parentId == null) b.turn(90); } engage(b); }; Robot.prototype.onScannedRobot = function (a) { var b = a.scannedRobot; var c = a.robot; if (b.parentId == c.id || c.parentId == b.id) { skipShoot[c.id] = 2; return; } for (var d in targetLocation) if (targeting[d] == null || d == c.id) { targetLocation[d] = b.position; targeting[d] = 30; } targeting[c.id] = 30; c.fire(); }; Robot.prototype.onHitByBullet = function (a) { var b = a.robot; if (b.availableDisappears > 0) b.disappear(); var c = adjust_angle(b.angle, a.bearing); if (c > 0) b.turn(c - 90); else b.turn(c + 90); move(b, 70); }; Robot.prototype.onRobotCollision = function (a) { var b = a.robot; moveDirection[b.id] *= -1; }; Robot.prototype.onWallCollision = function (a) { var b = a.robot; moveDirection[b.id] *= -1; };