@@ -77,17 +77,15 @@ public boolean engageEnemyTower() throws GameActionException {
77
77
// Move one step towards the enemy tower if possible
78
78
// Check if the robot is outside the tower's attack range but can still see it
79
79
// 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
+ // }
85
85
86
86
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 ()) {
91
89
rc .move (towardsTower );
92
90
// System.out.println("Moved towards enemy tower at: " + enemyTowerLocation);
93
91
@@ -103,7 +101,7 @@ public boolean engageEnemyTower() throws GameActionException {
103
101
}
104
102
105
103
// 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 ) {
107
105
Direction awayFromTower = enemyTowerLocation .directionTo (currentLocation );
108
106
if (rc .canMove (awayFromTower )) {
109
107
0 commit comments