예제 #1
0
파일: A.java 프로젝트: VlSomers/ProjectsIA
  public double cost() {
    double totalCost = 0;
    for (MyVehicle v : vehicleActions.keySet()) {
      City c = v.homeCity();
      long vehicleDistanceSum = 0;
      for (Action action : vehicleActions.get(v)) {
        vehicleDistanceSum += c.distanceUnitsTo(action.getCity());
        c = action.getCity();
      }
      double vehicleCost = Measures.unitsToKM(vehicleDistanceSum * v.costPerKm());
      totalCost += vehicleCost;
    }

    return totalCost;
  }
예제 #2
0
파일: A.java 프로젝트: VlSomers/ProjectsIA
  public Plan getPlanForMyVehicle(int index) {
    MyVehicle v = domainVal.vehicles.get(index);
    City currentCity = v.homeCity();
    Plan plan = new Plan(currentCity);

    for (Action a : vehicleActions.get(v)) {
      City destination = a.getCity();

      for (City c : currentCity.pathTo(destination)) {
        plan.appendMove(c);
      }

      if (a.type == Type.PICKUP) plan.appendPickup(a.task);
      else plan.appendDelivery(a.task);

      currentCity = destination;
    }

    return plan;
  }