From f6fc807ae75c1ca23861d3698d2987ff22ca00c2 Mon Sep 17 00:00:00 2001 From: Mihir Date: Wed, 27 Jan 2021 17:22:30 -0800 Subject: [PATCH] v1 optimization --- src/jefferson/EnlightmentCenter.java | 4 ++-- src/jefferson/Politician.java | 8 ++++++++ src/jefferson/Unit.java | 2 +- 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src/jefferson/EnlightmentCenter.java b/src/jefferson/EnlightmentCenter.java index abf669c..d88c5e4 100644 --- a/src/jefferson/EnlightmentCenter.java +++ b/src/jefferson/EnlightmentCenter.java @@ -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; diff --git a/src/jefferson/Politician.java b/src/jefferson/Politician.java index 55264c7..df3fe84 100644 --- a/src/jefferson/Politician.java +++ b/src/jefferson/Politician.java @@ -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; @@ -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); diff --git a/src/jefferson/Unit.java b/src/jefferson/Unit.java index 11ee9a9..50df17e 100644 --- a/src/jefferson/Unit.java +++ b/src/jefferson/Unit.java @@ -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);