Search in sources :

Example 6 with MutablePair

use of ecgberht.Util.MutablePair in project Ecgberht by Jabbo16.

the class SendDefenders method execute.

@Override
public State execute() {
    try {
        boolean air_only = true;
        boolean cannon_rush = false;
        for (Unit u : gameState.enemyInBase) {
            if (u.isFlying() || ((PlayerUnit) u).isCloaked())
                continue;
            if (!cannon_rush && (u instanceof Pylon || u instanceof PhotonCannon))
                cannon_rush = true;
            air_only = false;
        }
        Set<UnitInfo> friends = new TreeSet<>();
        for (Squad s : gameState.sqManager.squads.values()) friends.addAll(s.members);
        boolean bunker = false;
        if (!gameState.DBs.isEmpty()) {
            for (Bunker b : gameState.DBs.keySet()) {
                friends.add(gameState.unitStorage.getAllyUnits().get(b));
            }
            bunker = true;
        }
        int defenders = 6;
        if (gameState.enemyInBase.size() == 1 && gameState.enemyInBase.iterator().next() instanceof Worker) {
            defenders = 1;
        }
        MutablePair<Boolean, Boolean> battleWin = new MutablePair<>(true, false);
        if (defenders != 1 && IntelligenceAgency.enemyIsRushing()) {
            if (gameState.enemyInBase.size() + friends.size() < 40) {
                battleWin = gameState.sim.simulateDefenseBattle(friends, gameState.enemyInBase, 150, bunker);
            }
        // if (gameState.enemyInBase.size() >= 3 * friends.size()) battleWin.first = false;
        }
        if (cannon_rush)
            battleWin.first = false;
        int frame = gameState.frameCount;
        int notFound = 0;
        if (!air_only && ((!battleWin.first || battleWin.second) || defenders == 1)) {
            while (gameState.workerDefenders.size() + notFound < defenders && !gameState.workerIdle.isEmpty()) {
                Worker closestWorker = null;
                Position chosen = gameState.attackPosition;
                for (Worker u : gameState.workerIdle) {
                    if (u.getLastCommandFrame() == frame)
                        continue;
                    if ((closestWorker == null || u.getDistance(chosen) < closestWorker.getDistance(chosen))) {
                        closestWorker = u;
                    }
                }
                if (closestWorker != null) {
                    gameState.workerDefenders.put(closestWorker, null);
                    gameState.workerIdle.remove(closestWorker);
                } else
                    notFound++;
            }
            notFound = 0;
            while (gameState.workerDefenders.size() + notFound < defenders && !gameState.workerMining.isEmpty()) {
                Worker closestWorker = null;
                Position chosen = gameState.attackPosition;
                for (Entry<Worker, MineralPatch> u : gameState.workerMining.entrySet()) {
                    if (u.getKey().getLastCommandFrame() == frame)
                        continue;
                    if ((closestWorker == null || u.getKey().getDistance(chosen) < closestWorker.getDistance(chosen))) {
                        closestWorker = u.getKey();
                    }
                }
                if (closestWorker != null) {
                    if (gameState.workerMining.containsKey(closestWorker)) {
                        MineralPatch mineral = gameState.workerMining.get(closestWorker);
                        gameState.workerDefenders.put(closestWorker, null);
                        if (gameState.mineralsAssigned.containsKey(mineral)) {
                            gameState.mining--;
                            gameState.mineralsAssigned.put(mineral, gameState.mineralsAssigned.get(mineral) - 1);
                        }
                        gameState.workerMining.remove(closestWorker);
                    }
                } else
                    notFound++;
            }
            for (Entry<Worker, Position> u : gameState.workerDefenders.entrySet()) {
                if (frame == u.getKey().getLastCommandFrame())
                    continue;
                if (gameState.attackPosition != null) {
                    gameState.workerDefenders.put(u.getKey(), gameState.attackPosition);
                    if (gameState.enemyInBase.size() == 1 && gameState.enemyInBase.iterator().next() instanceof Worker) {
                        Unit scouter = gameState.enemyInBase.iterator().next();
                        Unit lastTarget = u.getKey().getOrderTarget();
                        if (lastTarget != null && lastTarget.equals(scouter))
                            continue;
                        u.getKey().attack(scouter);
                    } else {
                        Position closestDefense = null;
                        if (gameState.learningManager.isNaughty()) {
                            if (!gameState.DBs.isEmpty())
                                closestDefense = gameState.DBs.keySet().iterator().next().getPosition();
                            if (closestDefense == null)
                                closestDefense = gameState.getNearestCC(u.getKey().getPosition(), false);
                            if (closestDefense != null && u.getKey().getDistance(closestDefense) > UnitType.Terran_Marine.groundWeapon().maxRange() * 0.95) {
                                u.getKey().move(closestDefense);
                                continue;
                            }
                        }
                        Unit toAttack = gameState.getUnitToAttack(u.getKey(), gameState.enemyInBase);
                        if (toAttack != null) {
                            Unit lastTarget = u.getKey().getOrderTarget();
                            if (lastTarget != null && lastTarget.equals(toAttack))
                                continue;
                            u.getKey().attack(toAttack);
                        } else {
                            Position lastTargetPosition = u.getKey().getOrderTargetPosition();
                            if (lastTargetPosition != null && lastTargetPosition.equals(gameState.attackPosition))
                                continue;
                            u.getKey().attack(gameState.attackPosition);
                        }
                    }
                }
            }
        } else if (!gameState.getStrat().name.equals("ProxyBBS") && !gameState.getStrat().name.equals("ProxyEightRax")) {
            for (Entry<Integer, Squad> u : gameState.sqManager.squads.entrySet()) {
                if (gameState.attackPosition != null) {
                    u.getValue().giveAttackOrder(gameState.attackPosition);
                    u.getValue().status = Status.DEFENSE;
                } else {
                    u.getValue().status = Status.IDLE;
                    u.getValue().attack = null;
                }
            }
        }
        gameState.attackPosition = null;
        return State.FAILURE;
    } catch (Exception e) {
        System.err.println(this.getClass().getSimpleName());
        e.printStackTrace();
        return State.ERROR;
    }
}
Also used : Position(org.openbw.bwapi4j.Position) UnitInfo(ecgberht.UnitInfo) MutablePair(ecgberht.Util.MutablePair) Entry(java.util.Map.Entry) TreeSet(java.util.TreeSet) Squad(ecgberht.Squad)

