Skip to content

Commit

Permalink
- fixes for gotofacility
Browse files Browse the repository at this point in the history
  • Loading branch information
dmitry committed Dec 15, 2017
1 parent 4a544a7 commit 0c62ca7
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 37 deletions.
Binary file added 29.jar
Binary file not shown.
81 changes: 45 additions & 36 deletions core/src/MyStrategy.java
Original file line number Diff line number Diff line change
Expand Up @@ -534,7 +534,7 @@ private PlainArray calcMap(VehicleGroupInfo group) { //TODO improve logic at fin
}
}

if (intruders && count > 0.05 * group.count) {
if (intruders && count > 0.05 * group.count && opponent.getRemainingNuclearStrikeCooldownTicks() > 150) {
Set<Map.Entry<Point2D, Integer>> myIfvs = new HashMap<>(getUnitsCount(false).get(IFV)).entrySet();
for (Map.Entry<Point2D, Integer> myIfv : myIfvs) {
myIfv.setValue(Math.max(15 - myIfv.getValue(), 1));
Expand Down Expand Up @@ -783,7 +783,7 @@ private PlainArray calcMap(VehicleGroupInfo group) { //TODO improve logic at fin
HashMap<Point2D, Integer> cornerPushersFiltered = new HashMap<>(cornersPushers);
cornerPushersFiltered.keySet().removeIf(corner -> {
for (Point2D facPoint : allFacCounts.keySet()) {
if (facPoint.squareDistance(corner) < maxDistanceSquare) {
if (facPoint.squareDistance(corner) < 3 * 4 + 2) {
return true;
}
}
Expand Down Expand Up @@ -917,40 +917,7 @@ private void addToArrayNotOurFacilities(PlainArray plainArray, double range, flo
myGroup.goToFacility = null;
}

if (myGroup.goToFacility != null && myGroup.switchCount < MAX_SWITCH_COUNT) {
//try to switch

for (int i = 0; i < 4; i++) {
for (VehicleGroupInfo other : myGroups) {
if (other == myGroup) {
continue;
}
if (other.goToFacility == null) {
continue;
}

if (other.switchCount >= MAX_SWITCH_COUNT) {
continue;
}
FacilityWrapper myF = myGroup.goToFacility;
Point2D myAp = myGroup.getAveragePoint();

Point2D otherAp = other.getAveragePoint();
FacilityWrapper otherF = other.goToFacility;

boolean f1 = otherAp.getDistanceTo(otherF) > otherAp.getDistanceTo(myF);
boolean f2 = myAp.getDistanceTo(myF) > myAp.getDistanceTo(otherAp);

if (f1 && f2) {
log(" SWITCH GO TO FACILITY " + myGroup + " and " + other);
myGroup.goToFacility = otherF;
other.goToFacility = myF;
other.switchCount++;
myGroup.switchCount++;
}
}
}
}
switchGoToFacility(myGroup);

//if (myGroup.isAeral() || !allEnIn
//
Expand Down Expand Up @@ -995,6 +962,8 @@ private void addToArrayNotOurFacilities(PlainArray plainArray, double range, flo
}
}

switchGoToFacility(myGroup);


if (myGroup.goToFacility == null) {
addToArray(plainArray, fc.get(opponent.getId()).get(CONTROL_CENTER).entrySet(), range, factor * controlCenterFactor * enemyFactor);
Expand All @@ -1020,6 +989,46 @@ private void addToArrayNotOurFacilities(PlainArray plainArray, double range, flo
}
}

private void switchGoToFacility(VehicleGroupInfo myGroup) {
if (myGroup.goToFacility != null && myGroup.switchCount < MAX_SWITCH_COUNT) {
//try to switch

for (int i = 0; i < 4; i++) {
for (VehicleGroupInfo other : myGroups) {
if (other == myGroup) {
continue;
}
if (other.goToFacility == null) {
continue;
}

if (other.switchCount >= MAX_SWITCH_COUNT) {
continue;
}
FacilityWrapper myF = myGroup.goToFacility;
Point2D myAp = myGroup.getAveragePoint();

Point2D otherAp = other.getAveragePoint();
FacilityWrapper otherF = other.goToFacility;

boolean f1 = otherAp.getDistanceTo(otherF) > otherAp.getDistanceTo(myF);
boolean f2 = myAp.getDistanceTo(myF) > myAp.getDistanceTo(otherAp);

double currentDistance = myAp.getDistanceTo(myF) + otherAp.getDistanceTo(otherF);
double switchedDistance = myAp.getDistanceTo(otherF) + otherAp.getDistanceTo(myAp);

if (currentDistance > switchedDistance * 1.03) {
log(" SWITCH GO TO FACILITY " + myGroup + " and " + other);
myGroup.goToFacility = otherF;
other.goToFacility = myF;
other.switchCount++;
myGroup.switchCount++;
}
}
}
}
}

private FacilityWrapper getClosestFacility(Stream<FacilityWrapper> facilities, VehicleGroupInfo group, Point2D ap) {
return facilities.filter(f -> {

Expand Down
2 changes: 1 addition & 1 deletion lr/local-runner-sync.default.properties
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ fog-of-war-quality=1
#seed=539675860738317
#seed=541562105365045
#seed=560101143593578
seed=
seed=562820576579634

# Путь к каталогу с плагинами или пустая строка для работы без плагинов.
# Необходимо скомпилировать плагин, чтобы он загрузился игровым симулятором.
Expand Down

0 comments on commit 0c62ca7

Please sign in to comment.