Пример #1
0
  /**
   * Add a spline to the path
   *
   * @param wFrame
   * @param path
   * @param pfi
   */
  public void addAHermiteSpline(
      final SimpleWorldFrame wFrame, final Path path, final PathFinderInput pfi) {
    TrackedTigerBot bot = wFrame.getBot(pfi.getBotId());
    float dstOrient = pfi.getDstOrient();
    List<IVector2> mPath = new ArrayList<IVector2>();
    mPath.add(DistanceUnit.MILLIMETERS.toMeters(bot.getPos()));

    for (IVector2 p : path.getPath()) {
      mPath.add(DistanceUnit.MILLIMETERS.toMeters(p));
    }

    if (pfi.getMoveCon().getSpeed() > 0) {
      trajGeneratorMove.setPositionTrajParams(
          pfi.getMoveCon().getSpeed(), Sisyphus.maxLinearAcceleration);
    } else {
      trajGeneratorMove.setPositionTrajParams(
          Sisyphus.maxLinearVelocity, Sisyphus.maxLinearAcceleration);
    }
    trajGeneratorMove.setRotationTrajParams(maxRotateVelocity, Sisyphus.maxRotateAcceleration);
    trajGeneratorMove.setSplineParams(normalAngleToSpeed);
    trajGeneratorMove.setReducePathScore(pathReductionScore);

    SplinePair3D trajectories =
        trajGeneratorMove.create(
            mPath,
            bot.getVel(),
            pfi.getMoveCon().getVelAtDestination(),
            bot.getAngle(),
            dstOrient,
            bot.getaVel(),
            0);
    path.setHermiteSpline(trajectories);
    trajectories.setStartTime(System.nanoTime());
  }
  @Override
  public void doCalc(final TacticalField newTacticalField, final BaseAiFrame baseAiFrame) {
    WorldFrame wFrame = baseAiFrame.getWorldFrame();
    IBotIDMap<TrackedTigerBot> bots = wFrame.tigerBotsAvailable;
    for (TrackedTigerBot bot : bots.values()) {
      BotID botId = bot.getId();
      BotAiInformation aiInfo = new BotAiInformation();

      aiInfo.setBallContact(bot.hasBallContact());
      aiInfo.setVel(bot.getVel());

      Path path = baseAiFrame.getPrevFrame().getAresData().getLatestPaths().get(botId);
      aiInfo.setPathPlanning(path != null);
      aiInfo.setNumPaths(baseAiFrame.getPrevFrame().getAresData().getNumberOfPaths(botId));

      ABot aBot = bot.getBot();
      if (aBot != null) {
        aiInfo.setBattery(aBot.getBatteryLevel());
        aiInfo.setKickerCharge(aBot.getKickerLevel());
      }

      play:
      for (APlay play : baseAiFrame.getPrevFrame().getPlayStrategy().getActivePlays()) {
        for (ARole role : play.getRoles()) {
          if (role.getBotID().equals(botId)) {
            aiInfo.setPlay(play.getType().name());
            aiInfo.setRole(role.getType().name());
            ISkill skill = role.getCurrentSkill();
            if (skill != null) {
              aiInfo.setSkill(skill.getSkillName().name());
            } else {
              aiInfo.setSkill("no skill");
            }
            aiInfo.setRoleState(role.getCurrentState().name());

            ISkill moveSkill = role.getCurrentSkill();
            if (moveSkill instanceof MoveToSkill) {
              MovementCon moveCon = ((MoveToSkill) moveSkill).getMoveCon();
              aiInfo.addCondition(moveCon.getDestCon().getCondition());
              aiInfo.addCondition(moveCon.getAngleCon().getCondition());
            }

            break play;
          }
        }
      }

      newTacticalField.getBotAiInformation().put(botId, aiInfo);
    }
  }