Created
December 6, 2012 00:00
-
-
Save ografael/4220696 to your computer and use it in GitHub Desktop.
Revisions
-
Zolmeister revised this gist
Dec 5, 2012 . 1 changed file with 46 additions and 170 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,180 +1,56 @@ 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); }; -
Zolmeister 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 @@ -54,7 +54,7 @@ Robot.prototype.onIdle = function(ev) { this[c].target=this[o].target } if (!this[c].searching && !this[c].tracking && !this[c].target) { //this[c].searching = true if (c == 'robo') { if (this[c].y > robot.arenaHeight + 200 / 2) {//on top half, so turn down if (this[c].angle < 90 || this[c].angle > 270) { -
Zolmeister revised this gist
Dec 5, 2012 . 1 changed file with 5 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 @@ -108,9 +108,10 @@ Robot.prototype.onIdle = function(ev) { var p2 = this[c].target c12 = p1.x * p2.x + p1.y * p2.y s12 = p1.x * p2.y - p1.y * p2.x a12 = Math.atan2(s12, c12)*180/Math.PI robot.rotateCannon((a12)*(Math.abs(a12-this[c].angle)>180?-10:1)) //console.log(a12-this[c].angle) //turn cannon to face target } this[c].ticker += 1 @@ -139,6 +140,7 @@ Robot.prototype.onIdle = function(ev) { Robot.prototype.onWallCollision = function(ev) { var robot = ev.robot; c = robot.parentId != undefined ? 'clo' : 'robo' console.log("HIT WALL") this[c].moveDir *= -1 robot.ahead(1000 * this[c].moveDir) }; -
Zolmeister revised this gist
Dec 5, 2012 . 1 changed file with 168 additions and 48 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,58 +1,178 @@ //clone //search field efficiently for enemy (main, ignore any clones) //on found: //fire at them //clone moves 300 units away from bot //turn parallel to them //move forward/backward (if wall hit then switch) //continuously track enemy position //if lose position (not found within next firing position), go back to finding algo //calculate enemy trajectory //when can fire another round, fire using calculated trajectory //on hit other robot, rotate 90 deg, go forward 100, then search for enemy again //on hit wall, flip movement direction var Robot = function(robot) { robot.clone(); this.robo = { moveDir : 1, tracking : false, ticker : 0 } this.clo = { moveDir : -1, tracking : false, ticker : 0 } }; Robot.prototype.onIdle = function(ev) { var robot = ev.robot; c = robot.parentId != undefined ? 'clo' : 'robo' o = c == 'robo' ? 'clo' : 'robo' this[c].x = robot.position.x this[c].y = robot.position.x this[c].gunCoolDownTime = robot.gunCoolDownTime this[c].angle = robot.angle this[c].cannonAngle = robot.cannonAbsoluteAngle /*if (this[o].tracking && !this[c].tracking) { this[c].tracking = true this[c].searching = false var tar = this[o].target this[c].target = tar var p1 = this[c] var p2 = tar c12 = p1.x * p2.x + p1.y * p2.y s12 = p1.x * p2.y - p1.y * p2.x a12 = Math.atan2(s12, c12) if (a12 > 180) robot.rotateCannon((a12 - 180) * -1) else robot.rotateCannon(a12) }*/ if(this[o].target && !this[c].target){ this[c].target=this[o].target } if (!this[c].searching && !this[c].tracking && !this[c].target) { this[c].searching = true if (c == 'robo') { if (this[c].y > robot.arenaHeight + 200 / 2) {//on top half, so turn down if (this[c].angle < 90 || this[c].angle > 270) { robot.rotateCannon(360) } else robot.rotateCannon(-360) } else if (this[c].y < robot.arenaHeight + 200 / 2 - 200) {//on bottom half so turn up if (this[c].angle < 90 || this[c].angle > 270) { robot.rotateCannon(-360) } else robot.rotateCannon(360) } else if (this[c].x > robot.arenaWidth / 2) {//on right half, so start turning left if (this[c].angle < 180) { robot.rotateCannon(-360) } else robot.rotateCannon(360) } else {//on left half, so start turning right if (this[c].angle < 180) { robot.rotateCannon(360) } else robot.rotateCannon(-360) } } else { if (this[c].x > robot.arenaWidth / 2 + 200) {//on right half, so start turning left if (this[c].angle < 180) { robot.rotateCannon(-360) } else robot.rotateCannon(360) } else if (this[c].x < robot.arenaWidth / 2 - 200) {//on left half, so start turning right if (this[c].angle < 180) { robot.rotateCannon(360) } else robot.rotateCannon(-360) } else if (this[c].y > robot.arenaHeight / 2) {//on top half, so turn down if (this[c].angle < 90 || this[c].angle > 270) { robot.rotateCannon(360) } else robot.rotateCannon(-360) } else {//on bottom half so turn up if (this[c].angle < 90 || this[c].angle > 270) { robot.rotateCannon(-360) } else robot.rotateCannon(360) } } } else { if (this[c].target && this[c].gunCoolDownTime == 0) { //get my angle, and the position of the target var p1 = this[c] var p2 = this[c].target c12 = p1.x * p2.x + p1.y * p2.y s12 = p1.x * p2.y - p1.y * p2.x a12 = Math.atan2(s12, c12) robot.rotateCannon(a12 - this[c].angle) console.log("rotate to target") //turn cannon to face target } this[c].ticker += 1 if (this[c].ticker > 1000) { this[c].searching = false this[c].tracking = false this[c].ticker=0 this[c].target = undefined } } /*if(this[c].tracking){ //console.log("tracking") this[c].trackCount+=1 if(this[c].trackCount>1000){ console.log("tracking voer") this[c].tracking=false this[c].searching=true } if(this[c].gunCoolDownTime==0){ //robot.rotateCannon(this[c].moveDir*360) } robot.ahead(10*this[c].moveDir) }*/ }; Robot.prototype.onWallCollision = function(ev) { var robot = ev.robot; c = robot.parentId != undefined ? 'clo' : 'robo' this[c].moveDir *= -1 robot.ahead(1000 * this[c].moveDir) }; Robot.prototype.onRobotCollision = function(ev) { var robot = ev.robot, collidedRobot = ev.collidedRobot; c = robot.parentId != undefined ? 'clo' : 'robo' this[c].moveDir *= -1 robot.ahead(1000 * this[c].moveDir) }; Robot.prototype.onHitByBullet = function(ev) { }; Robot.prototype.onScannedRobot = function(ev) { var robot = ev.robot, scannedRobot = ev.scannedRobot; if (robot.id == scannedRobot.parentId || robot.parentId == scannedRobot.id) { return; } if (scannedRobot.parentId) {//found a clone return } c = robot.parentId != undefined ? 'clo' : 'robo' if (!this[c].tracking) { robot.stop() robot.fire(); //robot.turn(scannedRobot.angle-180) } else { robot.fire(); } robot.ahead(30 * this[c].moveDir) this[c].tracking = false this[c].trackCount = 0 this[c].ticker = 0 this[c].searching = false this[c].target = { x : scannedRobot.position.x, y : scannedRobot.position.y } }; -
Zolmeister revised this gist
Dec 5, 2012 . 1 changed file with 45 additions and 63 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,76 +1,58 @@ var Robot = function(robot){ robot.turnLeft(robot.angle % 90); //robot.turnGunRight(90); robot.clone(); this.direction = 1; }; Robot.prototype.onIdle = function(ev) { var robot = ev.robot; if (!robot.parentId) { robot.ahead(1); //if (robot.cannonRelativeAngle > 270 || robot.cannonRelativeAngle < 90) { // this.direction *= -1; //} //robot.turnGunRight(this.direction); //robot.turnGunRight(180); //robot.turnGunRight(-180); } else{ robot.ahead(1); robot.turnGunRight(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) { }; Robot.prototype.onScannedRobot = function(ev) { var robot = ev.robot, scannedRobot = ev.scannedRobot; if (robot.id == scannedRobot.parentId || robot.parentId == scannedRobot.id) { return; } robot.fire(); if(robot.parentId) robot.turnGunLeft(30); //robot.log('firing'); }; -
Zolmeister revised this gist
Dec 4, 2012 . No changes.There are no files selected for viewing
-
Zolmeister revised this gist
Dec 4, 2012 . No changes.There are no files selected for viewing
-
Zolmeister revised this gist
Dec 4, 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 @@ -8,14 +8,15 @@ var Robot = function(robot) { }; Robot.prototype.onIdle = function(ev) { var robot = ev.robot; var clo =0 robot.clone(); if(robot.parentId!=null){ clo=-240; } robot.id=2 robot.rotateCannon(90); robot = ev.robot; -
Zolmeister revised this gist
Dec 4, 2012 . 1 changed file with 57 additions and 31 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,49 +1,75 @@ //FightCode can only understand your robot //if its class is called Robot var go=120; var Robot = function(robot) { }; Robot.prototype.onIdle = function(ev) { var robot = ev.robot; var clo =0 robot.clone(); if(robot.parentId!=null){ clo=-240; } robot.rotateCannon(90); robot = ev.robot; if(.6>Math.random()){ robot.ahead(go+clo); robot.turn(95); } }; Robot.prototype.onScannedRobot = function(ev) { var sr = ev.scannedRobot; var robot = ev.robot; var bFriendly = ( robot.parentId !=null && robot.parentId==sr.id); bFriendly |= ( sr.parentId !=null && sr.parentId==robot.id); if(bFriendly){ robot.back(50); } if(!bFriendly){ robot.fire(); robot.fire(); robot.rotateCannon(-15); robot.fire(); robot.fire(); robot.rotateCannon(-10); } }; Robot.prototype.onWallCollision= function(ev){ var robot = ev.robot; go=go*-1; robot.back(go); robot.rotateCannon(90); robot.back(go); robot.rotateCannon(90); } Robot.prototype.onHitByBullet = function(ev) { var robot = ev.robot; if(robot.parentId!=null){ robot.turn(ev.bearing); robot.fire(); robot.fire(); robot.fire(); robot.fire(); robot.fire(); } }; Robot.prototype.onRobotCollision = function(ev) { var robot = ev.robot; robot.turn(20); robot.ahead(100); // trying to run away }; -
Zolmeister revised this gist
Dec 4, 2012 . 1 changed file with 2 additions and 6 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 @@ -8,13 +8,9 @@ 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); }; -
Zolmeister revised this gist
Dec 4, 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 @@ -13,6 +13,8 @@ Robot.prototype.onIdle = function(ev) { robot.back(100); robot.rotateCannon(360); robot.back(10); if(robot.parentId) robot.ahead(300); robot.rotateCannon(360); }; -
Zolmeister 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 @@ -9,9 +9,12 @@ Robot.prototype.onIdle = function(ev) { var robot = ev.robot; robot.clone(); robot.ahead(10); if(robot.parentId) robot.back(100); robot.rotateCannon(360); robot.back(10); robot.rotateCannon(360); }; Robot.prototype.onScannedRobot = function(ev) { -
Zolmeister 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 @@ -8,11 +8,10 @@ var Robot = function(robot) { Robot.prototype.onIdle = function(ev) { var robot = ev.robot; robot.clone(); robot.ahead(10); robot.rotateCannon(360); robot.back(10); robot.rotateCannon(360); }; Robot.prototype.onScannedRobot = function(ev) { -
Zolmeister revised this gist
Dec 4, 2012 . 1 changed file with 41 additions and 50 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,58 +1,49 @@ //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 }; -
Zolmeister revised this gist
Dec 4, 2012 . No changes.There are no files selected for viewing
-
Zolmeister revised this gist
Dec 4, 2012 . No changes.There are no files selected for viewing
-
Zolmeister revised this gist
Dec 4, 2012 . 1 changed file with 8 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,15 +6,19 @@ var Robot = function(robot){ }; Robot.prototype.onIdle = function(ev) { var robot = ev.robot; if (!robot.parentId) { robot.ahead(1); //if (robot.cannonRelativeAngle > 270 || robot.cannonRelativeAngle < 90) { // this.direction *= -1; //} //robot.turnGunRight(this.direction); //robot.turnGunRight(180); //robot.turnGunRight(-180); } else{ robot.ahead(1); robot.turnGunRight(1); } }; Robot.prototype.onWallCollision = function(ev) { @@ -48,5 +52,7 @@ Robot.prototype.onScannedRobot = function(ev) { return; } robot.fire(); if(robot.parentId) robot.turnGunLeft(30); //robot.log('firing'); }; -
Zolmeister revised this gist
Dec 2, 2012 . No changes.There are no files selected for viewing
-
Zolmeister revised this gist
Dec 2, 2012 . 1 changed file with 47 additions and 31 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,36 +1,52 @@ var Robot = function(robot){ robot.turnLeft(robot.angle % 90); //robot.turnGunRight(90); robot.clone(); this.direction = 1; }; Robot.prototype.onIdle = function(ev) { var robot = ev.robot; robot.ahead(1); if (robot.parentId) { //if (robot.cannonRelativeAngle > 270 || robot.cannonRelativeAngle < 90) { // this.direction *= -1; //} //robot.turnGunRight(this.direction); //robot.turnGunRight(180); //robot.turnGunRight(-180); } }; 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) { }; 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.log('firing'); }; -
Zolmeister revised this gist
Dec 2, 2012 . 1 changed file with 31 additions and 47 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,52 +1,36 @@ var Robot = function(robot) { this.dir=1; this.once=false }; Robot.prototype.onIdle = function(ev) { var robot = ev.robot; if(!robot.parentId) robot.rotateCannon(-1*this.dir); else{ robot.rotateCannon(-1); } if(robot.parentId && !this.once){ this.once=true; robot.back(100); } robot.clone(); }; Robot.prototype.onScannedRobot = function(ev) { var robot = ev.robot; var srobo = ev.scannedRobot; var id1 = robot.parentId || robot.id; var id2 = srobo.parentId || srobo.id; if(id1!=id2){ if(!robot.parentId){ robot.stop(); robot.fire(); robot.rotateCannon(-30*this.dir); this.dir*=-1; } else{ robot.rotateCannon(15); robot.fire(5); } } }; -
Zolmeister revised this gist
Dec 2, 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 @@ -28,7 +28,7 @@ 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); } -
Zolmeister revised this gist
Dec 2, 2012 . 1 changed file with 4 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 @@ -19,13 +19,16 @@ Robot.prototype.onIdle = function(ev) { }; 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); } -
Zolmeister revised this gist
Dec 2, 2012 . 1 changed file with 5 additions and 6 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,17 +1,17 @@ var Robot = function(robot){ robot.turnLeft(robot.angle % 90); //robot.turnGunRight(90); robot.clone(); this.direction = 1; }; Robot.prototype.onIdle = function(ev) { var robot = ev.robot; robot.ahead(1); if (robot.parentId) { //if (robot.cannonRelativeAngle > 270 || robot.cannonRelativeAngle < 90) { // this.direction *= -1; //} //robot.turnGunRight(this.direction); //robot.turnGunRight(180); //robot.turnGunRight(-180); } @@ -20,7 +20,6 @@ Robot.prototype.onIdle = function(ev) { Robot.prototype.onWallCollision = function(ev) { var robot = ev.robot; robot.turnRight(ev.bearing + 90); }; Robot.prototype.onRobotCollision = function(ev) { var robot = ev.robot, collidedRobot = ev.collidedRobot; -
cezarsa revised this gist
Dec 2, 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 @@ -46,5 +46,5 @@ Robot.prototype.onScannedRobot = function(ev) { return; } robot.fire(); //robot.log('firing'); }; -
cezarsa revised this gist
Dec 2, 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 @@ -46,4 +46,5 @@ Robot.prototype.onScannedRobot = function(ev) { return; } robot.fire(); robot.log('firing'); }; -
cezarsa revised this gist
Nov 30, 2012 . 1 changed file with 8 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 @@ -2,13 +2,20 @@ var Robot = function(robot){ robot.turnLeft(robot.angle % 90); robot.turnGunRight(90); robot.clone(); this.direction = 1; }; Robot.prototype.onIdle = function(ev) { var robot = ev.robot; robot.ahead(1); if (robot.parentId) { if (robot.cannonRelativeAngle > 270 || robot.cannonRelativeAngle < 90) { this.direction *= -1; } robot.turnGunRight(this.direction); //robot.turnGunRight(180); //robot.turnGunRight(-180); } }; Robot.prototype.onWallCollision = function(ev) { var robot = ev.robot; -
cezarsa revised this gist
Nov 30, 2012 . 1 changed file with 4 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,10 @@ var Robot = function(robot){ }; Robot.prototype.onIdle = function(ev) { var robot = ev.robot; robot.ahead(1); if (robot.parentId) { robot.turnGunRight(1) } }; Robot.prototype.onWallCollision = function(ev) { var robot = ev.robot; @@ -14,7 +17,6 @@ Robot.prototype.onWallCollision = function(ev) { }; 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); -
cezarsa revised this gist
Nov 29, 2012 . No changes.There are no files selected for viewing
-
cezarsa revised this gist
Nov 29, 2012 . No changes.There are no files selected for viewing
-
cezarsa revised this gist
Nov 29, 2012 . No changes.There are no files selected for viewing
NewerOlder