Search in sources :

Example 1 with MeanShift

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

the class SimulationTheory method createClusters.

/**
 * Using allied and enemy units create the clusters with them
 */
private void createClusters() {
    // Friendly Clusters
    List<UnitInfo> myUnits = new ArrayList<>();
    for (UnitInfo u : getGs().myArmy) {
        if (isArmyUnit(u.unit))
            myUnits.add(u);
    }
    // Bunkers
    getGs().DBs.keySet().stream().map(b -> getGs().unitStorage.getAllyUnits().get(b)).forEach(myUnits::add);
    // Agents
    getGs().agents.values().stream().map(g -> g.unitInfo).forEach(myUnits::add);
    MeanShift clustering = new MeanShift(myUnits, radius);
    friendly = clustering.run(iterations);
    // Enemy Clusters
    List<UnitInfo> enemyUnits = new ArrayList<>();
    for (UnitInfo u : getGs().unitStorage.getEnemyUnits().values()) {
        if (getGs().getStrat().proxy && u.unitType.isWorker() && (Util.isInOurBases(u) && !u.unit.isAttacking()))
            continue;
        if (u.unitType == UnitType.Zerg_Larva || (u.unitType == UnitType.Zerg_Egg && !u.player.isNeutral()))
            continue;
        if (Util.isStaticDefense(u.unitType) || u.burrowed || u.unitType == UnitType.Terran_Siege_Tank_Siege_Mode || getGs().frameCount - u.lastVisibleFrame <= 24 * 4)
            enemyUnits.add(u);
    }
    clustering = new MeanShift(enemyUnits, radius);
    enemies = clustering.run(iterations);
}
Also used : MeanShift(ecgberht.Clustering.MeanShift) Cluster(ecgberht.Clustering.Cluster) Util(ecgberht.Util.Util) UnitInfo(ecgberht.UnitInfo) Simulator(org.bk.ass.sim.Simulator) BW(org.openbw.bwapi4j.BW) ToIntFunction(java.util.function.ToIntFunction) Agent(org.bk.ass.sim.Agent) Set(java.util.Set) BWAPI4JAgentFactory(org.bk.ass.sim.BWAPI4JAgentFactory) IntelligenceAgency(ecgberht.IntelligenceAgency) Collectors(java.util.stream.Collectors) ConfigManager(ecgberht.ConfigManager) ArrayList(java.util.ArrayList) List(java.util.List) Ecgberht.getGs(ecgberht.Ecgberht.getGs) org.openbw.bwapi4j.unit(org.openbw.bwapi4j.unit) MutablePair(ecgberht.Util.MutablePair) org.openbw.bwapi4j.type(org.openbw.bwapi4j.type) Evaluator(org.bk.ass.sim.Evaluator) Position(org.openbw.bwapi4j.Position) UnitInfo(ecgberht.UnitInfo) ArrayList(java.util.ArrayList) MeanShift(ecgberht.Clustering.MeanShift)

Aggregations

Cluster (ecgberht.Clustering.Cluster)1 MeanShift (ecgberht.Clustering.MeanShift)1 ConfigManager (ecgberht.ConfigManager)1 Ecgberht.getGs (ecgberht.Ecgberht.getGs)1 IntelligenceAgency (ecgberht.IntelligenceAgency)1 UnitInfo (ecgberht.UnitInfo)1 MutablePair (ecgberht.Util.MutablePair)1 Util (ecgberht.Util.Util)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 Set (java.util.Set)1 ToIntFunction (java.util.function.ToIntFunction)1 Collectors (java.util.stream.Collectors)1 Agent (org.bk.ass.sim.Agent)1 BWAPI4JAgentFactory (org.bk.ass.sim.BWAPI4JAgentFactory)1 Evaluator (org.bk.ass.sim.Evaluator)1 Simulator (org.bk.ass.sim.Simulator)1 BW (org.openbw.bwapi4j.BW)1 Position (org.openbw.bwapi4j.Position)1 org.openbw.bwapi4j.type (org.openbw.bwapi4j.type)1