diff --git a/.idea/.gitignore b/.idea/.gitignore
new file mode 100644
index 0000000..13566b8
--- /dev/null
+++ b/.idea/.gitignore
@@ -0,0 +1,8 @@
+# Default ignored files
+/shelf/
+/workspace.xml
+# Editor-based HTTP Client requests
+/httpRequests/
+# Datasource local storage ignored files
+/dataSources/
+/dataSources.local.xml
diff --git a/.idea/misc.xml b/.idea/misc.xml
new file mode 100644
index 0000000..aecc280
--- /dev/null
+++ b/.idea/misc.xml
@@ -0,0 +1,5 @@
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/vcs.xml b/.idea/vcs.xml
new file mode 100644
index 0000000..35eb1dd
--- /dev/null
+++ b/.idea/vcs.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/examplefuncsplayer/Pathfind.java b/src/examplefuncsplayer/Pathfind.java
new file mode 100644
index 0000000..33b1438
--- /dev/null
+++ b/src/examplefuncsplayer/Pathfind.java
@@ -0,0 +1,35 @@
+package examplefuncsplayer;
+
+import battlecode.common.Direction;
+import battlecode.common.GameActionException;
+import battlecode.common.MapLocation;
+import battlecode.common.RobotController;
+
+public class Pathfind {
+
+ private static Direction dir;
+
+ public static void moveTowards(RobotController rc, MapLocation loc, boolean fill) throws GameActionException {
+ Direction dir = rc.getLocation().directionTo(loc);
+ if(rc.canMove(dir)) rc.move(dir);
+ else if(fill & rc.canFill(rc.getLocation().add(dir))) rc.fill(rc.getLocation().add(dir));
+ else {
+ Direction randDir = RobotPlayer.directions[RobotPlayer.random.nextInt(8)];
+ if(rc.canMove(randDir)) rc.move(randDir);
+ }
+ }
+
+ public static void explore(RobotController rc) throws GameActionException {
+ if(rc.isMovementReady()) {
+ MapLocation[] crumbLocs = rc.senseNearbyCrumbs(-1);
+ if(crumbLocs.length > 0) {
+ moveTowards(rc, crumbLocs[0], false);
+ }
+
+ if(dir == null || !rc.canMove(dir)) {
+ dir = RobotPlayer.directions[RobotPlayer.random.nextInt(8)];
+ }
+ if(rc.canMove(dir)) rc.move(dir);
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/examplefuncsplayer/RobotPlayer.java b/src/examplefuncsplayer/RobotPlayer.java
index da15984..b22095c 100644
--- a/src/examplefuncsplayer/RobotPlayer.java
+++ b/src/examplefuncsplayer/RobotPlayer.java
@@ -30,7 +30,7 @@ public strictfp class RobotPlayer {
* we get the same sequence of numbers every time this code is run. This is very useful for debugging!
*/
static final Random rng = new Random(6147);
-
+ public static Random random = null;
/** Array containing all the possible movement directions. */
static final Direction[] directions = {
Direction.NORTH,
@@ -71,6 +71,8 @@ public static void run(RobotController rc) throws GameActionException {
try {
// Make sure you spawn your robot in before you attempt to take any actions!
// Robots not spawned in do not have vision of any tiles and cannot perform any actions.
+ if(random == null) random = new Random(rc.getID());
+
if (!rc.isSpawned()){
MapLocation[] spawnLocs = rc.getAllySpawnLocations();
// Pick a random spawn location to attempt spawning in.
@@ -78,6 +80,8 @@ public static void run(RobotController rc) throws GameActionException {
if (rc.canSpawn(randomLoc)) rc.spawn(randomLoc);
}
else{
+ int round = rc.getRoundNum();
+ if(round < GameConstants.SETUP_ROUNDS) Setup.runSetup(rc);
if (rc.canPickupFlag(rc.getLocation())){
rc.pickupFlag(rc.getLocation());
rc.setIndicatorString("Holding a flag!");
@@ -108,6 +112,7 @@ else if (rc.canAttack(nextLoc)){
rc.build(TrapType.EXPLOSIVE, prevLoc);
// We can also move our code into different methods or classes to better organize it!
updateEnemyRobots(rc);
+ healNearbyFriend(rc);
}
} catch (GameActionException e) {
@@ -151,4 +156,16 @@ public static void updateEnemyRobots(RobotController rc) throws GameActionExcept
}
}
}
+
+ public static void healNearbyFriend (RobotController rc) throws GameActionException {
+ RobotInfo[] nearbyFriends = rc.senseNearbyRobots(2, rc.getTeam());
+ for (RobotInfo friend : nearbyFriends) {
+ if (friend.health < 1000 && rc.canHeal(friend.getLocation())) {
+ rc.heal(friend.getLocation());
+ System.out.println("Healed a friendly unit!");
+ rc.setIndicatorString("Healing: " + friend.getLocation());
+ break; // Heal only one unit per turn
+ }
+ }
+ }
}
diff --git a/src/examplefuncsplayer/Setup.java b/src/examplefuncsplayer/Setup.java
new file mode 100644
index 0000000..b8844ba
--- /dev/null
+++ b/src/examplefuncsplayer/Setup.java
@@ -0,0 +1,53 @@
+package examplefuncsplayer;
+
+import battlecode.common.*;
+
+public class Setup {
+
+ private static final int EXPLORE_ROUNDS = 150;
+
+ public static void runSetup(RobotController rc) throws GameActionException {
+
+ if(rc.getRoundNum() < EXPLORE_ROUNDS) {
+ //pickup flag if possible, explore randomly
+ FlagInfo[] flags = rc.senseNearbyFlags(-1);
+ for(FlagInfo flag : flags) {
+ MapLocation flagLoc = flag.getLocation();
+ if(rc.senseMapInfo(flagLoc).isSpawnZone() && rc.canPickupFlag(flagLoc)) {
+ rc.pickupFlag(flag.getLocation());
+ }
+ }
+ Pathfind.explore(rc);
+ }
+ else {
+ //try to place flag if it is far enough away from other flags
+ if(rc.senseLegalStartingFlagPlacement(rc.getLocation())) {
+ if(rc.canDropFlag(rc.getLocation())) rc.dropFlag(rc.getLocation());
+ }
+ //move towards flags and place defenses around them
+ FlagInfo[] flags = rc.senseNearbyFlags(-1);
+
+ FlagInfo targetFlag = null;
+ for(FlagInfo flag : flags) {
+ if(!flag.isPickedUp()) {
+ targetFlag = flag;
+ break;
+ }
+ }
+
+ if(targetFlag != null) {
+ Pathfind.moveTowards(rc, targetFlag.getLocation(), false);
+ if(rc.getLocation().distanceSquaredTo(flags[0].getLocation()) < 9) {
+ if(rc.canBuild(TrapType.EXPLOSIVE, rc.getLocation())) {
+ rc.build(TrapType.EXPLOSIVE, rc.getLocation());
+ }
+ else {
+ MapLocation waterLoc = rc.getLocation().add(RobotPlayer.directions[RobotPlayer.random.nextInt(8)]);
+ if(rc.canDig(waterLoc)) rc.dig(waterLoc);
+ }
+ }
+ }
+ else Pathfind.explore(rc);
+ }
+ }
+}
\ No newline at end of file
diff --git a/version.txt b/version.txt
index 3eefcb9..7da3c16 100644
--- a/version.txt
+++ b/version.txt
@@ -1 +1 @@
-1.0.0
+3.0.5
\ No newline at end of file