Robocode(A.K.A. how to make Zach eat his words and that strategy wins over sheer power!) by Andy Mahoney

Explosions galore fighting to the death with these battle bots is the type of excitement every programmer lives for. Program these Robots in Java and battle them in a struggle to the top! Now I will become number 1 in QHS my only challenger is Zack Smith, the man sitting to my right. WP_20150529_001

 

 

 

 

 

 

 

 

Alpha has three tactics based on how many enemies he’s facing. if it’s 1 he rams into them and fires as many times as possible. If it’s 2 he swerves around avoiding fire, and if it’s three he hides in a corner and snipes for the points. But Zack Exploited this.

code for startagy:

while(true) {

// Replace the next 4 lines with any behavior you would like
if (getOthers()>2){
turnGunRight(360);
goCorner();
}
else if (getOthers()<2){
turnGunRight(360);
turnRight(5 * turnDirection);

}

else {
setAhead(40000);
movingForward = true;
// Tell the game we will want to turn right 90
setTurnRight(90);
// At this point, we have indicated to the game that *when we do something*,
// we will want to move ahead and turn right. That’s what “set” means.
// It is important to realize we have not done anything yet!
// In order to actually move, we’ll want to call a method that
// takes real time, such as waitFor.
// waitFor actually starts the action — we start moving and turning.
// It will not return until we have finished turning.
waitFor(new TurnCompleteCondition(this));
// Note: We are still moving ahead now, but the turn is complete.
// Now we’ll turn the other way…
setTurnLeft(180);
// … and wait for the turn to finish …
waitFor(new TurnCompleteCondition(this));
// … then the other way …
setTurnRight(180);
// .. and wait for that turn to finish.
waitFor(new TurnCompleteCondition(this));
// then back to the top to do it all again
}
}
}

 

Don’t worry though because Alpha has back up on his team The Greeks. Meet Beta, the camping Tank ofg doom used to counter act PvtPuppyYawn.

Code for Beta:

public void onScannedRobot(ScannedRobotEvent e) {
// Replace the next line with any behavior you would like
if (isTeammate(e.getName())) {
return;
}
else{
fire(2);
}
}

/**
* onHitByBullet: What to do when you’re hit by a bullet
*/
public void onHitByBullet(HitByBulletEvent e) {
// Replace the next line with any behavior you would like
ahead(500);
}

/**
* onHitWall: What to do when you hit a wall
*/
public void onHitWall(HitWallEvent e) {
// Replace the next line with any behavior you would like
back(20);
ahead(10);
}
}

Unfortunately due to my unwillingness Zack in one night created 3 new robots and aligned them on a team so they wouldn’t kill each other. The percent wins out of 100 cam to 66% for the Squad and 34% for TheGreeks. I will make my team stronger nad larger next time. So watch out Zack for the new and improved TheGreeks. We’re coming after you!

 

Link for Alpha:  https://docs.google.com/document/d/14fogjNsjiv_nNBdfFlGZe7wGsQFlzNoPFygHFLlWIwI/edit?usp=sharing

Link for Beta:  https://docs.google.com/document/d/1wRZdcFsvOa2ynhKSMYcgseftw04cUnLfgxzhm-Dw6dI/edit?usp=sharing

Link for TheGreeks: https://docs.google.com/document/d/1xHfuPWH026h59-OZZH7cJh8vFJ7m8-NwvJYxuLhYTeA/edit?usp=sharing

Leave a Reply

Your email address will not be published. Required fields are marked *