Skip to content

Commit

Permalink
fix: merge conflict
Browse files Browse the repository at this point in the history
  • Loading branch information
Scoppio committed Feb 4, 2025
1 parent 918cfca commit 3278714
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 19 deletions.
14 changes: 4 additions & 10 deletions megamek/src/megamek/client/bot/princess/BasicPathRanker.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
import megamek.client.bot.princess.BotGeometry.CoordFacingCombo;
import megamek.client.bot.princess.BotGeometry.HexLine;
import megamek.client.bot.princess.UnitBehavior.BehaviorType;
import megamek.codeUtilities.MathUtility;
import megamek.common.*;
import megamek.common.options.OptionsConstants;
import megamek.common.planetaryconditions.PlanetaryConditions;
Expand Down Expand Up @@ -63,13 +62,8 @@ public class BasicPathRanker extends PathRanker {
protected int blackIce = -1;

public BasicPathRanker(Princess owningPrincess) {
this(owningPrincess, owningPrincess.getPrecognition().getPathEnumerator());
}

public BasicPathRanker(Princess owningPrincess, PathEnumerator pathEnumerator) {
super(owningPrincess);
bestDamageByEnemies = new TreeMap<>();
this.pathEnumerator = pathEnumerator;
logger.debug("Using %s behavior.", getOwner().getBehaviorSettings().getDescription());
}

Expand Down Expand Up @@ -102,9 +96,9 @@ boolean isInMyLoS(Entity unit, HexLine leftBounds, HexLine rightBounds) {
&& (rightBounds.judgeArea(pathEnumerator.getUnitMovableAreas().get(unit.getId())) < 0);
}

double getMaxDamageAtRange(FireControl fireControl, Entity shooter, int range, boolean useExtremeRange,
double getMaxDamageAtRange(Entity shooter, int range, boolean useExtremeRange,
boolean useLOSRange) {
return fireControl.getMaxDamageAtRange(shooter, range, useExtremeRange, useLOSRange);
return FireControl.getMaxDamageAtRange(shooter, range, useExtremeRange, useLOSRange);
}

boolean canFlankAndKick(Entity enemy, Coords behind, Coords leftFlank, Coords rightFlank, int myFacing) {
Expand Down Expand Up @@ -173,7 +167,7 @@ public EntityEvaluationResponse evaluateUnmovedEnemy(Entity enemy, MovePath path

if (isInMyLoS(enemy, leftBounds, rightBounds)) {
returnResponse.addToMyEstimatedDamage(
getMaxDamageAtRange(getFireControl(path.getEntity()),
getMaxDamageAtRange(
path.getEntity(),
range,
useExtremeRange,
Expand All @@ -182,7 +176,7 @@ public EntityEvaluationResponse evaluateUnmovedEnemy(Entity enemy, MovePath path

// in general if an enemy can end its position in range, it can hit me
returnResponse.addToEstimatedEnemyDamage(
getMaxDamageAtRange(getFireControl(enemy),
getMaxDamageAtRange(
enemy,
range,
useExtremeRange,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ protected RankedPath rankPath(MovePath path, Game game, int maxRange, double fal
}

@Override
EntityEvaluationResponse evaluateUnmovedEnemy(Entity enemy, MovePath path, boolean useExtremeRange, boolean useLOSRange) {
public EntityEvaluationResponse evaluateUnmovedEnemy(Entity enemy, MovePath path, boolean useExtremeRange, boolean useLOSRange) {
//some preliminary calculations
final double damageDiscount = 0.25;
EntityEvaluationResponse returnResponse =
Expand Down
2 changes: 1 addition & 1 deletion megamek/src/megamek/client/bot/princess/PathRanker.java
Original file line number Diff line number Diff line change
Expand Up @@ -379,7 +379,7 @@ protected double getMovePathSuccessProbability(MovePath movePath) {
* @param path
* @return
*/
protected double calculateMovePathPSRDamage(Entity movingEntity, MovePath path) {
public double calculateMovePathPSRDamage(Entity movingEntity, MovePath path) {
double damage = 0.0;

List<TargetRoll> pilotingRolls = getPSRList(path);
Expand Down
3 changes: 3 additions & 0 deletions megamek/src/megamek/client/bot/princess/Princess.java
Original file line number Diff line number Diff line change
Expand Up @@ -2728,12 +2728,15 @@ public void initializePathRankers() {
pathRankers = new HashMap<>();

BasicPathRanker basicPathRanker = new BasicPathRanker(this);
basicPathRanker.setPathEnumerator(getPrecognition().getPathEnumerator());
pathRankers.put(PathRankerType.Basic, basicPathRanker);

InfantryPathRanker infantryPathRanker = new InfantryPathRanker(this);
infantryPathRanker.setPathEnumerator(getPrecognition().getPathEnumerator());
pathRankers.put(PathRankerType.Infantry, infantryPathRanker);

NewtonianAerospacePathRanker newtonianAerospacePathRanker = new NewtonianAerospacePathRanker(this);
newtonianAerospacePathRanker.setPathEnumerator(getPrecognition().getPathEnumerator());
pathRankers.put(PathRankerType.NewtonianAerospace, newtonianAerospacePathRanker);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ void testEvaluateUnmovedAeroEnemy() {
final Entity mockMyUnit = MockGenerators.generateMockBipedMek(0, 0);
when(mockMyUnit.canChangeSecondaryFacing()).thenReturn(true);

doReturn(10.0).when(testRanker).getMaxDamageAtRange(nullable(FireControl.class),
doReturn(10.0).when(testRanker).getMaxDamageAtRange(
eq(mockMyUnit), anyInt(), anyBoolean(), anyBoolean());

final MovePath mockPath = MockGenerators.generateMockPath(testCoords, mockMyUnit);
Expand All @@ -207,7 +207,7 @@ void testEvaluateUnmovedEnemyInLOSAndUnableToKick() {
final Entity mockMyUnit = MockGenerators.generateMockBipedMek(0, 0);
when(mockMyUnit.canChangeSecondaryFacing()).thenReturn(true);

doReturn(10.0).when(testRanker).getMaxDamageAtRange(nullable(FireControl.class),
doReturn(10.0).when(testRanker).getMaxDamageAtRange(
eq(mockMyUnit), anyInt(), anyBoolean(), anyBoolean());

final MovePath mockPath = MockGenerators.generateMockPath(testCoords, mockMyUnit);
Expand All @@ -226,7 +226,7 @@ void testEvaluateUnmovedEnemyInLOSAndUnableToKick() {
.isInMyLoS(eq(mockEnemyMek), any(HexLine.class), any(HexLine.class));
doReturn(8.5)
.when(testRanker)
.getMaxDamageAtRange(nullable(FireControl.class), eq(mockEnemyMek), anyInt(),
.getMaxDamageAtRange(eq(mockEnemyMek), anyInt(),
anyBoolean(),
anyBoolean());
doReturn(false)
Expand All @@ -252,7 +252,7 @@ void testEvaluateUnmovedEnemyNotInLOS() {
final Entity mockMyUnit = MockGenerators.generateMockBipedMek(0, 0);
when(mockMyUnit.canChangeSecondaryFacing()).thenReturn(true);

doReturn(10.0).when(testRanker).getMaxDamageAtRange(nullable(FireControl.class),
doReturn(10.0).when(testRanker).getMaxDamageAtRange(
eq(mockMyUnit), anyInt(), anyBoolean(), anyBoolean());

final MovePath mockPath = MockGenerators.generateMockPath(testCoords, mockMyUnit);
Expand All @@ -271,7 +271,7 @@ void testEvaluateUnmovedEnemyNotInLOS() {
.isInMyLoS(eq(mockEnemyMek), any(HexLine.class), any(HexLine.class));
doReturn(8.5)
.when(testRanker)
.getMaxDamageAtRange(nullable(FireControl.class), eq(mockEnemyMek), anyInt(),
.getMaxDamageAtRange(eq(mockEnemyMek), anyInt(),
anyBoolean(), anyBoolean());
doReturn(false)
.when(testRanker)
Expand All @@ -294,7 +294,7 @@ void testEvaluateUnmovedEnemyNotInLOSAndAbleToKick() {
final Entity mockMyUnit = MockGenerators.generateMockBipedMek(0, 0);
when(mockMyUnit.canChangeSecondaryFacing()).thenReturn(true);

doReturn(10.0).when(testRanker).getMaxDamageAtRange(nullable(FireControl.class),
doReturn(10.0).when(testRanker).getMaxDamageAtRange(
eq(mockMyUnit), anyInt(), anyBoolean(), anyBoolean());

final MovePath mockPath = MockGenerators.generateMockPath(testCoords, mockMyUnit);
Expand All @@ -313,7 +313,7 @@ void testEvaluateUnmovedEnemyNotInLOSAndAbleToKick() {
.isInMyLoS(eq(mockEnemyMek), any(HexLine.class), any(HexLine.class));
doReturn(8.5)
.when(testRanker)
.getMaxDamageAtRange(nullable(FireControl.class), eq(mockEnemyMek), anyInt(),
.getMaxDamageAtRange(eq(mockEnemyMek), anyInt(),
anyBoolean(), anyBoolean());
doReturn(true)
.when(testRanker)
Expand Down

0 comments on commit 3278714

Please sign in to comment.