Example 7 with MutablePair

use of ecgberht.Util.MutablePair in project Ecgberht by Jabbo16.

the class ChoosePosition method execute.

@Override
public State execute() {
    try {
        if (gameState.chosenToBuild == UnitType.None)
            return State.FAILURE;
        Player self = gameState.getPlayer();
        TilePosition origin;
        if (gameState.chosenToBuild.isRefinery()) {
            if (!gameState.vespeneGeysers.isEmpty()) {
                for (Entry<VespeneGeyser, Boolean> g : gameState.vespeneGeysers.entrySet()) {
                    if (!g.getValue()) {
                        gameState.chosenPosition = g.getKey().getTilePosition();
                        return State.SUCCESS;
                    }
                }
            }
        } else if (gameState.chosenToBuild == UnitType.Terran_Command_Center) {
            if (!gameState.islandBases.isEmpty() && gameState.islandCCs.size() < gameState.islandBases.size()) {
                if (gameState.islandExpand)
                    return State.FAILURE;
                for (Agent u : gameState.agents.values()) {
                    if (u instanceof DropShipAgent && u.statusToString().equals("IDLE")) {
                        gameState.islandExpand = true;
                        return State.FAILURE;
                    }
                }
            }
            TilePosition main;
            if (gameState.mainCC != null)
                main = gameState.mainCC.second.getTilePosition();
            else
                main = gameState.getPlayer().getStartLocation();
            List<Base> valid = new ArrayList<>();
            if (gameState.getStrat().name.equals("PlasmaWraithHell")) {
                for (Base b : gameState.specialBLs) {
                    if (!gameState.CCs.containsKey(b)) {
                        gameState.chosenPosition = b.getLocation();
                        return State.SUCCESS;
                    }
                }
            }
            for (Base b : gameState.BLs) {
                if (!gameState.CCs.containsKey(b) && Util.isConnected(b.getLocation(), main))
                    valid.add(b);
            }
            List<Base> remove = new ArrayList<>();
            for (Base b : valid) {
                if (gameState.getGame().getBWMap().isVisible(b.getLocation()) && !gameState.getGame().getBWMap().isBuildable(b.getLocation(), true)) {
                    remove.add(b);
                    continue;
                }
                if (b.getArea() != gameState.naturalArea) {
                    for (Unit u : gameState.enemyCombatUnitMemory) {
                        if (gameState.bwem.getMap().getArea(u.getTilePosition()) == null || !(u instanceof Attacker) || u instanceof Worker) {
                            continue;
                        }
                        if (gameState.bwem.getMap().getArea(u.getTilePosition()).equals(b.getArea())) {
                            remove.add(b);
                            break;
                        }
                    }
                    for (UnitInfo u : gameState.unitStorage.getEnemyUnits().values().stream().filter(u -> u.unitType.isBuilding()).collect(Collectors.toSet())) {
                        if (gameState.bwem.getMap().getArea(u.tileposition) == null)
                            continue;
                        if (gameState.bwem.getMap().getArea(u.tileposition).equals(b.getArea())) {
                            remove.add(b);
                            break;
                        }
                    }
                }
            }
            valid.removeAll(remove);
            if (valid.isEmpty())
                return State.FAILURE;
            gameState.chosenPosition = valid.get(0).getLocation();
            return State.SUCCESS;
        } else {
            if (!gameState.workerBuild.isEmpty()) {
                for (MutablePair<UnitType, TilePosition> w : gameState.workerBuild.values()) {
                    gameState.testMap.updateMap(w.second, w.first, false);
                }
            }
            if (!gameState.chosenToBuild.equals(UnitType.Terran_Bunker) && !gameState.chosenToBuild.equals(UnitType.Terran_Missile_Turret)) {
                if (gameState.getStrat().proxy && gameState.chosenToBuild == UnitType.Terran_Barracks) {
                    origin = gameState.mapCenter.toTilePosition();
                } else if (gameState.mainCC != null && gameState.mainCC.first != null) {
                    origin = gameState.mainCC.first.getLocation();
                } else
                    origin = self.getStartLocation();
            } else if (gameState.chosenToBuild.equals(UnitType.Terran_Missile_Turret)) {
                if (gameState.defendPosition != null)
                    origin = gameState.defendPosition.toTilePosition();
                else if (gameState.DBs.isEmpty()) {
                    origin = Util.getClosestChokepoint(self.getStartLocation().toPosition()).getCenter().toTilePosition();
                } else {
                    origin = gameState.DBs.keySet().stream().findFirst().map(UnitImpl::getTilePosition).orElse(null);
                }
            } else if (gameState.learningManager.isNaughty() && gameState.enemyRace == Race.Zerg) {
                origin = gameState.getBunkerPositionAntiPool();
                if (origin != null) {
                    gameState.testMap = gameState.map.clone();
                    gameState.chosenPosition = origin;
                    return State.SUCCESS;
                } else {
                    origin = gameState.testMap.findBunkerPositionAntiPool();
                    if (origin != null) {
                        gameState.testMap = gameState.map.clone();
                        gameState.chosenPosition = origin;
                        return State.SUCCESS;
                    } else if (gameState.mainCC != null)
                        origin = gameState.mainCC.second.getTilePosition();
                    else
                        origin = gameState.getPlayer().getStartLocation();
                }
            } else if (gameState.Ts.isEmpty()) {
                if (gameState.defendPosition != null && gameState.naturalChoke != null && gameState.defendPosition.equals(gameState.naturalChoke.getCenter().toPosition())) {
                    origin = gameState.testMap.findBunkerPosition(gameState.naturalChoke);
                    if (origin != null) {
                        gameState.testMap = gameState.map.clone();
                        gameState.chosenPosition = origin;
                        return State.SUCCESS;
                    }
                }
                if (gameState.mainChoke != null && !gameState.getStrat().name.equals("MechGreedyFE") && !gameState.getStrat().name.equals("BioGreedyFE") && !gameState.getStrat().name.equals("14CC") && !gameState.getStrat().name.equals("BioMechGreedyFE")) {
                    origin = gameState.testMap.findBunkerPosition(gameState.mainChoke);
                    if (origin != null) {
                        gameState.testMap = gameState.map.clone();
                        gameState.chosenPosition = origin;
                        return State.SUCCESS;
                    } else
                        origin = gameState.mainChoke.getCenter().toTilePosition();
                } else if (gameState.naturalChoke != null) {
                    origin = gameState.testMap.findBunkerPosition(gameState.naturalChoke);
                    if (origin != null) {
                        gameState.testMap = gameState.map.clone();
                        gameState.chosenPosition = origin;
                        return State.SUCCESS;
                    } else
                        origin = gameState.mainChoke.getCenter().toTilePosition();
                } else {
                    origin = gameState.testMap.findBunkerPosition(gameState.mainChoke);
                    if (origin != null) {
                        gameState.testMap = gameState.map.clone();
                        gameState.chosenPosition = origin;
                        return State.SUCCESS;
                    } else
                        origin = gameState.mainChoke.getCenter().toTilePosition();
                }
            } else
                origin = gameState.Ts.stream().findFirst().map(UnitImpl::getTilePosition).orElse(null);
            TilePosition position = gameState.testMap.findPositionNew(gameState.chosenToBuild, origin);
            gameState.testMap = gameState.map.clone();
            if (position != null) {
                gameState.chosenPosition = position;
                return State.SUCCESS;
            }
        }
        return State.FAILURE;
    } catch (Exception e) {
        System.err.println(this.getClass().getSimpleName());
        e.printStackTrace();
        return State.ERROR;
    }
}
Also used : Agent(ecgberht.Agents.Agent) DropShipAgent(ecgberht.Agents.DropShipAgent) Player(org.openbw.bwapi4j.Player) Base(bwem.Base) UnitInfo(ecgberht.UnitInfo) MutablePair(ecgberht.Util.MutablePair) DropShipAgent(ecgberht.Agents.DropShipAgent) TilePosition(org.openbw.bwapi4j.TilePosition) ArrayList(java.util.ArrayList) List(java.util.List)

