Skip to content

Commit

Permalink
v1 optimization
Browse files Browse the repository at this point in the history
  • Loading branch information
mvpatel2000 committed Jan 28, 2021
1 parent cb151ce commit f6fc807
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 3 deletions.
4 changes: 2 additions & 2 deletions src/jefferson/EnlightmentCenter.java
Original file line number Diff line number Diff line change
Expand Up @@ -167,8 +167,8 @@ public EnlightmentCenter(RobotController rc) throws GameActionException {
public void run() throws GameActionException {
super.run();

if (currentRound == 100) {
// rc.resign(); // TODO: remove; just for debugging
if (currentRound == 800) {
rc.resign(); // TODO: remove; just for debugging
}

spawnDestIsGuess = true;
Expand Down
8 changes: 8 additions & 0 deletions src/jefferson/Politician.java
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,9 @@ public void runUnit() throws GameActionException {

// System.out.println("1: " + Clock.getBytecodesLeft());
// Read flags to check for slanderers
if (nearbyAllies.length > 20) {
nearbyAllies = rc.senseNearbyRobots(RobotType.POLITICIAN.actionRadiusSquared, allyTeam);
}
areSlanderers = new boolean[nearbyAllies.length];
nearbySlanderer = false;
edgeSlanderer = null;
Expand Down Expand Up @@ -405,6 +408,11 @@ public boolean considerAttack(boolean bigAttacker, boolean paranoid) throws Game
}
}

// Everyone around us is an ally, no need to attack
if (nearbyNeutral.length == 0 && nearbyEnemies.length == 0) {
return false;
}


// Recreate arrays with smaller radius only considering attack
RobotInfo[] attackNearbyRobots = rc.senseNearbyRobots(RobotType.POLITICIAN.actionRadiusSquared);
Expand Down
2 changes: 1 addition & 1 deletion src/jefferson/Unit.java
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ public RobotInfo getNearestEnemyFromAllies() throws GameActionException {
MapLocation enemyLoc = null;
MapLocation allyLoc = null; // TODO: remove, for debugging purposes
RobotType enemyType = null;
for (int i = 0; i < Math.min(20, nearbyAllies.length); i++) {
for (int i = 0; i < Math.min(10, nearbyAllies.length); i++) {
RobotInfo r = nearbyAllies[i];
if (rc.canGetFlag(r.ID)) {
int flag = rc.getFlag(r.ID);
Expand Down

0 comments on commit f6fc807

Please sign in to comment.