Skip to content

Instantly share code, notes, and snippets.

@Firvagor
Forked from Walko/robot.js
Created December 4, 2012 14:59
Show Gist options
  • Select an option

  • Save Firvagor/4204827 to your computer and use it in GitHub Desktop.

Select an option

Save Firvagor/4204827 to your computer and use it in GitHub Desktop.

Revisions

  1. @Walko Walko 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
    @@ -31,7 +31,7 @@ Robot.prototype.onScannedRobot = function(ev) {
    robot.stop();
    robot.fire();
    robot.turn(15);
    robot.ahead(50);
    robot.ahead(0,5);
    robot.rotateCannon(-30);
    robot.fire();

  2. @Walko Walko 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
    @@ -38,7 +38,7 @@ Robot.prototype.onScannedRobot = function(ev) {
    };
    Robot.prototype.onRobotCollision = function(ev) {
    var robot = ev.robot;
    robot.fire(2);
    robot.fire(5);
    robot.turn(200);
    robot.ahead(500); // trying to run away
    robot.clone(robot);
  3. @Walko Walko revised this gist Dec 4, 2012. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions robot.js
    Original file line number Diff line number Diff line change
    @@ -9,7 +9,7 @@ Robot.prototype.onIdle = function(ev) {
    var robot = ev.robot;
    robot.ahead(1);
    robot.rotateCannon(360);
    // robot.ahead(1);
    robot.ahead(1);


    //robot.back(1000);
    @@ -31,7 +31,7 @@ Robot.prototype.onScannedRobot = function(ev) {
    robot.stop();
    robot.fire();
    robot.turn(15);
    robot.ahead(20);
    robot.ahead(50);
    robot.rotateCannon(-30);
    robot.fire();

  4. @Walko Walko revised this gist Dec 4, 2012. 1 changed file with 3 additions and 3 deletions.
    6 changes: 3 additions & 3 deletions robot.js
    Original file line number Diff line number Diff line change
    @@ -9,7 +9,7 @@ Robot.prototype.onIdle = function(ev) {
    var robot = ev.robot;
    robot.ahead(1);
    robot.rotateCannon(360);
    robot.ahead(1);
    // robot.ahead(1);


    //robot.back(1000);
    @@ -30,8 +30,8 @@ Robot.prototype.onScannedRobot = function(ev) {
    //robot.ahead(5000);
    robot.stop();
    robot.fire();
    robot.turn(25);
    robot.ahead(10);
    robot.turn(15);
    robot.ahead(20);
    robot.rotateCannon(-30);
    robot.fire();

  5. @Walko Walko revised this gist Dec 4, 2012. 1 changed file with 3 additions and 3 deletions.
    6 changes: 3 additions & 3 deletions robot.js
    Original file line number Diff line number Diff line change
    @@ -47,9 +47,9 @@ Robot.prototype.onRobotCollision = function(ev) {
    Robot.prototype.onHitByBullet = function(ev) {
    var robot;
    robot = ev.robot;
    robot.turn(50 - ev.bulletBearing);
    robot.back(50);
    robot.ahead(50);
    robot.turn(10 - ev.bulletBearing);
    robot.back(70);
    robot.ahead(70);


    };
  6. @Walko Walko revised this gist Dec 4, 2012. 1 changed file with 3 additions and 1 deletion.
    4 changes: 3 additions & 1 deletion robot.js
    Original file line number Diff line number Diff line change
    @@ -41,14 +41,16 @@ Robot.prototype.onRobotCollision = function(ev) {
    robot.fire(2);
    robot.turn(200);
    robot.ahead(500); // trying to run away
    robot.clone(robot);

    };
    Robot.prototype.onHitByBullet = function(ev) {
    var robot;
    robot = ev.robot;
    robot.turn(50 - ev.bulletBearing);
    robot.back(50);
    robot.ahead(50);
    robot.clone(robot);


    };
    //Robot.prototype.onScannedRobot = function(ev) {
  7. @Walko Walko revised this gist Dec 4, 2012. 1 changed file with 1 addition and 0 deletions.
    1 change: 1 addition & 0 deletions robot.js
    Original file line number Diff line number Diff line change
    @@ -48,6 +48,7 @@ Robot.prototype.onHitByBullet = function(ev) {
    robot.turn(50 - ev.bulletBearing);
    robot.back(50);
    robot.ahead(50);
    robot.clone(robot);

    };
    //Robot.prototype.onScannedRobot = function(ev) {
  8. @Walko Walko revised this gist Dec 4, 2012. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions robot.js
    Original file line number Diff line number Diff line change
    @@ -46,8 +46,8 @@ Robot.prototype.onHitByBullet = function(ev) {
    var robot;
    robot = ev.robot;
    robot.turn(50 - ev.bulletBearing);
    robot.back(20);
    robot.ahead(20);
    robot.back(50);
    robot.ahead(50);

    };
    //Robot.prototype.onScannedRobot = function(ev) {
  9. @Walko Walko revised this gist Dec 4, 2012. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions robot.js
    Original file line number Diff line number Diff line change
    @@ -7,9 +7,9 @@ var Robot = function(robot) {

    Robot.prototype.onIdle = function(ev) {
    var robot = ev.robot;
    robot.ahead(10);
    robot.ahead(1);
    robot.rotateCannon(360);
    robot.ahead(10);
    robot.ahead(1);


    //robot.back(1000);
  10. @Walko Walko revised this gist Dec 4, 2012. No changes.
  11. @Walko Walko 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
    @@ -45,7 +45,7 @@ Robot.prototype.onRobotCollision = function(ev) {
    Robot.prototype.onHitByBullet = function(ev) {
    var robot;
    robot = ev.robot;
    robot.turn(10 - ev.bulletBearing);
    robot.turn(50 - ev.bulletBearing);
    robot.back(20);
    robot.ahead(20);

  12. @Walko Walko revised this gist Dec 4, 2012. 1 changed file with 3 additions and 2 deletions.
    5 changes: 3 additions & 2 deletions robot.js
    Original file line number Diff line number Diff line change
    @@ -45,8 +45,9 @@ Robot.prototype.onRobotCollision = function(ev) {
    Robot.prototype.onHitByBullet = function(ev) {
    var robot;
    robot = ev.robot;
    robot.turn(40 - ev.bulletBearing);
    robot.back(50);
    robot.turn(10 - ev.bulletBearing);
    robot.back(20);
    robot.ahead(20);

    };
    //Robot.prototype.onScannedRobot = function(ev) {
  13. @Walko Walko 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
    @@ -31,7 +31,7 @@ Robot.prototype.onScannedRobot = function(ev) {
    robot.stop();
    robot.fire();
    robot.turn(25);
    robot.ahead(50);
    robot.ahead(10);
    robot.rotateCannon(-30);
    robot.fire();

  14. @Walko Walko revised this gist Dec 4, 2012. 1 changed file with 10 additions and 5 deletions.
    15 changes: 10 additions & 5 deletions robot.js
    Original file line number Diff line number Diff line change
    @@ -21,14 +21,19 @@ Robot.prototype.onIdle = function(ev) {

    Robot.prototype.onScannedRobot = function(ev) {
    var robot = ev.robot;
    robot.fire(4);
    robot.rotateCannon(0,1);
    robot.fire(1);
    robot.rotateCannon(0,1);
    // robot.fire(4);
    // robot.rotateCannon(0,1);
    // robot.fire(1);
    // robot.rotateCannon(0,1);
    //robot.rotateCannon(10);
    // robot.turn(50);
    //robot.ahead(5000);

    robot.stop();
    robot.fire();
    robot.turn(25);
    robot.ahead(50);
    robot.rotateCannon(-30);
    robot.fire();

    };
    Robot.prototype.onRobotCollision = function(ev) {
  15. @Walko Walko revised this gist Dec 4, 2012. 1 changed file with 3 additions and 1 deletion.
    4 changes: 3 additions & 1 deletion robot.js
    Original file line number Diff line number Diff line change
    @@ -7,8 +7,10 @@ var Robot = function(robot) {

    Robot.prototype.onIdle = function(ev) {
    var robot = ev.robot;
    robot.ahead(1000);
    robot.ahead(10);
    robot.rotateCannon(360);
    robot.ahead(10);


    //robot.back(1000);
    // robot.rotateCannon(360);
  16. @Walko Walko revised this gist Dec 4, 2012. 1 changed file with 4 additions and 1 deletion.
    5 changes: 4 additions & 1 deletion robot.js
    Original file line number Diff line number Diff line change
    @@ -20,6 +20,9 @@ Robot.prototype.onIdle = function(ev) {
    Robot.prototype.onScannedRobot = function(ev) {
    var robot = ev.robot;
    robot.fire(4);
    robot.rotateCannon(0,1);
    robot.fire(1);
    robot.rotateCannon(0,1);
    //robot.rotateCannon(10);
    // robot.turn(50);
    //robot.ahead(5000);
    @@ -36,7 +39,7 @@ Robot.prototype.onHitByBullet = function(ev) {
    var robot;
    robot = ev.robot;
    robot.turn(40 - ev.bulletBearing);
    robot.back(10);
    robot.back(50);

    };
    //Robot.prototype.onScannedRobot = function(ev) {
  17. @Walko Walko 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
    @@ -36,7 +36,7 @@ Robot.prototype.onHitByBullet = function(ev) {
    var robot;
    robot = ev.robot;
    robot.turn(40 - ev.bulletBearing);
    robot.back(1000);
    robot.back(10);

    };
    //Robot.prototype.onScannedRobot = function(ev) {
  18. @Walko Walko revised this gist Dec 4, 2012. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions robot.js
    Original file line number Diff line number Diff line change
    @@ -9,7 +9,7 @@ Robot.prototype.onIdle = function(ev) {
    var robot = ev.robot;
    robot.ahead(1000);
    robot.rotateCannon(360);
    robot.fire(1);

    //robot.back(1000);
    // robot.rotateCannon(360);
    // robot.turn(20);
    @@ -19,7 +19,7 @@ Robot.prototype.onIdle = function(ev) {

    Robot.prototype.onScannedRobot = function(ev) {
    var robot = ev.robot;
    robot.fire(3);
    robot.fire(4);
    //robot.rotateCannon(10);
    // robot.turn(50);
    //robot.ahead(5000);
  19. @Walko Walko revised this gist Dec 4, 2012. 1 changed file with 2 additions and 1 deletion.
    3 changes: 2 additions & 1 deletion robot.js
    Original file line number Diff line number Diff line change
    @@ -9,6 +9,7 @@ Robot.prototype.onIdle = function(ev) {
    var robot = ev.robot;
    robot.ahead(1000);
    robot.rotateCannon(360);
    robot.fire(1);
    //robot.back(1000);
    // robot.rotateCannon(360);
    // robot.turn(20);
    @@ -27,7 +28,7 @@ Robot.prototype.onScannedRobot = function(ev) {
    };
    Robot.prototype.onRobotCollision = function(ev) {
    var robot = ev.robot;
    robot.fire(5);
    robot.fire(2);
    robot.turn(200);
    robot.ahead(500); // trying to run away
    };
  20. @Walko Walko revised this gist Dec 4, 2012. 1 changed file with 6 additions and 5 deletions.
    11 changes: 6 additions & 5 deletions robot.js
    Original file line number Diff line number Diff line change
    @@ -9,18 +9,19 @@ Robot.prototype.onIdle = function(ev) {
    var robot = ev.robot;
    robot.ahead(1000);
    robot.rotateCannon(360);
    robot.back(1000);
    robot.rotateCannon(360);
    robot.turn(20);
    //robot.back(1000);
    // robot.rotateCannon(360);
    // robot.turn(20);


    };

    Robot.prototype.onScannedRobot = function(ev) {
    var robot = ev.robot;
    robot.fire(3);
    //robot.turn(50);
    robot.ahead(5000);
    //robot.rotateCannon(10);
    // robot.turn(50);
    //robot.ahead(5000);


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

    Robot.prototype.onScannedRobot = function(ev) {
    var robot = ev.robot;
    robot.fire();
    robot.turn(50);
    robot.fire(3);
    //robot.turn(50);
    robot.ahead(5000);


    @@ -37,15 +37,15 @@ Robot.prototype.onHitByBullet = function(ev) {
    robot.back(1000);

    };
    Robot.prototype.onScannedRobot = function(ev) {
    var robot;
    //Robot.prototype.onScannedRobot = function(ev) {
    // var robot;
    // var robot1;
    var scanned =ev.scannedRobot;
    robot = ev.robot;
    robot.fire(5);
    //var scanned =ev.scannedRobot;
    //robot = ev.robot;
    //robot.fire(5);
    // robot1.clone(robot);
    // if(scannedRobot !== robot1.parentId && scanned.parentId !== robot1.id)
    // robot1.fire(2);
    };
    //};


  22. @Walko Walko revised this gist Dec 4, 2012. 1 changed file with 7 additions and 4 deletions.
    11 changes: 7 additions & 4 deletions robot.js
    Original file line number Diff line number Diff line change
    @@ -33,16 +33,19 @@ Robot.prototype.onRobotCollision = function(ev) {
    Robot.prototype.onHitByBullet = function(ev) {
    var robot;
    robot = ev.robot;
    robot.turn(180 - ev.bulletBearing);
    robot.back(100);
    robot.clone(robot);
    robot.turn(40 - ev.bulletBearing);
    robot.back(1000);

    };
    Robot.prototype.onScannedRobot = function(ev) {
    var robot;
    // var robot1;
    var scanned =ev.scannedRobot;
    robot = ev.robot;
    robot.fire(5);
    //if(scanned.id !== robot.parentId && scanned.parentId !== robot.id) { robot.fire(3);}esle{ robot.fire(3);}
    // robot1.clone(robot);
    // if(scannedRobot !== robot1.parentId && scanned.parentId !== robot1.id)
    // robot1.fire(2);
    };


  23. @Walko Walko revised this gist Dec 4, 2012. 1 changed file with 15 additions and 4 deletions.
    19 changes: 15 additions & 4 deletions robot.js
    Original file line number Diff line number Diff line change
    @@ -7,11 +7,12 @@ var Robot = function(robot) {

    Robot.prototype.onIdle = function(ev) {
    var robot = ev.robot;
    robot.ahead(100);
    robot.ahead(1000);
    robot.rotateCannon(360);
    robot.back(100);
    robot.rotateCannon(360);
    robot.clone(robot);
    robot.back(1000);
    robot.rotateCannon(360);
    robot.turn(20);


    };

    @@ -25,6 +26,7 @@ Robot.prototype.onScannedRobot = function(ev) {
    };
    Robot.prototype.onRobotCollision = function(ev) {
    var robot = ev.robot;
    robot.fire(5);
    robot.turn(200);
    robot.ahead(500); // trying to run away
    };
    @@ -35,3 +37,12 @@ Robot.prototype.onHitByBullet = function(ev) {
    robot.back(100);
    robot.clone(robot);
    };
    Robot.prototype.onScannedRobot = function(ev) {
    var robot;
    var scanned =ev.scannedRobot;
    robot = ev.robot;
    robot.fire(5);
    //if(scanned.id !== robot.parentId && scanned.parentId !== robot.id) { robot.fire(3);}esle{ robot.fire(3);}
    };


  24. @Walko Walko revised this gist Dec 4, 2012. 1 changed file with 3 additions and 0 deletions.
    3 changes: 3 additions & 0 deletions robot.js
    Original file line number Diff line number Diff line change
    @@ -11,6 +11,7 @@ Robot.prototype.onIdle = function(ev) {
    robot.rotateCannon(360);
    robot.back(100);
    robot.rotateCannon(360);
    robot.clone(robot);

    };

    @@ -19,6 +20,7 @@ Robot.prototype.onScannedRobot = function(ev) {
    robot.fire();
    robot.turn(50);
    robot.ahead(5000);


    };
    Robot.prototype.onRobotCollision = function(ev) {
    @@ -31,4 +33,5 @@ Robot.prototype.onHitByBullet = function(ev) {
    robot = ev.robot;
    robot.turn(180 - ev.bulletBearing);
    robot.back(100);
    robot.clone(robot);
    };
  25. @Walko Walko revised this gist Dec 4, 2012. No changes.
  26. @Walko Walko created this gist Dec 4, 2012.
    34 changes: 34 additions & 0 deletions robot.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,34 @@

    //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.turn(50);
    robot.ahead(5000);

    };
    Robot.prototype.onRobotCollision = function(ev) {
    var robot = ev.robot;
    robot.turn(200);
    robot.ahead(500); // trying to run away
    };
    Robot.prototype.onHitByBullet = function(ev) {
    var robot;
    robot = ev.robot;
    robot.turn(180 - ev.bulletBearing);
    robot.back(100);
    };