Skip to content

Commit

Permalink
- impl scale but disabled
Browse files Browse the repository at this point in the history
  • Loading branch information
dmitry committed Dec 17, 2017
1 parent 9ec70c1 commit 6306b33
Show file tree
Hide file tree
Showing 5 changed files with 77 additions and 6 deletions.
Binary file added 32.2.jar
Binary file not shown.
71 changes: 70 additions & 1 deletion core/src/MyStrategy.java
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ public final class MyStrategy implements Strategy {
public static final int MAX_SWITCH_COUNT = 400;
public static final boolean ARRV_SPLIT_ENABLE = false;
public static final boolean AERIL_INITIAL_ROTATE = false;
private static final boolean SCALE_UP_ON_NUCLEAR = false;
private static int constantId;

private MyStrategyPainter painter = new EmptyPaintner();
Expand Down Expand Up @@ -171,6 +172,8 @@ private void potentialMove() {

if (initialScale(myGroup)) continue;

if (scaleOperations(myGroup)) continue;

if (myGroup.goToFacility != null && myGroup.getAveragePoint().getDistanceTo(myGroup.getGoToFacilityPoint()) < 14) {
if (!myGroup.goToFacility.isMy() || myGroup.goToFacility.f.getCapturePoints() != game.getMaxFacilityCapturePoints()) {
log(Utils.LOG_MOVING + " skip move because of capturing " + myGroup);
Expand All @@ -185,6 +188,72 @@ private void potentialMove() {
}
}

private boolean scaleOperations(VehicleGroupInfo myGroup) {
if (!SCALE_UP_ON_NUCLEAR) {
return false;
}
if (opponent.getRemainingNuclearStrikeCooldownTicks() > 50) {
if (myGroup.isScaledNuclear) {
myGroup.isScaledNuclear = false;
scheduleSelectAll(myGroup);
delayedMoves.add(move1 -> {
move1.setAction(ActionType.SCALE);
move1.setX(myGroup.getAveragePoint().getX());
move1.setY(myGroup.getAveragePoint().getY());
move1.setFactor(0.1);
});
return true;
}
} else if (myGroup.count > 55) {
if (!myGroup.isScaledNuclear) {
Point2D myAp = myGroup.getCellAveragePoint();


Map<VehicleType, Map<Point2D, Integer>> unitsCount = getUnitsCount(true);
enemyUnitsCount = null;
myUnitsCount = null;
for (Map.Entry<VehicleType, Map<Point2D, Integer>> points : unitsCount.entrySet()) {
VehicleType key = points.getKey();
double visionRange = getVisionRange(key) / cellSize + 3;
for (Point2D point2D : points.getValue().keySet()) {
if (point2D.getDistanceTo(myAp) < visionRange) {
myGroup.isScaledNuclear = true;
scheduleSelectAll(myGroup);
delayedMoves.add(move1 -> {
move1.setAction(ActionType.SCALE);
move1.setX(myGroup.getAveragePoint().getX());
move1.setY(myGroup.getAveragePoint().getY());
move1.setFactor(1.5);
});
return true;
}


}

}
}
}

return false;
}

private double getVisionRange(VehicleType key) {
switch (key) {
case ARRV:
return game.getArrvVisionRange();
case FIGHTER:
return game.getFighterVisionRange();
case HELICOPTER:
return game.getHelicopterVisionRange();
case IFV:
return game.getIfvVisionRange();
case TANK:
return game.getTankVisionRange();
}
return 100;
}

private boolean trySetProduction() {
Collection<FacilityWrapper> values = um.facilityById.values();
for (FacilityWrapper fw : values) {
Expand Down Expand Up @@ -1154,7 +1223,7 @@ private Map<VehicleType, Map<Point2D, Integer>> getUnitsCount(boolean enemy) {


for (VehicleWrapper vehicle : um.vehicleById.values()) {
if (currentMapGroup.vehicles.contains(vehicle)) {
if (currentMapGroup != null && currentMapGroup.vehicles.contains(vehicle)) {
continue;
}

Expand Down
9 changes: 5 additions & 4 deletions core/src/RewindClientWrapper.java
Original file line number Diff line number Diff line change
Expand Up @@ -147,8 +147,9 @@ public void onEndTick() {
}
}

rc.message(String.format(Locale.US, "\\nMe: %s Opponent: %s\\nActionCooldown: %s\\nNuclearCooldown: %s \\nMyGroups count %s",
mys.me.getScore(), mys.opponent.getScore(), mys.me.getRemainingActionCooldownTicks(), mys.me.getRemainingNuclearStrikeCooldownTicks(), myGroups.size()));
rc.message(String.format(Locale.US, "\\nMe: %s Opponent: %s\\nActionCooldown: %s\\nNuclearCooldown: %s \\nEnemyNuclearCooldown: %s \\nMyGroups count %s",
mys.me.getScore(), mys.opponent.getScore(), mys.me.getRemainingActionCooldownTicks(), mys.me.getRemainingNuclearStrikeCooldownTicks(),
mys.opponent.getRemainingNuclearStrikeCooldownTicks(), myGroups.size()));

ArrayList<Map.Entry<ActionType, Integer>> entries = new ArrayList<>(mys.movesStats.entrySet());
String msg = "\\nMy moves count: " + mys.movesCount + "\\n";
Expand Down Expand Up @@ -212,11 +213,11 @@ private void drawPP(VehicleGroupInfo myGroup) {
}
//mys.log(String.format("%s %s %s - v: %s", myGroup.vehicleType, realX, realY, (int) v));
//System.out.print(String.format("%s %s %s - v: %s", myGroup.vehicleType, realX, realY, (int) v));
// System.out.print((int) v + " ");
// System.out.print((int) v + " ");
rc.rect(realX, realY, realX + cellSize, realY + cellSize, new Color(133, alpha, 255 - alpha, 100), 1);
}
}
// System.out.println();
// System.out.println();
}

// rc.message(String.format("\\n%s\\nMap Draw: min %.2f max %.2f \\ndelta %.2f", myGroup.vehicleType, min, max, delta));
Expand Down
1 change: 1 addition & 0 deletions core/src/VehicleGroupInfo.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ public class VehicleGroupInfo {
public boolean shrinkRotateToRight;
public int noMoveCount;
public int shrinkCount;
public boolean isScaledNuclear;

public VehicleGroupInfo(Ownership ownership, VehicleType vehicleType, MyStrategy myStrategy) {
this.ownership = ownership;
Expand Down
2 changes: 1 addition & 1 deletion lr/local-runner-sync.default.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Отрисовка игры на экран: true или false.
render-to-screen=false
render-to-screen=true

# Синхронизация обсчёта игры и её отрисовки на экран: true или false.
# Не используется, если настройка render-to-screen=false.
Expand Down

0 comments on commit 6306b33

Please sign in to comment.