Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4,427 changes: 4,427 additions & 0 deletions java/src/safe_explore_baseline/Attack.java

Large diffs are not rendered by default.

48 changes: 48 additions & 0 deletions java/src/safe_explore_baseline/Comms.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
package safe_explore_baseline;
import battlecode.common.*;

public class Comms {
public static RobotController rc;
public static void init(RobotController rc) throws GameActionException {
Comms.rc = rc;
}

public static void run() throws GameActionException {
updateSym();
broadcastSym();
}

public static void updateSym() throws GameActionException {
Message[] m = rc.readMessages(-1);
for (int i = m.length; --i >= 0;) {
int msg = m[i].getBytes();
SymmetryChecker.RSYM &= (msg & 1);
SymmetryChecker.HSYM &= ((msg & 2) >> 1);
SymmetryChecker.VSYM &= ((msg & 4) >> 2);
}
}

public static void broadcastSym() throws GameActionException {
int R = SymmetryChecker.RSYM;
int H = SymmetryChecker.HSYM;
int V = SymmetryChecker.VSYM;
int send = R + 2 * H + 4 * V;
if (Globals.isTower(rc.getType())) {
if (rc.canBroadcastMessage()) {
rc.broadcastMessage(send);
}
for (int i = Globals.friends.length; --i >= 0;) {
if (rc.canSendMessage(Globals.friends[i].location, send)) {
rc.sendMessage(Globals.friends[i].location, send);
}
}
}
else {
for (int i = Globals.friends.length; --i >= 0;) if (Globals.isTower(Globals.friends[i].getType())) {
if (rc.canSendMessage(Globals.friends[i].location, send)) {
rc.sendMessage(Globals.friends[i].location, send);
}
}
}
}
}
75 changes: 75 additions & 0 deletions java/src/safe_explore_baseline/Explore.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
package safe_explore_baseline;
import battlecode.common.*;
import java.util.Stack;

public class Explore {
public static RobotController rc;
public static MapLocation exploreTarget = null;
public static Stack<MapLocation> circle;

//r = 8
//public static int cX[] = {-8, -5, 0, 5, 8, 5, 0, -5};
//public static int cY[] = {0, 6, 8, 6, 0, -6, -8, -6};

public static int cX[] = {-6, -4, 0, 4, 6, 4, 0, -6};
public static int cY[] = {0, 4, 6, 4, 0, -4, -6, -4};

public static void init(RobotController rc) {
Explore.rc = rc;
circle = new Stack<>();
}

public static void exploreOnPaint(MapInfo[] near) throws GameActionException {
explore(near);
}

public static void explore(MapInfo[] near) throws GameActionException {
if (exploreTarget == null || rc.getLocation().distanceSquaredTo(exploreTarget) <= 5) {
/*
if (!circle.isEmpty()) {
exploreTarget = circle.pop();
}
else {
if (Globals.rng.nextInt(3) == 0) {
int st = Globals.rng.nextInt(8);
MapLocation loc;

loc = new MapLocation(rc.getLocation().x + cX[(st + 0) % 8], rc.getLocation().y + cY[(st + 0) % 8]);
if (Globals.onMap(loc)) {
circle.push(loc);
}

loc = new MapLocation(rc.getLocation().x + cX[(st + 1) % 8], rc.getLocation().y + cY[(st + 1) % 8]);
if (Globals.onMap(loc)) {
circle.push(loc);
}

loc = new MapLocation(rc.getLocation().x + cX[(st + 2) % 8], rc.getLocation().y + cY[(st + 2) % 8]);
if (Globals.onMap(loc)) {
circle.push(loc);
}

loc = new MapLocation(rc.getLocation().x + cX[(st + 3) % 8], rc.getLocation().y + cY[(st + 3) % 8]);
if (Globals.onMap(loc)) {
circle.push(loc);
}

exploreTarget = circle.pop();
}
if (exploreTarget == null) {
exploreTarget = new MapLocation(
Globals.rng.nextInt(rc.getMapWidth()),
Globals.rng.nextInt(rc.getMapHeight())
);
}
}
*/
exploreTarget = new MapLocation(
Globals.rng.nextInt(rc.getMapWidth()),
Globals.rng.nextInt(rc.getMapHeight())
);
}
Pathing.pathTo(exploreTarget);
}

}
Loading