Skip to content

Commit

Permalink
-- 23.4 - faciliti priorities
Browse files Browse the repository at this point in the history
  • Loading branch information
dmitry committed Dec 14, 2017
1 parent c884e3e commit 7c237f4
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 15 deletions.
Binary file added 23.3.jar
Binary file not shown.
Binary file added 23.4.jar
Binary file not shown.
57 changes: 42 additions & 15 deletions core/src/MyStrategy.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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()) {
Expand Down Expand Up @@ -850,11 +851,15 @@ private void addToArrayNotOurFacilities(PlainArray plainArray, double range, flo

Map<Long, Map<FacilityType, Map<Point2D, Integer>>> 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);
Expand All @@ -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;
}
Expand All @@ -897,6 +909,21 @@ private void addToArrayNotOurFacilities(PlainArray plainArray, double range, flo
}
}

private FacilityWrapper getClosestFacility(Stream<FacilityWrapper> 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;
Expand Down Expand Up @@ -1167,7 +1194,7 @@ private boolean initialScale(VehicleGroupInfo myGroup) {
});

delayedMoves.add(move1 -> {
//pass
//pass
});

delayedMoves.add(move1 -> {
Expand Down

0 comments on commit 7c237f4

Please sign in to comment.