Example 8 with MutablePair

use of ecgberht.Util.MutablePair in project Ecgberht by Jabbo16.

the class CheckMineralWalkGoldRush method execute.

@Override
public State execute() {
    try {
        if (gameState.walkingMinerals.isEmpty())
            return State.SUCCESS;
        for (Map.Entry<SCV, MutablePair<UnitType, TilePosition>> u : gameState.workerBuild.entrySet()) {
            if (u.getValue().first != UnitType.Terran_Command_Center)
                continue;
            SCV scv = u.getKey();
            Unit movingMineral = u.getKey().getTargetUnit();
            if (movingMineral == null) {
                MineralPatch target = getCloserMineral(u);
                if (target == null) {
                    if (scv.getOrderTarget() != null && scv.getOrder() != Order.Move) {
                        scv.move(u.getValue().second.toPosition());
                    }
                    continue;
                }
                if (!target.equals(scv.getTargetUnit()))
                    scv.rightClick(target, false);
            } else if (scv.getDistance(movingMineral) < 32) {
                scv.move(u.getValue().second.toPosition());
            }
        }
        return State.SUCCESS;
    } catch (Exception e) {
        System.err.println(this.getClass().getSimpleName());
        e.printStackTrace();
        return State.ERROR;
    }
}
Also used : MutablePair(ecgberht.Util.MutablePair) MineralPatch(org.openbw.bwapi4j.unit.MineralPatch) SCV(org.openbw.bwapi4j.unit.SCV) Unit(org.openbw.bwapi4j.unit.Unit) Map(java.util.Map)

