@Before public void setUp() { mockPathRanker = Mockito.mock(BasicPathRanker.class); MoralUtil mockMoralUtil = Mockito.mock(MoralUtil.class); MMLogger fakeLogger = new FakeLogger(); mockPrincess = Mockito.mock(Princess.class); Mockito.doNothing().when(mockPrincess).log(Mockito.any(Class.class), Mockito.anyString(), Mockito.any(LogLevel.class), Mockito.anyString()); Mockito.when(mockPrincess.getPathRanker(PathRankerType.Basic)).thenReturn(mockPathRanker); Mockito.when(mockPrincess.getPathRanker(Mockito.any(Entity.class))).thenReturn(mockPathRanker); Mockito.when(mockPrincess.getMoralUtil()).thenReturn(mockMoralUtil); Mockito.when(mockPrincess.getLogger()).thenReturn(fakeLogger); }
final double distance = getPathRanker(entity).distanceToClosestEnemy(entity, entity.getPosition(), game);
Mockito.when(mockRanker.distanceToHomeEdge(Mockito.any(Coords.class), Mockito.any(CardinalEdge.class), Mockito.any(IGame.class))).thenReturn(0); Mockito.when(mockPrincess.getPathRanker(Mockito.any(Entity.class))).thenReturn(mockRanker);
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; }
getPathRanker(entity).initUnitTurn(entity, getGame()); final double fallTolerance = getBehaviorSettings().getFallShameIndex() / 10d; final int startingHomeDistance = getPathRanker(entity).distanceToHomeEdge( entity.getPosition(), getBehaviorSettings().getDestinationEdge(), getGame()); final List<RankedPath> rankedpaths = getPathRanker(entity).rankPaths(paths, getGame(), entity.getMaxWeaponRange(), Long.toString(stop_time - startTime) + " millis"); final RankedPath bestpath = getPathRanker(entity).getBestPath(rankedpaths); log(getClass(), METHOD_NAME, LogLevel.INFO, "Best Path: " + bestpath.getPath() + " Rank: "
Mockito.when(mockPrincess.getPathRanker(PathRankerType.Basic)).thenReturn(mockPathRanker);
Entity closestEnemy = getPathRanker(movingEntity).findClosestEnemy(movingEntity, pathEndpoint, getGame());