Skip to content

Commit aeb933e

Browse files
made engageEnemyTower not hard coded for soliders
1 parent 7d9d7ec commit aeb933e

File tree

1 file changed

+8
-10
lines changed

1 file changed

+8
-10
lines changed

java/src/s2/TowerEngager.java

+8-10
Original file line numberDiff line numberDiff line change
@@ -77,17 +77,15 @@ public boolean engageEnemyTower() throws GameActionException {
7777
// Move one step towards the enemy tower if possible
7878
// Check if the robot is outside the tower's attack range but can still see it
7979
// System.out.println("Debug Before Cooldown Check: Movement=" + rc.getMovementCooldownTurns() + ", Action=" + rc.getActionCooldownTurns());
80-
if (rc.getMovementCooldownTurns() > 0 || rc.getActionCooldownTurns() > 0) { //IMPORTANT RUNNING WITH 0 IS OPTIMAL BUT SHOUDL TWEAK LATER
81-
// System.out.println("Movement cooldown: " + rc.getMovementCooldownTurns());
82-
// System.out.println("Cooldowns too high, skipping engagement. Action cooldown is:" + rc.getActionCooldownTurns());
83-
return true;
84-
}
80+
// if (!rc.isActionReady() || !rc.isMovementReady()) { //IMPORTANT RUNNING WITH 0 IS OPTIMAL BUT SHOUDL TWEAK LATER
81+
// // System.out.println("Movement cooldown: " + rc.getMovementCooldownTurns());
82+
// // System.out.println("Cooldowns too high, skipping engagement. Action cooldown is:" + rc.getActionCooldownTurns());
83+
// return true;
84+
// }
8585

8686

87-
if (currentLocation.distanceSquaredTo(enemyTowerLocation) > 9 &&
88-
currentLocation.distanceSquaredTo(enemyTowerLocation) <= 16 &&
89-
rc.getMovementCooldownTurns() == 0 && rc.getActionCooldownTurns() == 0) {
90-
if (rc.canMove(towardsTower)) {
87+
if (currentLocation.distanceSquaredTo(enemyTowerLocation) > rc.getType().actionRadiusSquared) {
88+
if (rc.canMove(towardsTower) && rc.isActionReady()) {
9189
rc.move(towardsTower);
9290
// System.out.println("Moved towards enemy tower at: " + enemyTowerLocation);
9391

@@ -103,7 +101,7 @@ public boolean engageEnemyTower() throws GameActionException {
103101
}
104102

105103
// If the robot is within the tower's attack range, move one step away
106-
if (currentLocation.distanceSquaredTo(enemyTowerLocation) <= 9) {
104+
if (currentLocation.distanceSquaredTo(enemyTowerLocation) <= rc.getType().actionRadiusSquared) {
107105
Direction awayFromTower = enemyTowerLocation.directionTo(currentLocation);
108106
if (rc.canMove(awayFromTower)) {
109107

0 commit comments

Comments
 (0)