Created
November 28, 2012 16:35
-
-
Save heynemann/4162401 to your computer and use it in GitHub Desktop.
Revisions
-
heynemann revised this gist
Dec 14, 2012 . 1 changed file with 10 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -26,11 +26,19 @@ Robot.prototype.onIdle = function(ev) { var deltaX = Math.abs(robot.position.x - foundRobotPosition.x); var deltaY = Math.abs(robot.position.y - foundRobotPosition.y); var angle = Math.atan(deltaY / deltaX); angle = angle * (180/Math.PI); foundByClone = false; foundByParent = false; robot.turn(angle); for (var i=0; i < this.options.shootIterations; i++) { robot.fire(); robot.ahead(10); robot.rotateCannon(-1); } } robot.turn(1); robot.ahead(1); }; -
heynemann revised this gist
Dec 14, 2012 . 1 changed file with 29 additions and 9 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -1,26 +1,49 @@ var foundRobotPosition = {x:0, y:0}, foundByParent=false, foundByClone=false; //FightCode can only understand your robot //if its class is called Robot var Robot = function(robot){ robot.clone(); this.options = { direction: 1, aheadWhileTurning: 3, shootIterations: 5, distanceToWalkBackOnHit: 10, hasCloned: false }; }; Robot.prototype.onIdle = function(ev) { var robot = ev.robot; if ( (foundByClone && robot.parentId == null) || (foundByParent && robot.parentId != null) ){ var deltaX = Math.abs(robot.position.x - foundRobotPosition.x); var deltaY = Math.abs(robot.position.y - foundRobotPosition.y); var angle = Math.atan(deltaY / deltaX); console.log(angle); foundByClone = false; foundByParent = false; } robot.rotateCannon(1); robot.ahead(1); }; Robot.prototype.onScannedRobot = function(ev) { var robot = ev.robot, scanned = ev.scannedRobot; foundRobotPosition = scanned.position; if (robot.parentId == null) { foundByParent = true; } else { foundByClone = true; } if (scanned.parentId != null || robot.parentId == scanned.id || robot.id == scanned.parentId){ @@ -33,7 +56,6 @@ Robot.prototype.onScannedRobot = function(ev) { robot.ahead(10); robot.rotateCannon(-1); } }; Robot.prototype.onWallCollision = function(ev) { @@ -42,8 +64,6 @@ Robot.prototype.onWallCollision = function(ev) { }; Robot.prototype.onRobotCollision = function(ev) { }; Robot.prototype.onHitByBullet = function(ev) { -
heynemann revised this gist
Dec 5, 2012 . 1 changed file with 2 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -18,6 +18,7 @@ Robot.prototype.onIdle = function(ev) { }; Robot.prototype.onScannedRobot = function(ev) { ev.robot.stop(); /* var robot = ev.robot, scanned = ev.scannedRobot; if (scanned.parentId != null || @@ -36,6 +37,7 @@ Robot.prototype.onScannedRobot = function(ev) { }; Robot.prototype.onWallCollision = function(ev) { ev.robot.turn(180); ev.robot.back(this.options.distanceToWalkBackOnHit); }; -
heynemann revised this gist
Dec 5, 2012 . No changes.There are no files selected for viewing
-
heynemann revised this gist
Dec 5, 2012 . 1 changed file with 1 addition and 0 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -13,6 +13,7 @@ var Robot = function(robot){ Robot.prototype.onIdle = function(ev) { var robot = ev.robot; robot.ahead(10); robot.fire(); }; -
heynemann revised this gist
Dec 5, 2012 . 1 changed file with 6 additions and 11 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -13,17 +13,11 @@ var Robot = function(robot){ Robot.prototype.onIdle = function(ev) { var robot = ev.robot; robot.fire(); }; Robot.prototype.onScannedRobot = function(ev) { /* var robot = ev.robot, scanned = ev.scannedRobot; if (scanned.parentId != null || robot.parentId == scanned.id || @@ -34,18 +28,19 @@ Robot.prototype.onScannedRobot = function(ev) { for (var i=0; i < this.options.shootIterations; i++) { robot.fire(); robot.ahead(10); robot.rotateCannon(-1); } */ }; Robot.prototype.onWallCollision = function(ev) { ev.robot.back(this.options.distanceToWalkBackOnHit); }; Robot.prototype.onRobotCollision = function(ev) { //ev.robot.turn(ev.bearing); //ev.robot.back(this.options.distanceToWalkBackOnHit); }; Robot.prototype.onHitByBullet = function(ev) { -
heynemann revised this gist
Dec 5, 2012 . 1 changed file with 4 additions and 5 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -4,9 +4,9 @@ var Robot = function(robot){ //robot.ignore('onRobotCollision'); this.options = { direction: 1, aheadWhileTurning: 3, shootIterations: 5, distanceToWalkBackOnHit: 100, hasCloned: false }; }; @@ -18,8 +18,8 @@ Robot.prototype.onIdle = function(ev) { robot.clone(); this.options.hasCloned = true; } robot.ahead(this.options.aheadWhileTurning); robot.rotateCannon(1); }; Robot.prototype.onScannedRobot = function(ev) { @@ -32,7 +32,6 @@ Robot.prototype.onScannedRobot = function(ev) { } //this.options.direction = (scanned.angle > 180) ? 1 : -1; for (var i=0; i < this.options.shootIterations; i++) { robot.fire(); robot.ahead(1); -
heynemann revised this gist
Dec 5, 2012 . 1 changed file with 2 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -32,9 +32,10 @@ Robot.prototype.onScannedRobot = function(ev) { } //this.options.direction = (scanned.angle > 180) ? 1 : -1; robot.rotateCannon(-5); for (var i=0; i < this.options.shootIterations; i++) { robot.fire(); robot.ahead(1); robot.rotateCannon(-1); } }; -
heynemann revised this gist
Dec 5, 2012 . 1 changed file with 1 addition and 2 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -35,8 +35,7 @@ Robot.prototype.onScannedRobot = function(ev) { robot.rotateCannon(-20); for (var i=0; i < this.options.shootIterations; i++) { robot.fire(); robot.rotateCannon(-1); } }; -
heynemann revised this gist
Dec 5, 2012 . 1 changed file with 3 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -5,7 +5,7 @@ var Robot = function(robot){ this.options = { direction: 1, aheadWhileTurning: 1, shootIterations: 10, distanceToWalkBackOnHit: 50, hasCloned: false }; @@ -32,10 +32,11 @@ Robot.prototype.onScannedRobot = function(ev) { } //this.options.direction = (scanned.angle > 180) ? 1 : -1; robot.rotateCannon(-20); for (var i=0; i < this.options.shootIterations; i++) { robot.fire(); robot.back(10); robot.rotateCannon(1); } }; -
heynemann revised this gist
Dec 5, 2012 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -5,7 +5,7 @@ var Robot = function(robot){ this.options = { direction: 1, aheadWhileTurning: 1, shootIterations: 4, distanceToWalkBackOnHit: 50, hasCloned: false }; -
heynemann revised this gist
Dec 5, 2012 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -32,7 +32,7 @@ Robot.prototype.onScannedRobot = function(ev) { } //this.options.direction = (scanned.angle > 180) ? 1 : -1; for (var i=0; i < this.options.shootIterations; i++) { robot.fire(); robot.turn(-10); robot.back(10); -
heynemann revised this gist
Dec 5, 2012 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -32,7 +32,7 @@ Robot.prototype.onScannedRobot = function(ev) { } //this.options.direction = (scanned.angle > 180) ? 1 : -1; for (var i=0; i<this.options.shootIterations; i++) { robot.fire(); robot.turn(-10); robot.back(10); -
heynemann revised this gist
Dec 5, 2012 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -32,7 +32,7 @@ Robot.prototype.onScannedRobot = function(ev) { } //this.options.direction = (scanned.angle > 180) ? 1 : -1; for (var i=0; i < this.options.shootIterations; i++) { robot.fire(); robot.turn(-10); robot.back(10); -
heynemann revised this gist
Dec 5, 2012 . 1 changed file with 3 additions and 3 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -32,10 +32,10 @@ Robot.prototype.onScannedRobot = function(ev) { } //this.options.direction = (scanned.angle > 180) ? 1 : -1; for (var i=0; i <= this.options.shootIterations; i++) { robot.fire(); robot.turn(-10); robot.back(10); } }; -
heynemann revised this gist
Dec 5, 2012 . 1 changed file with 2 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -32,10 +32,10 @@ Robot.prototype.onScannedRobot = function(ev) { } //this.options.direction = (scanned.angle > 180) ? 1 : -1; robot.rotateCannon(10); for (var i=0; i<this.options.shootIterations; i++) { robot.fire(); robot.ahead(10); } }; -
heynemann revised this gist
Dec 5, 2012 . 1 changed file with 2 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -5,7 +5,7 @@ var Robot = function(robot){ this.options = { direction: 1, aheadWhileTurning: 1, shootIterations: 2, distanceToWalkBackOnHit: 50, hasCloned: false }; @@ -34,8 +34,8 @@ Robot.prototype.onScannedRobot = function(ev) { for (var i=0; i<this.options.shootIterations; i++) { robot.fire(); robot.turn(-10); robot.back(10); } }; -
heynemann revised this gist
Dec 5, 2012 . 1 changed file with 1 addition and 2 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -5,7 +5,7 @@ var Robot = function(robot){ this.options = { direction: 1, aheadWhileTurning: 1, shootIterations: 10, distanceToWalkBackOnHit: 50, hasCloned: false }; @@ -35,7 +35,6 @@ Robot.prototype.onScannedRobot = function(ev) { for (var i=0; i<this.options.shootIterations; i++) { robot.fire(); robot.turn(10); robot.turn(-10); } }; -
heynemann revised this gist
Dec 4, 2012 . 1 changed file with 3 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -34,6 +34,9 @@ Robot.prototype.onScannedRobot = function(ev) { for (var i=0; i<this.options.shootIterations; i++) { robot.fire(); robot.turn(10); robot.ahead(20); robot.turn(-10); } }; -
heynemann revised this gist
Dec 4, 2012 . No changes.There are no files selected for viewing
-
heynemann revised this gist
Dec 4, 2012 . No changes.There are no files selected for viewing
-
heynemann revised this gist
Dec 4, 2012 . 1 changed file with 1 addition and 4 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -5,7 +5,7 @@ var Robot = function(robot){ this.options = { direction: 1, aheadWhileTurning: 1, shootIterations: 100, distanceToWalkBackOnHit: 50, hasCloned: false }; @@ -34,9 +34,6 @@ Robot.prototype.onScannedRobot = function(ev) { for (var i=0; i<this.options.shootIterations; i++) { robot.fire(); } }; -
heynemann revised this gist
Dec 4, 2012 . 1 changed file with 3 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -6,7 +6,7 @@ var Robot = function(robot){ direction: 1, aheadWhileTurning: 1, shootIterations: 5, distanceToWalkBackOnHit: 50, hasCloned: false }; }; @@ -45,9 +45,10 @@ Robot.prototype.onWallCollision = function(ev) { }; Robot.prototype.onRobotCollision = function(ev) { ev.robot.turn(ev.bearing); ev.robot.back(this.options.distanceToWalkBackOnHit); }; Robot.prototype.onHitByBullet = function(ev) { ev.robot.turn(ev.bearing); }; -
heynemann revised this gist
Dec 4, 2012 . 1 changed file with 2 additions and 3 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -6,7 +6,7 @@ var Robot = function(robot){ direction: 1, aheadWhileTurning: 1, shootIterations: 5, distanceToWalkBackOnHit: 100, hasCloned: false }; }; @@ -45,10 +45,9 @@ Robot.prototype.onWallCollision = function(ev) { }; Robot.prototype.onRobotCollision = function(ev) { ev.robot.back(this.options.distanceToWalkBackOnHit); }; Robot.prototype.onHitByBullet = function(ev) { ev.robot.rotateCannon(ev.bearing); }; -
heynemann revised this gist
Dec 4, 2012 . 1 changed file with 13 additions and 3 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -1,25 +1,35 @@ //FightCode can only understand your robot //if its class is called Robot var Robot = function(robot){ //robot.ignore('onRobotCollision'); this.options = { direction: 1, aheadWhileTurning: 1, shootIterations: 5, distanceToWalkBackOnHit: 50, hasCloned: false }; }; Robot.prototype.onIdle = function(ev) { var robot = ev.robot; if (!this.options.hasCloned) { robot.clone(); this.options.hasCloned = true; } robot.turn(this.options.direction); robot.ahead(this.options.aheadWhileTurning); }; Robot.prototype.onScannedRobot = function(ev) { var robot = ev.robot, scanned = ev.scannedRobot; if (scanned.parentId != null || robot.parentId == scanned.id || robot.id == scanned.parentId){ return; } //this.options.direction = (scanned.angle > 180) ? 1 : -1; for (var i=0; i<this.options.shootIterations; i++) { -
heynemann revised this gist
Dec 4, 2012 . 1 changed file with 9 additions and 7 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -4,37 +4,39 @@ var Robot = function(robot){ //robot.ignore('onRobotCollision'); this.options = { direction: 1, aheadWhileTurning: 4, shootIterations: 5, distanceToWalkBackOnHit: 100 }; }; Robot.prototype.onIdle = function(ev) { var robot = ev.robot; robot.turn(this.options.direction); robot.ahead(this.options.aheadWhileTurning); }; Robot.prototype.onScannedRobot = function(ev) { var robot = ev.robot, scanned = ev.scannedRobot; //this.options.direction = (scanned.angle > 180) ? 1 : -1; for (var i=0; i<this.options.shootIterations; i++) { robot.fire(); robot.rotateCannon(2); robot.ahead(3); robot.rotateCannon(-2); } }; Robot.prototype.onWallCollision = function(ev) { ev.robot.back(this.options.distanceToWalkBackOnHit); }; Robot.prototype.onRobotCollision = function(ev) { ev.robot.turn(ev.bearing); ev.robot.back(this.options.distanceToWalkBackOnHit); }; Robot.prototype.onHitByBullet = function(ev) { -
heynemann revised this gist
Dec 4, 2012 . 1 changed file with 4 additions and 3 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -17,8 +17,8 @@ Robot.prototype.onIdle = function(ev) { Robot.prototype.onScannedRobot = function(ev) { var robot = ev.robot, scanned = ev.scannedRobot; //this.options.direction = (scanned.angle > 180) ? 1 : -1; for (var i=0; i<5; i++) { robot.fire(); robot.rotateCannon(2); @@ -28,7 +28,8 @@ Robot.prototype.onScannedRobot = function(ev) { }; Robot.prototype.onWallCollision = function(ev) { ev.robot.back(50); ev.robot.turn(1); }; Robot.prototype.onRobotCollision = function(ev) { -
heynemann revised this gist
Dec 4, 2012 . 1 changed file with 1 addition and 0 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -11,6 +11,7 @@ var Robot = function(robot){ Robot.prototype.onIdle = function(ev) { var robot = ev.robot; robot.turn(this.options.direction); robot.ahead(1); }; Robot.prototype.onScannedRobot = function(ev) { -
heynemann revised this gist
Dec 4, 2012 . 1 changed file with 3 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -20,7 +20,9 @@ Robot.prototype.onScannedRobot = function(ev) { for (var i=0; i<5; i++) { robot.fire(); robot.rotateCannon(2); robot.ahead(5); robot.rotateCannon(-2); } }; -
heynemann revised this gist
Dec 3, 2012 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -16,7 +16,7 @@ Robot.prototype.onIdle = function(ev) { Robot.prototype.onScannedRobot = function(ev) { var robot = ev.robot, scanned = ev.scannedRobot; this.options.direction = (scanned.angle > 180) ? 1 : -1; for (var i=0; i<5; i++) { robot.fire();
NewerOlder