Skip to content
Merged
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
15 changes: 13 additions & 2 deletions java/src/s2/Tower.java
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,18 @@ public void run() throws GameActionException {
// break; // Spawn only one soldier
// }
// }
MapInfo[] infos = rc.senseNearbyMapInfos(-1);
RobotInfo[] nearbyEnemies = rc.senseNearbyRobots(-1, rc.getTeam().opponent());

int e_count = 0;
for (MapInfo mapInfo: infos) {
if (mapInfo.getPaint().isEnemy()) {
e_count++;
}
}
if (e_count>35 || nearbyEnemies.length > 3) {
rtype = 2;
}

// Pick a direction to build in.
Direction dir = directions[rng.nextInt(directions.length)];
Expand All @@ -64,7 +76,7 @@ public void run() throws GameActionException {
if (spawn_count[rtype] >= target_count[rtype]) {
rtype++;
}
if (rtype > 2) {
if (rtype == 2) {
rtype = 0;
spawn_count[0] = 0;
spawn_count[1] = 0;
Expand All @@ -83,7 +95,6 @@ public void run() throws GameActionException {
}

// Attack logic for Tower
RobotInfo[] nearbyEnemies = rc.senseNearbyRobots(-1, rc.getTeam().opponent());

// Perform Single Target Attack on the lowest HP priority target
if (nearbyEnemies.length > 0) {
Expand Down
Loading