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);
}
Aggregations