Example #1
1
int MeleeAgent::getIdealNumberOfAttackers(Unit u) {
    if (u->getType().isBuilding()) {
        return 400;
    }

    if (u->getType().isWorker()) {
        return 2;
    }

    if (u->getType().size() == UnitSizeTypes::Small) {
        return 3;
    }

    if (u->getType().size() == UnitSizeTypes::Medium) {
        return 4;
    }

    if (u->getType().size() == UnitSizeTypes::Large) {
        return 6;
    }

    return 8;
}
Example #2
1
double MeleeAgent::tacticalThreat(Unit u) {
    const UnitType t = u->getType();


    if (t.getID() == UnitTypes::Terran_Medic.getID()) return Blackboard::Instance().getDouble("ThreatMedic");
    if (t.getID() == UnitTypes::Terran_SCV.getID() && u->isRepairing()) return Blackboard::Instance().getDouble("ThreatRepairingSCV");
    if (t.isWorker()) return Blackboard::Instance().getDouble("ThreatWorker");
    if (t.isDetector()) return Blackboard::Instance().getDouble("ThreatDetector");
    if (t.getID() == UnitTypes::Protoss_Carrier.getID() || u->canLoad()) return Blackboard::Instance().getDouble("ThreatCarrier");
    if (t.getID() == UnitTypes::Protoss_Pylon.getID()) return Blackboard::Instance().getDouble("ThreatPylon");
    if (t.getID() == UnitTypes::Zerg_Queen.getID()) return Blackboard::Instance().getDouble("ThreatQueen");
    if (t.isResourceDepot()) return Blackboard::Instance().getDouble("ThreatDepot");
    if (t.canProduce() && t.isBuilding() && u->isPowered()) return Blackboard::Instance().getDouble("ThreatProductionBuilding");
    if (t == UnitTypes::Zerg_Spawning_Pool) return Blackboard::Instance().getDouble("ThreatProductionBuilding");

    return 1;
}
Example #3
1
double MeleeAgent::calcDPS(Unit attacker, Unit defender) {
    double dps;

    if (attacker->getType() == UnitTypes::Terran_Bunker) {
        // Let's just assume there are 4 Marines inside
        dps = Broodwar->getDamageFrom(UnitTypes::Terran_Marine, defender->getType(), attacker->getPlayer(), defender->getPlayer()) * 4;
        return dps * WeaponTypes::Gauss_Rifle.damageFactor() * 24 / WeaponTypes::Gauss_Rifle.damageCooldown();
    }

    if (!attacker->getType().canAttack()) {
        return 0;
    }

    // TODO: Air weapons
    dps = Broodwar->getDamageFrom(attacker->getType(), defender->getType(), attacker->getPlayer(), defender->getPlayer());
    return dps * attacker->getType().groundWeapon().damageFactor() * 24 / attacker->getType().groundWeapon().damageCooldown();
}
Example #4
1
double MeleeAgent::calcAggro(Unit attacker, Unit defender) {
    if (!defender->getType().canAttack() && defender->getType() != UnitTypes::Terran_Bunker) {
        return 0;
    }
    return calcDPS(defender, attacker) / ((double)(defender->getHitPoints() + defender->getShields()) / calcDPS(attacker, defender));
}