Skip to content

Commit

Permalink
master Example 1 -> Example 2
Browse files Browse the repository at this point in the history
  • Loading branch information
stephenbush-wf committed Oct 13, 2015
1 parent 223299a commit c4f73c8
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions Example.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package exampleBot;

import battlecode.common.Direction;
import battlecode.common.MapLocation;
import battlecode.common.RobotController;


Expand All @@ -17,6 +18,12 @@ public static void run(RobotController rc) {

if ( rc.isActive() ) {
Direction dir = rc.getLocation().directionTo(rc.senseEnemyHQLocation()); // Get the direction to the enemy Base
MapLocation spawnLocation = rc.getLocation().add(dir); // Get me the next adjacent location in that direction

while ( rc.senseMine(spawnLocation) != null) { // Check to see if there's a mine at that location
dir = dir.rotateLeft(); // If so, rotate until we find a direction with no mines
spawnLocation = rc.getLocation().add(dir);
}

rc.spawn(dir); // Spawn a robot in that direction!!
}
Expand Down

0 comments on commit c4f73c8

Please sign in to comment.