Skip to content

Commit

Permalink
merge conflict
Browse files Browse the repository at this point in the history
  • Loading branch information
mvpatel2000 committed Jan 28, 2021
2 parents 251c464 + 3ee33af commit 9676fac
Showing 1 changed file with 26 additions and 3 deletions.
29 changes: 26 additions & 3 deletions src/jefferson/EnlightmentCenter.java
Original file line number Diff line number Diff line change
Expand Up @@ -407,7 +407,10 @@ else if (numPoliticians > numMuckrakers * poliMuckRatio()) {
else {
//System.out.println("Medium Sized Politician threshold: " + mediumSizedPolitician);
//System.out.println("Diluted Remaining Health:" + dilutedRemainingHealth);
if (Math.random() < 0.5) { // spawn defender
MapLocation tempEnemy = isMidGame ? optimalDestinationMidGame(false) : optimalDestination(false);
boolean allyCloser = existsAllyCloser(tempEnemy);
System.out.println("Only Produce large Politicians: " + (!nearbyMuckraker && allyCloser && currentRound >= 200 && remainingHealth == rc.getConviction()));
if (Math.random() < 0.5 && (nearbyMuckraker || !allyCloser || currentRound < 200 || remainingHealth != rc.getConviction())) { // spawn defender
MapLocation enemyLocation = isMidGame ? optimalDestinationMidGame(false) : optimalDestination(false);
System.out.println("Spawning defender: " + enemyLocation);
int influence = rc.getRoundNum() < 50 ? 14 : 18;
Expand All @@ -420,7 +423,7 @@ else if (numPoliticians > numMuckrakers * poliMuckRatio()) {
MapLocation enemyLocation = isMidGame ? optimalDestinationMidGame(true) : optimalDestination(true);
System.out.println("Spawning killer: " + enemyLocation);
int instr = SpawnDestinationFlag.INSTR_ATTACK;
if (rc.getRoundNum() > 300 && Math.random() < 0.5) {
if (rc.getRoundNum() > 300 && nearbyMuckraker) {
instr = SpawnDestinationFlag.INSTR_DEFEND_ATTACK;
}
spawnRobotWithTracker(RobotType.POLITICIAN, optimalDir, 1000, enemyLocation, instr, spawnDestIsGuess);
Expand All @@ -430,7 +433,7 @@ else if (numPoliticians > numMuckrakers * poliMuckRatio()) {
MapLocation enemyLocation = isMidGame ? optimalDestinationMidGame(true) : optimalDestination(true);
System.out.println("Spawning medium sized: " + enemyLocation);
int instr = SpawnDestinationFlag.INSTR_ATTACK;
if (rc.getRoundNum() > 300 && Math.random() < 0.5) {
if (rc.getRoundNum() > 300 && nearbyMuckraker) {
instr = SpawnDestinationFlag.INSTR_DEFEND_ATTACK;
}
spawnRobotWithTracker(RobotType.POLITICIAN, optimalDir, mediumSizedPolitician, enemyLocation, instr, spawnDestIsGuess);
Expand Down Expand Up @@ -510,6 +513,25 @@ MapLocation optimalSlandererDestination() {
} return 1.5;
}

boolean existsAllyCloser(MapLocation enemyLoc) {
int dist2 = myLocation.distanceSquaredTo(enemyLoc);
if (numAllyECs == 0 && capturedAllyECLocsToInfluence.isEmpty()) {
return false;
} else {
for (int i=0; i<numAllyECs; i++) {
if (allyECLocs[i].distanceSquaredTo(enemyLoc) < dist2) {
return true;
}
}
for (MapLocation ml : capturedAllyECLocsToInfluence.keySet()) {
if (ml.distanceSquaredTo(enemyLoc) < dist2) {
return true;
}
}
}
return false;
}

/**
* Reads flags from Ally ECs.
* Handles logic: Given a flag from an Ally EC, what does this EC do?
Expand Down Expand Up @@ -1054,6 +1076,7 @@ MapLocation optimalDestination(boolean includeNeutral, boolean prioritizeDistanc
dArr[1] = vertFurthestDirection == Direction.NORTH ? stop*sendY : -stop*sendY;
} else {
// Randomly launch vertically, horizontally, or at 45 degrees (45 deg TODO).
// System.out.println("randomly launching in all dirs");
int[] dHoriz = optimalHorizontalDestination(horizAbsSum, horizSum, horizFurthestDirection, horizFurthestWall);
int[] dVert = optimalVerticalDestination(vertAbsSum, vertSum, vertFurthestDirection, vertFurthestWall);
double rand = Math.random();
Expand Down

0 comments on commit 9676fac

Please sign in to comment.