Example 9 with MutablePair

use of ecgberht.Util.MutablePair in project Ecgberht by Jabbo16.

the class DebugManager method debugScreen.

private void debugScreen(GameState gameState) {
    try {
        if (!ConfigManager.getConfig().ecgConfig.debugScreen)
            return;
        if (gameState.naturalArea != null) {
            print(gameState.naturalArea.getTop().toTilePosition(), Color.RED);
            for (ChokePoint c : gameState.naturalArea.getChokePoints()) {
                if (c.getGeometry().size() > 2)
                    mapDrawer.drawLineMap(c.getGeometry().get(0).toPosition(), c.getGeometry().get(c.getGeometry().size() - 1).toPosition(), Color.GREY);
            }
        }
        for (ChokePoint c : gameState.bwem.getMap().getChokePoints()) {
            if (c.getGeometry().size() > 2)
                mapDrawer.drawLineMap(c.getGeometry().get(0).toPosition(), c.getGeometry().get(c.getGeometry().size() - 1).toPosition(), Color.GREEN);
        }
        /*for(Entry<Base, MutablePair<MineralPatch, MineralPatch>> u : fortressSpecialBLs.entrySet()){
            if(u.getValue().first != null) bw.getMapDrawer().drawLineMap(u.getKey().getLocation().toPosition(), u.getValue().first.getPosition(),Color.RED);
            if(u.getValue().second != null)bw.getMapDrawer().drawLineMap(u.getKey().getLocation().toPosition(), u.getValue().second.getPosition(),Color.ORANGE);
        }*/
        for (MineralPatch m : gameState.walkingMinerals) print(m, Color.RED);
        for (MineralPatch d : gameState.blockingMinerals.values()) print(d, Color.RED);
        int counter = 0;
        for (Base b : gameState.BLs) {
            mapDrawer.drawTextMap(Util.getUnitCenterPosition(b.getLocation().toPosition(), UnitType.Terran_Command_Center), ColorUtil.formatText(Integer.toString(counter), ColorUtil.White));
            for (Mineral m : b.getBlockingMinerals()) print(m.getUnit(), Color.RED);
            counter++;
        }
        for (Building b : gameState.buildingLot) print(b, Color.PURPLE);
        for (Unit u : gameState.enemyInBase) print(u, Color.RED);
        for (Base b : gameState.islandBases) mapDrawer.drawTextMap(b.getLocation().toPosition(), ColorUtil.formatText("Island", ColorUtil.White));
        for (Unit u : gameState.islandCCs.values()) {
            print(u, Color.YELLOW);
        }
        for (Agent ag : gameState.agents.values()) {
            if (ag instanceof VultureAgent) {
                VultureAgent vulture = (VultureAgent) ag;
                mapDrawer.drawTextMap(vulture.myUnit.getPosition(), ColorUtil.formatText(ag.statusToString(), ColorUtil.White));
            } else if (ag instanceof VesselAgent) {
                VesselAgent vessel = (VesselAgent) ag;
                mapDrawer.drawTextMap(vessel.myUnit.getPosition(), ColorUtil.formatText(ag.statusToString(), ColorUtil.White));
                if (vessel.follow != null)
                    mapDrawer.drawLineMap(vessel.myUnit.getPosition(), vessel.follow.getSquadCenter(), Color.YELLOW);
            } else if (ag instanceof WraithAgent) {
                WraithAgent wraith = (WraithAgent) ag;
                mapDrawer.drawTextMap(wraith.myUnit.getPosition().add(new Position(-16, UnitType.Terran_Wraith.dimensionUp())), ColorUtil.formatText(wraith.name, ColorUtil.White));
            } else if (ag instanceof DropShipAgent) {
                DropShipAgent dropShip = (DropShipAgent) ag;
                mapDrawer.drawTextMap(dropShip.myUnit.getPosition(), ColorUtil.formatText(ag.statusToString(), ColorUtil.White));
            } else if (ag instanceof WorkerScoutAgent) {
                WorkerScoutAgent worker = (WorkerScoutAgent) ag;
                mapDrawer.drawTextMap(worker.myUnit.getPosition().add(new Position(-16, UnitType.Terran_SCV.dimensionUp())), ColorUtil.formatText(worker.statusToString(), ColorUtil.White));
            }
        }
        if (gameState.enemyStartBase != null)
            mapDrawer.drawTextMap(gameState.enemyStartBase.getLocation().toPosition(), ColorUtil.formatText("EnemyStartBase", ColorUtil.White));
        if (gameState.disrupterBuilding != null)
            mapDrawer.drawTextMap(gameState.disrupterBuilding.getPosition().add(new Position(0, -8)), ColorUtil.formatText("BM!", ColorUtil.White));
        if (gameState.enemyNaturalBase != null)
            mapDrawer.drawTextMap(gameState.enemyNaturalBase.getLocation().toPosition(), ColorUtil.formatText("EnemyNaturalBase", ColorUtil.White));
        if (gameState.mainChoke != null) {
            mapDrawer.drawTextMap(gameState.mainChoke.getCenter().toPosition(), ColorUtil.formatText("MainChoke", ColorUtil.White));
        // bw.getMapDrawer().drawTextMap(mainChoke.getCenter().toPosition(), ColorUtil.formatText(Double.toString(Util.getChokeWidth(mainChoke)), ColorUtil.White));
        }
        if (gameState.naturalChoke != null)
            mapDrawer.drawTextMap(gameState.naturalChoke.getCenter().toPosition(), ColorUtil.formatText("NatChoke", ColorUtil.White));
        if (gameState.chosenHarasser != null) {
            mapDrawer.drawTextMap(gameState.chosenHarasser.getPosition(), ColorUtil.formatText("Harasser", ColorUtil.White));
            print(gameState.chosenHarasser, Color.BLUE);
        }
        for (Map.Entry<SCV, MutablePair<UnitType, TilePosition>> u : gameState.workerBuild.entrySet()) {
            print(u.getKey(), Color.TEAL);
            mapDrawer.drawTextMap(u.getKey().getPosition(), ColorUtil.formatText("Building " + u.getValue().first.toString(), ColorUtil.White));
            print(u.getValue().second, u.getValue().first, Color.TEAL);
            mapDrawer.drawLineMap(u.getKey().getPosition(), Util.getUnitCenterPosition(u.getValue().second.toPosition(), u.getValue().first), Color.RED);
        }
        if (gameState.chosenUnitToHarass != null) {
            print(gameState.chosenUnitToHarass, Color.RED);
            mapDrawer.drawTextMap(gameState.chosenUnitToHarass.getPosition(), ColorUtil.formatText("UnitToHarass", ColorUtil.White));
        }
        for (Map.Entry<SCV, Mechanical> r : gameState.repairerTask.entrySet()) {
            print(r.getKey(), Color.YELLOW);
            mapDrawer.drawTextMap(r.getKey().getPosition(), ColorUtil.formatText("Repairer", ColorUtil.White));
            if (r.getValue() == null || !r.getValue().exists())
                continue;
            print(r.getValue(), Color.YELLOW);
            mapDrawer.drawLineMap(r.getKey().getPosition(), r.getValue().getPosition(), Color.YELLOW);
        }
        for (UnitInfo ui : gameState.unitStorage.getEnemyUnits().values()) {
            mapDrawer.drawTextMap(ui.lastPosition.add(new Position(0, 16)), ColorUtil.formatText(ui.unitType.toString(), ColorUtil.White));
            print(ui.unit, Color.RED);
        }
        /*for (UnitInfo ui : gameState.myArmy) {
                mapDrawer.drawTextMap(ui.position.add(new Position(0, 16)), ColorUtil.formatText(ui.unitType.toString(), ColorUtil.White));
                print(ui.unit, Color.BLUE);
            }*/
        if (gameState.chosenScout != null) {
            mapDrawer.drawTextMap(gameState.chosenScout.getPosition(), ColorUtil.formatText("Scouter", ColorUtil.White));
            print(gameState.chosenScout, Color.PURPLE);
        }
        if (gameState.chosenRepairer != null)
            mapDrawer.drawTextMap(gameState.chosenRepairer.getPosition(), ColorUtil.formatText("ChosenRepairer", ColorUtil.White));
        for (ChokePoint c : gameState.bwem.getMap().getChokePoints()) {
            List<WalkPosition> sides = c.getGeometry();
            if (sides.size() == 3) {
                mapDrawer.drawLineMap(sides.get(1).toPosition(), sides.get(2).toPosition(), Color.GREEN);
            }
        }
        for (Unit u : gameState.CCs.values()) {
            print(u, Color.YELLOW);
            mapDrawer.drawCircleMap(u.getPosition(), 500, Color.ORANGE);
        }
        for (Unit u : gameState.DBs.keySet()) {
            mapDrawer.drawCircleMap(u.getPosition(), 300, Color.ORANGE);
        }
        for (Unit u : gameState.workerIdle) print(u, Color.ORANGE);
        for (Map.Entry<SCV, Building> u : gameState.workerTask.entrySet()) {
            print(u.getKey(), Color.TEAL);
            mapDrawer.drawTextMap(u.getKey().getPosition(), ColorUtil.formatText("Tasked: " + u.getValue().getType().toString(), ColorUtil.White));
            print(u.getValue(), Color.TEAL);
            mapDrawer.drawLineMap(u.getKey().getPosition(), u.getValue().getPosition(), Color.RED);
        }
        for (Worker u : gameState.workerDefenders.keySet()) {
            print(u, Color.PURPLE);
            mapDrawer.drawTextMap(u.getPosition(), ColorUtil.formatText("SpartanSCV", ColorUtil.White));
        }
        for (Map.Entry<Worker, MineralPatch> u : gameState.workerMining.entrySet()) {
            print(u.getKey(), Color.CYAN);
            mapDrawer.drawLineMap(u.getKey().getPosition(), u.getValue().getPosition(), Color.CYAN);
        }
        for (Map.Entry<Worker, GasMiningFacility> u : gameState.workerGas.entrySet()) {
            if (u.getKey().getOrder() == Order.HarvestGas)
                continue;
            print(u.getKey(), Color.GREEN);
            mapDrawer.drawLineMap(u.getKey().getPosition(), u.getValue().getPosition(), Color.GREEN);
        }
        for (Map.Entry<VespeneGeyser, Boolean> u : gameState.vespeneGeysers.entrySet()) {
            print(u.getKey(), Color.GREEN);
            if (gameState.refineriesAssigned.containsKey(u.getKey())) {
                int gas = gameState.refineriesAssigned.get(u.getKey());
                mapDrawer.drawTextMap(u.getKey().getPosition(), ColorUtil.formatText(Integer.toString(gas), ColorUtil.White));
            }
        }
        gameState.sim.drawClusters();
        for (Squad s : gameState.sqManager.squads.values()) {
            if (s.status == Squad.Status.ATTACK && s.attack != null)
                mapDrawer.drawLineMap(s.getSquadCenter(), s.attack, Color.ORANGE);
        }
        for (Squad s : gameState.sqManager.squads.values()) {
            if (s.members.isEmpty())
                continue;
            Position center = s.getSquadCenter();
            // mapDrawer.drawCircleMap(center, 90, Color.GREEN);
            mapDrawer.drawTextMap(center.add(new Position(0, UnitType.Terran_Marine.dimensionUp())), ColorUtil.formatText(s.status.toString(), ColorUtil.White));
            mapDrawer.drawTextMap(center.add(new Position(0, UnitType.Terran_Marine.dimensionUp() * 2)), ColorUtil.formatText(s.lose ? "Lose" : "Win", ColorUtil.White));
        }
        for (Map.Entry<MineralPatch, Integer> m : gameState.mineralsAssigned.entrySet()) {
            print(m.getKey(), Color.CYAN);
            if (m.getValue() == 0)
                continue;
            mapDrawer.drawTextMap(m.getKey().getPosition(), ColorUtil.formatText(m.getValue().toString(), ColorUtil.White));
        }
    } catch (Exception e) {
        System.err.println("debugScreen Exception");
        e.printStackTrace();
    }
}
Also used : MutablePair(ecgberht.Util.MutablePair) ChokePoint(bwem.ChokePoint) Mineral(bwem.Mineral) ChokePoint(bwem.ChokePoint) Base(bwem.Base) Map(java.util.Map)

Aggregations

MutablePair (ecgberht.Util.MutablePair)9 Base (bwem.Base)4 UnitInfo (ecgberht.UnitInfo)4 ArrayList (java.util.ArrayList)3 Position (org.openbw.bwapi4j.Position)3 TilePosition (org.openbw.bwapi4j.TilePosition)3 SCV (org.openbw.bwapi4j.unit.SCV)3 DropShipAgent (ecgberht.Agents.DropShipAgent)2 List (java.util.List)2 Map (java.util.Map)2 TreeSet (java.util.TreeSet)2 Agent (org.bk.ass.sim.Agent)2 MineralPatch (org.openbw.bwapi4j.unit.MineralPatch)2 Area (bwem.Area)1 ChokePoint (bwem.ChokePoint)1 Mineral (bwem.Mineral)1 Agent (ecgberht.Agents.Agent)1 VesselAgent (ecgberht.Agents.VesselAgent)1 VultureAgent (ecgberht.Agents.VultureAgent)1 WraithAgent (ecgberht.Agents.WraithAgent)1