diff --git a/23.3.jar b/23.3.jar new file mode 100644 index 0000000..3a947fe Binary files /dev/null and b/23.3.jar differ diff --git a/23.4.jar b/23.4.jar new file mode 100644 index 0000000..634555a Binary files /dev/null and b/23.4.jar differ diff --git a/core/src/MyStrategy.java b/core/src/MyStrategy.java index 05990e5..9f168a5 100755 --- a/core/src/MyStrategy.java +++ b/core/src/MyStrategy.java @@ -3,6 +3,7 @@ import java.util.*; import java.util.function.Consumer; import java.util.stream.Collectors; +import java.util.stream.Stream; import static model.FacilityType.CONTROL_CENTER; import static model.FacilityType.VEHICLE_FACTORY; @@ -166,7 +167,7 @@ private void potentialMove() { continue; } - if (initialScale(myGroup)) continue; + if (initialScale(myGroup)) continue; if (myGroup.goToFacility != null && myGroup.getAveragePoint().getDistanceTo(myGroup.goToFacility.getCenterPos()) < 20) { if (!myGroup.goToFacility.isMy() || myGroup.goToFacility.f.getCapturePoints() != game.getMaxFacilityCapturePoints()) { @@ -850,11 +851,15 @@ private void addToArrayNotOurFacilities(PlainArray plainArray, double range, flo Map>> fc = getFacilitiesCount(); - if (group.goToFacility != null && group.goToFacility.isMy()) { + if (group.goToFacility != null && group.goToFacility.isMy() && group.goToFacility.f.getCapturePoints() == game.getMaxFacilityCapturePoints()) { group.goToFacility = null; } - //if (group.isAeral() || !allEnInvisible) { // or check how far is enemy + //if (group.isAeral() || !allEnIn + // + // + // + // visible) { // or check how far is enemy if (group.isAeral()) { // or check how far is enemy addToArray(plainArray, fc.get(opponent.getId()).get(CONTROL_CENTER).entrySet(), range, factor * controlCenterFactor * enemyFactor); @@ -868,18 +873,25 @@ private void addToArrayNotOurFacilities(PlainArray plainArray, double range, flo if (group.goToFacility == null) { Point2D ap = group.getAveragePoint(); - FacilityWrapper closestFree = um.facilityById.values().stream().filter(f -> { + FacilityWrapper closestFree = null; - if (f.isMy()) { - return false; - } - for (VehicleGroupInfo groupInfo : myGroups) { - if (groupInfo != group && groupInfo.goToFacility == f && groupInfo.vehicles.size() > 20) { - return false; - } - } - return true; - }).min(Comparator.comparingDouble(value -> value.getCenterPos().squareDistance(ap))).orElse(null); + closestFree = getClosestFacility(um.facilityById.values().stream().filter(f -> f.f.getOwnerPlayerId() == -1 && f.f.getType() == VEHICLE_FACTORY), group, ap); + + if (closestFree == null) { + closestFree = getClosestFacility(um.facilityById.values().stream().filter(f -> f.isMy() && f.f.getCapturePoints() < game.getMaxFacilityCapturePoints()), group, ap); + } + + if (closestFree == null) { + closestFree = getClosestFacility(um.facilityById.values().stream().filter(f -> f.f.getOwnerPlayerId() == opponent.getId() && f.f.getType() == VEHICLE_FACTORY), group, ap); + } + + if (closestFree == null) { + closestFree = getClosestFacility(um.facilityById.values().stream().filter(f -> f.f.getOwnerPlayerId() == -1 && f.f.getType() == CONTROL_CENTER), group, ap); + } + + if (closestFree == null) { + closestFree = getClosestFacility(um.facilityById.values().stream().filter(f -> f.f.getOwnerPlayerId() == opponent.getId() && f.f.getType() == CONTROL_CENTER), group, ap); + } group.goToFacility = closestFree; } @@ -897,6 +909,21 @@ private void addToArrayNotOurFacilities(PlainArray plainArray, double range, flo } } + private FacilityWrapper getClosestFacility(Stream facilities, VehicleGroupInfo group, Point2D ap) { + return facilities.filter(f -> { + + if (f.isMy()) { + return false; + } + for (VehicleGroupInfo groupInfo : myGroups) { + if (groupInfo != group && groupInfo.goToFacility == f && groupInfo.vehicles.size() > 20) { + return false; + } + } + return true; + }).min(Comparator.comparingDouble(value -> value.getCenterPos().squareDistance(ap))).orElse(null); + } + private boolean shouldHeal(VehicleType ifv) { VehicleGroupInfo ifvGroup = findGroup(myGroups, ifv); return ifvGroup != null && ifvGroup.shouldHeal; @@ -1167,7 +1194,7 @@ private boolean initialScale(VehicleGroupInfo myGroup) { }); delayedMoves.add(move1 -> { - //pass + //pass }); delayedMoves.add(move1 -> {