Skip to content

Commit 7d115f0

Browse files
Merge pull request #13 from CoffeeCoder1015/dynamicMopping
Makes mopper spawning dyanmic
2 parents 94aac76 + ae4c373 commit 7d115f0

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

java/src/s2/Tower.java

+13-2
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,18 @@ public void run() throws GameActionException {
4444
// break; // Spawn only one soldier
4545
// }
4646
// }
47+
MapInfo[] infos = rc.senseNearbyMapInfos(-1);
48+
RobotInfo[] nearbyEnemies = rc.senseNearbyRobots(-1, rc.getTeam().opponent());
49+
50+
int e_count = 0;
51+
for (MapInfo mapInfo: infos) {
52+
if (mapInfo.getPaint().isEnemy()) {
53+
e_count++;
54+
}
55+
}
56+
if (e_count>35 || nearbyEnemies.length > 3) {
57+
rtype = 2;
58+
}
4759

4860
// Pick a direction to build in.
4961
Direction dir = directions[rng.nextInt(directions.length)];
@@ -64,7 +76,7 @@ public void run() throws GameActionException {
6476
if (spawn_count[rtype] >= target_count[rtype]) {
6577
rtype++;
6678
}
67-
if (rtype > 2) {
79+
if (rtype == 2) {
6880
rtype = 0;
6981
spawn_count[0] = 0;
7082
spawn_count[1] = 0;
@@ -83,7 +95,6 @@ public void run() throws GameActionException {
8395
}
8496

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

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

0 commit comments

Comments
 (0)