if (isFallingBack(entity)) { total *= PRIORITY_FALLBACK; modifiers.append("\tx2.0 (is Fleeing)");
@Test public void testIsFallingBack() { Entity mockMech = Mockito.mock(BipedMech.class); Mockito.when(mockMech.isImmobile()).thenReturn(false); Mockito.when(mockMech.isCrippled(Mockito.anyBoolean())).thenReturn(false); Mockito.when(mockMech.getId()).thenReturn(1); Mockito.when(mockPrincess.wantsToFallBack(Mockito.any(Entity.class))).thenReturn(false); Mockito.when(mockPrincess.isFallingBack(Mockito.any(Entity.class))).thenCallRealMethod(); BehaviorSettings mockBehavior = Mockito.mock(BehaviorSettings.class); Mockito.when(mockBehavior.getDestinationEdge()).thenReturn(CardinalEdge.NEAREST_OR_NONE); Mockito.when(mockBehavior.isForcedWithdrawal()).thenReturn(true); Mockito.when(mockPrincess.getBehaviorSettings()).thenReturn(mockBehavior); // A normal undamaged mech. Assert.assertFalse(mockPrincess.isFallingBack(mockMech)); // A mobile mech that wants to fall back (for any reason). Mockito.when(mockMech.isCrippled(Mockito.anyBoolean())).thenReturn(true); Assert.assertTrue(mockPrincess.isFallingBack(mockMech)); }
boolean inRange = (maxRange >= startingTargetDistance); CardinalEdge homeEdge = getOwner().getHomeEdge(mover); boolean fleeing = getOwner().isFallingBack(mover);
Mockito.when(mockPrincess.isFallingBack(Mockito.any(Entity.class))).thenReturn(false); Mockito.when(mockPrincess.isFallingBack(Mockito.any(Entity.class))).thenReturn(true); Assert.assertFalse(mockPrincess.mustFleeBoard(mockMech));
boolean mustFleeBoard(final Entity entity) { if (!isFallingBack(entity)) { return false; } if (!entity.canFlee()) { return false; } if (0 < getPathRanker(entity).distanceToHomeEdge(entity.getPosition(), getHomeEdge(entity), getGame())) { return false; } //noinspection RedundantIfStatement if (!getFleeBoard() && !(entity.isCrippled() && getForcedWithdrawal())) { return false; } return true; }
Mockito.when(mockPrincess.calculateMoveIndex(Mockito.any(Entity.class), Mockito.any(StringBuilder.class))) .thenCallRealMethod(); Mockito.when(mockPrincess.isFallingBack(Mockito.any(Entity.class))).thenReturn(false); Mockito.when(mockPrincess.isFallingBack(Mockito.eq(mockMech))).thenReturn(true); expected = 2.222; actual = mockPrincess.calculateMoveIndex(mockMech, new StringBuilder()); Mockito.when(mockPrincess.isFallingBack(Mockito.eq(mockMech))).thenReturn(false); Mockito.when(mockMech.isCommander()).thenReturn(true); expected = 0.555;
getPrecognition().ensureUpToDate(); if (isFallingBack(entity)) { String msg = entity.getDisplayName(); if (getFallBack()) {
/** * Tells me whether this path will result in me flying to a location * from which there is absolutely no way to remain on the board the following turn. * * We also take into account the possibility that we are intentionally trying to * a) retreat * b) fly off a particular edge * @param path The path to examine * @return 0 if we are A-Ok with it, .5 (maybe tune this) if we aren't looking to go off board */ @Override protected double calculateOffBoardMod(MovePath path) { // step one: project given path's vector over the next turn. OffBoardDirection offBoardDirection = calculateOffBoardDirection(path.getEntity(), path.getFinalCoords(), path.getFinalVectors()); // if we want to flee the board from the edge in question, we're ok if(getOwner().isFallingBack(path.getEntity()) && (getOwner().getHomeEdge(path.getEntity()) == CardinalEdge.getCardinalEdge(offBoardDirection.getValue()))) { return 0.0; } if(offBoardDirection == OffBoardDirection.NONE) { return 0.0; } return .5; }
if(owner.isFallingBack(shooter) && !owner.canShootWhileFallingBack(shooter)) { return retval;