Search in sources :

Example 1 with Cluster

use of ecgberht.Clustering.Cluster in project Ecgberht by Jabbo16.

the class SimulationTheory method createSimInfos.

/**
 * Using the clusters creates different SimInfos based on distance between them
 */
private void createSimInfos() {
    for (Cluster friend : friendly) {
        if (friend.units.isEmpty())
            continue;
        SimInfo aux = new SimInfo(friend);
        for (Cluster enemy : enemies) {
            if (enemy.units.isEmpty())
                continue;
            if (closeClusters(friend, enemy))
                aux.enemies.addAll(enemy.units);
        }
        aux.allies.addAll(friend.units);
        simulations.add(aux);
    }
    List<SimInfo> newSims = new ArrayList<>();
    for (SimInfo s : simulations) {
        SimInfo air = new SimInfo();
        SimInfo ground = new SimInfo();
        for (UnitInfo u : s.allies) {
            if (u.flying)
                air.allies.add(u);
            else
                ground.allies.add(u);
        }
        boolean emptyAir = air.allies.isEmpty();
        boolean emptyGround = ground.allies.isEmpty();
        if (emptyAir && emptyGround)
            continue;
        for (UnitInfo u : s.enemies) {
            if (u.unit instanceof AirAttacker || u.unitType == UnitType.Terran_Bunker)
                air.enemies.add(u);
            if (u.unit instanceof GroundAttacker || u.unitType == UnitType.Terran_Bunker || u.unitType == UnitType.Zerg_Creep_Colony)
                ground.enemies.add(u);
        }
        air.type = SimInfo.SimType.AIR;
        newSims.add(air);
        ground.type = SimInfo.SimType.GROUND;
        newSims.add(ground);
    }
    if (!newSims.isEmpty())
        simulations.addAll(newSims);
}
Also used : UnitInfo(ecgberht.UnitInfo) ArrayList(java.util.ArrayList) Cluster(ecgberht.Clustering.Cluster)

Example 2 with Cluster

use of ecgberht.Clustering.Cluster in project Ecgberht by Jabbo16.

the class SquadManager method createSquads.

public void createSquads(List<Cluster> friendly) {
    squads.clear();
    int counter = 0;
    for (Cluster c : friendly) {
        Squad s = new Squad(counter, new Position((int) c.modeX, (int) c.modeY), getGs().sim.getSimulation(c));
        squads.put(counter, s);
        counter++;
    }
}
Also used : Position(org.openbw.bwapi4j.Position) Cluster(ecgberht.Clustering.Cluster)

Example 3 with Cluster

use of ecgberht.Clustering.Cluster in project Ecgberht by Jabbo16.

the class SimulationTheory method drawClusters.

/**
 * Draws the clusters created on the screen
 */
public void drawClusters() {
    int cluster = 0;
    for (Cluster c : friendly) {
        drawCluster(c, true, cluster);
        cluster++;
    }
    cluster = 0;
    for (Cluster c : enemies) {
        drawCluster(c, false, cluster);
        cluster++;
    }
}
Also used : Cluster(ecgberht.Clustering.Cluster)

Aggregations

Cluster (ecgberht.Clustering.Cluster)3 UnitInfo (ecgberht.UnitInfo)1 ArrayList (java.util.ArrayList)1 Position (org.openbw.bwapi4j.Position)1