Skip to content

Instantly share code, notes, and snippets.

@cgardner
Forked from fabiopimentel/robot.js
Created December 4, 2012 03:38
Show Gist options
  • Select an option

  • Save cgardner/4200303 to your computer and use it in GitHub Desktop.

Select an option

Save cgardner/4200303 to your computer and use it in GitHub Desktop.

Revisions

  1. cgardner revised this gist Dec 4, 2012. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion robot.js
    Original file line number Diff line number Diff line change
    @@ -18,7 +18,7 @@ Robot.prototype.onScannedRobot = function(ev) {
    var scanned = ev.scannedRobot;
    if(scanned.id !== robot.parentId && scanned.parentId !== robot.id) {
    robot.fire();
    robot.rotateCannon(-25);
    robot.rotateCannon(-25);
    }
    else{
    robot.ahead(30);
  2. cgardner revised this gist Dec 4, 2012. 1 changed file with 18 additions and 17 deletions.
    35 changes: 18 additions & 17 deletions robot.js
    Original file line number Diff line number Diff line change
    @@ -1,15 +1,16 @@
    //FightCode can only understand your robot
    //if its class is called Robot
    var Robot = function(robot) {
    robot.clone();
    robot.clone();
    robot.rotateCannon(360);
    };

    Robot.prototype.onIdle = function(ev) {
    var robot = ev.robot;
    robot.ahead(100);
    robot.rotateCannon(360);
    robot.back(100);
    robot.rotateCannon(360);
    var robot = ev.robot;
    robot.ahead(100);
    robot.rotateCannon(360);
    robot.back(100);
    robot.rotateCannon(360);
    };

    Robot.prototype.onScannedRobot = function(ev) {
    @@ -24,17 +25,17 @@ Robot.prototype.onScannedRobot = function(ev) {
    }
    };
    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);
    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
    };
    var robot = ev.robot;
    robot.ahead(robot.position+5);
    robot.ahead(robot.position-15);
    // trying to run away
    };
  3. cgardner revised this gist Dec 4, 2012. No changes.
  4. cgardner revised this gist Dec 4, 2012. 1 changed file with 9 additions and 18 deletions.
    27 changes: 9 additions & 18 deletions robot.js
    Original file line number Diff line number Diff line change
    @@ -1,32 +1,27 @@

    //FightCode can only understand your robot
    //if its class is called Robot
    var Robot = function(robot) {

    robot.clone();
    };

    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) {
    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.rotateCannon(-25);
    }
    else{
    robot.ahead(30);
    }
    };
    Robot.prototype.onHitByBullet = function(ev) {
    var robot;
    @@ -41,9 +36,5 @@ Robot.prototype.onRobotCollision = function(ev) {
    var robot = ev.robot;
    robot.ahead(robot.position+5);
    robot.ahead(robot.position-15);

    // trying to run away
    };



  5. @fabiopimentel fabiopimentel revised this gist Dec 4, 2012. 1 changed file with 3 additions and 12 deletions.
    15 changes: 3 additions & 12 deletions robot.js
    Original file line number Diff line number Diff line change
    @@ -16,27 +16,18 @@ Robot.prototype.onIdle = function(ev) {
    };

    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);
    }


    };

    // ohhh... we were hit by another robot...
    /*Robot.prototype.onHitByBullet = function(ev) {
    var robot;
    robot = ev.robot;
    robot.turn(90 - ev.bulletBearing);
    robot.ahead(10);
    robot.turn(80 - ev.bulletBearing);
    robot.back(10);
    };
    */
    // ohhh... we were hit by another robot...
    Robot.prototype.onHitByBullet = function(ev) {
    var robot;
    robot = ev.robot;
  6. @fabiopimentel fabiopimentel revised this gist Dec 4, 2012. 1 changed file with 22 additions and 5 deletions.
    27 changes: 22 additions & 5 deletions robot.js
    Original file line number Diff line number Diff line change
    @@ -7,6 +7,7 @@ var Robot = function(robot) {

    Robot.prototype.onIdle = function(ev) {
    var robot = ev.robot;
    robot.clone();
    robot.ahead(100);
    robot.rotateCannon(360);
    robot.back(100);
    @@ -15,27 +16,43 @@ Robot.prototype.onIdle = function(ev) {
    };

    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);


    }


    };

    // ohhh... we were hit by another robot...
    Robot.prototype.onHitByBullet = function(ev) {
    /*Robot.prototype.onHitByBullet = function(ev) {
    var robot;
    robot = ev.robot;
    robot.turn(90 - ev.bulletBearing);
    robot.ahead(10);
    robot.turn(80 - ev.bulletBearing);
    robot.back(10);
    };
    */
    // ohhh... we were hit by another robot...
    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
    };



  7. @fabiopimentel fabiopimentel revised this gist Dec 3, 2012. No changes.
  8. @fabiopimentel fabiopimentel created this gist Dec 3, 2012.
    41 changes: 41 additions & 0 deletions robot.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,41 @@

    //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(100);
    robot.rotateCannon(360);
    robot.back(100);
    robot.rotateCannon(360);

    };

    Robot.prototype.onScannedRobot = function(ev) {
    var robot = ev.robot;
    robot.fire();
    robot.rotateCannon(-3);
    robot.rotateCannon(-30);




    };

    // ohhh... we were hit by another robot...
    Robot.prototype.onHitByBullet = function(ev) {
    var robot;
    robot = ev.robot;
    robot.turn(90 - ev.bulletBearing);
    robot.ahead(10);
    robot.turn(80 - ev.bulletBearing);
    robot.back(10);
    };