@Test public void processOneBotCoveringAll() { when(ballConsultant.getTimeForKick(anyDouble(), anyDouble())).thenReturn(0.2); IVector2 pos = Vector2.fromXY(1000, 0); ICircle horizon = Circle.createCircle(pos, 2000); mockBot(pos, horizon, 0); List<AngleRange> coveredAngles = processor.findCoveredAngleRanges(); assertThat(coveredAngles).hasSize(1); }
public List<AngleRange> findCoveredAngleRanges() { List<AngleRange> coveredAngles = new ArrayList<>(); ITriangle triangle = createTriangle(); IVector2 endCenter = TriangleMath.bisector(start, endLeft, endRight); IVector2 startToEndCenter = endCenter.subtractNew(start); List<MovingRobot> robots = movingRobots.entrySet().stream() .filter(entry -> !excludedBots.contains(entry.getKey())) .map(Map.Entry::getValue) .collect(Collectors.toList()); for (MovingRobot movingRobot : robots) { double distBotToStart = movingRobot.getPos().distanceTo(start); double timeBallToBot = ballConsultant.getTimeForKick(distBotToStart, kickSpeed) + timeToKick; double horizon = Math.max(0, timeBallToBot - timeForBotToReact); ICircle obstacleCircle = movingRobot.getMovingHorizon(horizon); List<IVector2> intersections = obstacleCircle.tangentialIntersections(start); if (triangle.isPointInShape(movingRobot.getPos()) || intersections.stream().anyMatch(triangle::isPointInShape)) { addAngleRange(coveredAngles, startToEndCenter, intersections); } } return coveredAngles; }
AngleRangeGenerator { public List<AngleRange> findCoveredAngleRanges() { List<AngleRange> coveredAngles = new ArrayList<>(); ITriangle triangle = createTriangle(); IVector2 endCenter = TriangleMath.bisector(start, endLeft, endRight); IVector2 startToEndCenter = endCenter.subtractNew(start); List<MovingRobot> robots = movingRobots.entrySet().stream() .filter(entry -> !excludedBots.contains(entry.getKey())) .map(Map.Entry::getValue) .collect(Collectors.toList()); for (MovingRobot movingRobot : robots) { double distBotToStart = movingRobot.getPos().distanceTo(start); double timeBallToBot = ballConsultant.getTimeForKick(distBotToStart, kickSpeed) + timeToKick; double horizon = Math.max(0, timeBallToBot - timeForBotToReact); ICircle obstacleCircle = movingRobot.getMovingHorizon(horizon); List<IVector2> intersections = obstacleCircle.tangentialIntersections(start); if (triangle.isPointInShape(movingRobot.getPos()) || intersections.stream().anyMatch(triangle::isPointInShape)) { addAngleRange(coveredAngles, startToEndCenter, intersections); } } return coveredAngles; } }
AngleRangeGenerator { public List<AngleRange> findCoveredAngleRanges() { List<AngleRange> coveredAngles = new ArrayList<>(); ITriangle triangle = createTriangle(); IVector2 endCenter = TriangleMath.bisector(start, endLeft, endRight); IVector2 startToEndCenter = endCenter.subtractNew(start); List<MovingRobot> robots = movingRobots.entrySet().stream() .filter(entry -> !excludedBots.contains(entry.getKey())) .map(Map.Entry::getValue) .collect(Collectors.toList()); for (MovingRobot movingRobot : robots) { double distBotToStart = movingRobot.getPos().distanceTo(start); double timeBallToBot = ballConsultant.getTimeForKick(distBotToStart, kickSpeed) + timeToKick; double horizon = Math.max(0, timeBallToBot - timeForBotToReact); ICircle obstacleCircle = movingRobot.getMovingHorizon(horizon); List<IVector2> intersections = obstacleCircle.tangentialIntersections(start); if (triangle.isPointInShape(movingRobot.getPos()) || intersections.stream().anyMatch(triangle::isPointInShape)) { addAngleRange(coveredAngles, startToEndCenter, intersections); } } return coveredAngles; }  }
AngleRangeGenerator { public List<AngleRange> findCoveredAngleRanges() { List<AngleRange> coveredAngles = new ArrayList<>(); ITriangle triangle = createTriangle(); IVector2 endCenter = TriangleMath.bisector(start, endLeft, endRight); IVector2 startToEndCenter = endCenter.subtractNew(start); List<MovingRobot> robots = movingRobots.entrySet().stream() .filter(entry -> !excludedBots.contains(entry.getKey())) .map(Map.Entry::getValue) .collect(Collectors.toList()); for (MovingRobot movingRobot : robots) { double distBotToStart = movingRobot.getPos().distanceTo(start); double timeBallToBot = ballConsultant.getTimeForKick(distBotToStart, kickSpeed) + timeToKick; double horizon = Math.max(0, timeBallToBot - timeForBotToReact); ICircle obstacleCircle = movingRobot.getMovingHorizon(horizon); List<IVector2> intersections = obstacleCircle.tangentialIntersections(start); if (triangle.isPointInShape(movingRobot.getPos()) || intersections.stream().anyMatch(triangle::isPointInShape)) { addAngleRange(coveredAngles, startToEndCenter, intersections); } } return coveredAngles; }  List<AngleRange> findCoveredAngleRanges(); List<AngleRange> findUncoveredAngleRanges(); List<AngleRange> findUncoveredAngleRanges(final List<AngleRange> coveredAngles, final AngleRange fullRange); AngleRange getAngleRange(); IVector2 getStart(); void setStart(final IVector2 start); IVector2 getEndLeft(); void setEndLeft(final IVector2 endLeft); IVector2 getEndRight(); void setEndRight(final IVector2 endRight); void setKickSpeed(final double kickSpeed); void setTimeToKick(final double timeToKick); Map<BotID, MovingRobot> getMovingRobots(); void setMovingRobots(final Map<BotID, MovingRobot> movingRobots); void setBallConsultant(final IStraightBallConsultant ballConsultant); void setTimeForBotToReact(final double timeForBotToReact); void setExcludedBots(final Set<BotID> excludedBots); void setExtendTriangle(final boolean extendTriangle); }
AngleRangeGenerator { public List<AngleRange> findCoveredAngleRanges() { List<AngleRange> coveredAngles = new ArrayList<>(); ITriangle triangle = createTriangle(); IVector2 endCenter = TriangleMath.bisector(start, endLeft, endRight); IVector2 startToEndCenter = endCenter.subtractNew(start); List<MovingRobot> robots = movingRobots.entrySet().stream() .filter(entry -> !excludedBots.contains(entry.getKey())) .map(Map.Entry::getValue) .collect(Collectors.toList()); for (MovingRobot movingRobot : robots) { double distBotToStart = movingRobot.getPos().distanceTo(start); double timeBallToBot = ballConsultant.getTimeForKick(distBotToStart, kickSpeed) + timeToKick; double horizon = Math.max(0, timeBallToBot - timeForBotToReact); ICircle obstacleCircle = movingRobot.getMovingHorizon(horizon); List<IVector2> intersections = obstacleCircle.tangentialIntersections(start); if (triangle.isPointInShape(movingRobot.getPos()) || intersections.stream().anyMatch(triangle::isPointInShape)) { addAngleRange(coveredAngles, startToEndCenter, intersections); } } return coveredAngles; }  List<AngleRange> findCoveredAngleRanges(); List<AngleRange> findUncoveredAngleRanges(); List<AngleRange> findUncoveredAngleRanges(final List<AngleRange> coveredAngles, final AngleRange fullRange); AngleRange getAngleRange(); IVector2 getStart(); void setStart(final IVector2 start); IVector2 getEndLeft(); void setEndLeft(final IVector2 endLeft); IVector2 getEndRight(); void setEndRight(final IVector2 endRight); void setKickSpeed(final double kickSpeed); void setTimeToKick(final double timeToKick); Map<BotID, MovingRobot> getMovingRobots(); void setMovingRobots(final Map<BotID, MovingRobot> movingRobots); void setBallConsultant(final IStraightBallConsultant ballConsultant); void setTimeForBotToReact(final double timeForBotToReact); void setExcludedBots(final Set<BotID> excludedBots); void setExtendTriangle(final boolean extendTriangle);  }