Exemplo n.º 1
0
  @Override
  public void manage() {
    updateExplorationMap();

    List<Planner> planners = new ArrayList<>();

    planners.add(new ColonyPlanner(world, controls));

    planners.add(new ResearchPlanner(world, controls, exploration));
    planners.add(new ColonizationPlanner(world, controls));
    planners.add(
        new ExplorationPlanner(
            world,
            controls,
            exploration,
            new Action1<Date>() {
              @Override
              public void invoke(Date value) {
                lastSatelliteDeploy = value;
              }
            }));

    int mix1 = planners.size();
    planners.add(new EconomyPlanner(world, controls));
    planners.add(new OffensePlanner(world, controls));
    planners.add(new StaticDefensePlanner(world, controls));
    int mix2 = planners.size();

    planners.add(
        new AttackPlanner(
            world,
            controls,
            exploration,
            new Action1<Date>() {
              @Override
              public void invoke(Date value) {
                nextAttack = value;
              }
            }));

    ModelUtils.shuffle(planners.subList(mix1, mix2));

    for (Planner p : planners) {
      List<Action0> acts = p.run();
      if (!acts.isEmpty()) {
        applyActions.addAll(acts);
        if (p.getClass() == ColonyPlanner.class) {
          return;
        }
      }
    }
  }
Exemplo n.º 2
0
 /**
  * Select a target in range which the current ship can do most damage.
  *
  * @param world the world object.
  * @param ship the current ship
  */
 static void selectNewTarget(SpacewarWorld world, final SpacewarStructure ship) {
   List<SpacewarStructure> es = world.enemiesInRange(ship);
   ModelUtils.shuffle(es);
   SpacewarStructure best = null;
   double bestEfficiency = 0d;
   for (SpacewarStructure s : es) {
     BattleEfficiencyModel bem = ship.getEfficiency(s);
     double eff = bem != null ? bem.damageMultiplier : 1d;
     if (eff > bestEfficiency) {
       best = s;
       bestEfficiency = eff;
     }
   }
   if (best != null) {
     world.attack(ship, best, Mode.BEAM);
   }
 }