Skip to content

Commit

Permalink
master Example 7 -> Example 8
Browse files Browse the repository at this point in the history
  • Loading branch information
stephenbush-wf committed Oct 13, 2015
1 parent fecfac2 commit ab63cdf
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions Example.java
Original file line number Diff line number Diff line change
Expand Up @@ -39,15 +39,16 @@ public static void run(RobotController rc) {

if ( rc.isActive() ) {
Direction moveDir = rc.getLocation().directionTo(enemyBase); // I want to move in the direction of the enemy HQ!
MapLocation moveLocation = rc.getLocation().add(moveDir); // Get me the next adjacent location in that direction

while( !rc.canMove(moveDir) ) { // Check to see if i can move there, ie whether or not there's another bot there
moveDir = moveDir.rotateLeft(); // If not, rotate until i get a direction with no robots
}
MapLocation moveLocation = rc.getLocation().add(moveDir); // Get me the next adjacent location in that direction

if ( rc.senseMine(moveLocation) != null ) { // But first make sure there are no mines
rc.defuseMine(moveLocation); // If so, defuse it!
} else {
while( !rc.canMove(moveDir) ) { // Check to see if i can move there, ie whether or not there's another bot there
moveDir = moveDir.rotateLeft(); // If not, rotate until i get a direction with no robots
}
rc.move(moveDir); // If so, move in that direction!
rc.move(moveDir); // Move in that direction!
}


Expand Down

0 comments on commit ab63cdf

Please sign in to comment.