Skip to content

Commit

Permalink
- 24, rotates, switch facilities targets, priority for Vehicle Factories
Browse files Browse the repository at this point in the history
  • Loading branch information
dmitry committed Dec 14, 2017
1 parent ea58383 commit e8fd62a
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 15 deletions.
Binary file added 24.jar
Binary file not shown.
51 changes: 39 additions & 12 deletions core/src/MyStrategy.java
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public final class MyStrategy implements Strategy {
public static final int CAN_DISABLE_FEAR_SINCE_TICK = 9300;
public static final int CAN_DISABLE_FEAR_SINCE_COUNT = 490;
public static final int MAX_CELL_DISTANCE_OF_MOVE = 11 / 2;
public static final int MAX_SWITCH_COUNT = 3;
public static final int MAX_SWITCH_COUNT = 400;
private static int constantId;

private MyStrategyPainter painter = new EmptyPaintner();
Expand Down Expand Up @@ -228,7 +228,14 @@ private VehicleType getTypeForProductionByLess() {
for (VehicleType vehicleType : VehicleType.values()) {
allyCounts.putIfAbsent(vehicleType, 0L);
}
Map.Entry<VehicleType, Long> min = Collections.min(allyCounts.entrySet(), Comparator.comparingLong(Map.Entry::getValue));
Map.Entry<VehicleType, Long> min = Collections.min(allyCounts.entrySet(), (o1, o2) -> {
int compare = Long.compare(o1.getValue(), o2.getValue());
if (compare != 0) {
return compare;
}

return o2.getKey().compareTo(o1.getKey());
});
if (min.getValue() < FACILITY_SIZE_TO_GO) {
return min.getKey();
}
Expand Down Expand Up @@ -907,18 +914,18 @@ private void addToArrayNotOurFacilities(PlainArray plainArray, double range, flo
}


if (myGroup.goToFacility == null) {
{
Point2D ap = myGroup.getAveragePoint();
FacilityWrapper closestFree = null;

closestFree = getClosestFacility(um.facilityById.values().stream().filter(f -> f.f.getOwnerPlayerId() == -1 && f.f.getType() == VEHICLE_FACTORY), myGroup, ap);

if (closestFree == null) {
closestFree = getClosestFacility(um.facilityById.values().stream().filter(f -> f.isMy() && f.f.getCapturePoints() < game.getMaxFacilityCapturePoints()), myGroup, ap);
closestFree = getClosestFacility(um.facilityById.values().stream().filter(f -> f.f.getOwnerPlayerId() == opponent.getId() && f.f.getType() == VEHICLE_FACTORY), myGroup, ap);
}

if (closestFree == null) {
closestFree = getClosestFacility(um.facilityById.values().stream().filter(f -> f.f.getOwnerPlayerId() == opponent.getId() && f.f.getType() == VEHICLE_FACTORY), myGroup, ap);
closestFree = getClosestFacility(um.facilityById.values().stream().filter(f -> f.isMy() && f.f.getCapturePoints() < game.getMaxFacilityCapturePoints()), myGroup, ap);
}

if (closestFree == null) {
Expand All @@ -929,7 +936,9 @@ private void addToArrayNotOurFacilities(PlainArray plainArray, double range, flo
closestFree = getClosestFacility(um.facilityById.values().stream().filter(f -> f.f.getOwnerPlayerId() == opponent.getId() && f.f.getType() == CONTROL_CENTER), myGroup, ap);
}

myGroup.goToFacility = closestFree;
if (closestFree != null) {
myGroup.goToFacility = closestFree;
}
}


Expand Down Expand Up @@ -1485,6 +1494,11 @@ private void refreshGroups(List<VehicleGroupInfo> groups, boolean findNewGroups)
sizeToGo = 32;
break;
}

if (myGroups.size() > 13) {
sizeToGo *= 1.8;
}

if (gc.vehicles.size() > sizeToGo || !fw.isMy()) {
refreshGroup(gc);
groups.add(0, gc);
Expand Down Expand Up @@ -1630,12 +1644,25 @@ private void actualMoveToPoint(VehicleGroupInfo myGroup, Point2D point, Move mov
shouldScale = world.getTickIndex() - myGroup.lastShrinkForGatherI > 400 && shouldScale;
if (shouldScale) {
myGroup.lastShrinkForGatherI = world.getTickIndex();
// log(Utils.LOG_MOVING + " found " + separatedVehicles.size() + " separated vehicles for " + myGroup);
log(Utils.LOG_MOVING + " try SCALE ");
move.setAction(ActionType.SCALE);
move.setX(myAverage.getX());
move.setY(myAverage.getY());
move.setFactor(0.1);

myGroup.nextShrinkIsScale = !myGroup.nextShrinkIsScale;
if (myGroup.nextShrinkIsScale) {
// log(Utils.LOG_MOVING + " found " + separatedVehicles.size() + " separated vehicles for " + myGroup);
log(Utils.LOG_MOVING + " try SCALE " + myGroup);
move.setAction(ActionType.SCALE);
move.setX(myAverage.getX());
move.setY(myAverage.getY());
move.setFactor(0.1);
} else {
// log(Utils.LOG_MOVING + " found " + separatedVehicles.size() + " separated vehicles for " + myGroup);
log(Utils.LOG_MOVING + " try ROTATE " + myGroup);
move.setAction(ActionType.ROTATE);
move.setX(myAverage.getX());
move.setY(myAverage.getY());
move.setAngle(myGroup.shrinkRotateToRight ? Math.PI : -Math.PI);
myGroup.shrinkRotateToRight = !myGroup.shrinkRotateToRight;
}

} else {
move.setAction(ActionType.MOVE);

Expand Down
3 changes: 2 additions & 1 deletion core/src/Runner.java
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@ public static void main(String[] args) throws IOException {
//runProc(null, true, "java", "-cp", "22.5.jar", "Runner");
//runProc(null, true, "java", "-cp", "23.jar", "Runner");
//runProc(null, true, "java", "-cp", "23.2.jar", "Runner");
runProc(null, true, "java", "-cp", "23.4.jar", "Runner");
//runProc(null, true, "java", "-cp", "23.4.jar", "Runner");
runProc(null, true, "java", "-cp", "23.5.jar", "Runner");
}
}).start();
new Runner(new String[]{"127.0.0.1", hasArgs ? "31001" : "31002", "0000000000000000"}).run();
Expand Down
2 changes: 2 additions & 0 deletions core/src/VehicleGroupInfo.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ public class VehicleGroupInfo {
public int potentialMapCalcAt;
public FacilityWrapper goToFacility;
public int switchCount;
public boolean nextShrinkIsScale;
public boolean shrinkRotateToRight;

public VehicleGroupInfo(Ownership ownership, VehicleType vehicleType, MyStrategy myStrategy) {
this.ownership = ownership;
Expand Down
5 changes: 3 additions & 2 deletions lr/local-runner-sync.default.properties
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,9 @@ fog-of-war-quality=1
# генератора случайных чисел или пустая строка.
# Параметр в командной строке имеет больший приоритет.
#seed=51764284009692
seed=536603617854755
#seed=
#seed=536603617854755
#seed=539675860738317
seed=

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

0 comments on commit e8fd62a

Please sign in to comment.