|
BWAPI
|
#include <Condition.h>

Definition at line 46 of file Condition.h.
| Condition::Condition | ( | ) | [inline] |
Definition at line 49 of file Condition.h.
Referenced by operator&&(), and operator||().
: mType(ConditionTest::None), mOperatorType(OperatorType::None), mNeededValue(false) {}

| Condition::Condition | ( | ConditionTest | type, |
| bool | expectedValue = true |
||
| ) |
Definition at line 10 of file Condition.cpp.
: mType(type) , mOperatorType(OperatorType::None) , mLCondition() , mRCondition() , mNeededValue(expectedValue) , mExtraInt(0) , mExtraDouble(0) , mUnitType(BWAPI::UnitTypes::None) , mTech(BWAPI::TechTypes::None) , mUpgrade(BWAPI::UpgradeTypes::None) , mString() { }
| Condition::Condition | ( | ConditionTest | type, |
| int | extraValue | ||
| ) |
Definition at line 25 of file Condition.cpp.
: mType(type) , mOperatorType(OperatorType::None) , mLCondition() , mRCondition() , mNeededValue(false) , mExtraInt(extraValue) , mExtraDouble(0) , mUnitType(BWAPI::UnitTypes::None) , mTech(BWAPI::TechTypes::None) , mUpgrade(BWAPI::UpgradeTypes::None) , mString() { }
| Condition::Condition | ( | ConditionTest | type, |
| bool | expectedValue, | ||
| int | extraValue | ||
| ) |
Definition at line 40 of file Condition.cpp.
: mType(type) , mOperatorType(OperatorType::None) , mLCondition() , mRCondition() , mNeededValue(expectedValue) , mExtraInt(extraValue) , mExtraDouble(0) , mUnitType(BWAPI::UnitTypes::None) , mTech(BWAPI::TechTypes::None) , mUpgrade(BWAPI::UpgradeTypes::None) , mString() { }
| Condition::Condition | ( | ConditionTest | type, |
| double | extraValue | ||
| ) |
Definition at line 55 of file Condition.cpp.
: mType(type) , mOperatorType(OperatorType::None) , mLCondition() , mRCondition() , mNeededValue(false) , mExtraInt(0) , mExtraDouble(extraValue) , mUnitType(BWAPI::UnitTypes::None) , mTech(BWAPI::TechTypes::None) , mUpgrade(BWAPI::UpgradeTypes::None) , mString() { }
| Condition::Condition | ( | ConditionTest | type, |
| bool | expectedValue, | ||
| double | extraValue | ||
| ) |
Definition at line 70 of file Condition.cpp.
: mType(type) , mOperatorType(OperatorType::None) , mLCondition() , mRCondition() , mNeededValue(expectedValue) , mExtraInt(0) , mExtraDouble(extraValue) , mUnitType(BWAPI::UnitTypes::None) , mTech(BWAPI::TechTypes::None) , mUpgrade(BWAPI::UpgradeTypes::None) , mString() { }
| Condition::Condition | ( | ConditionTest | type, |
| BWAPI::UnitType | unitType, | ||
| int | count = 1 |
||
| ) |
Definition at line 84 of file Condition.cpp.
: mType(type) , mOperatorType(OperatorType::None) , mLCondition() , mRCondition() , mNeededValue(false) , mExtraInt(count) , mExtraDouble(0) , mUnitType(unitType) , mTech(BWAPI::TechTypes::None) , mUpgrade(BWAPI::UpgradeTypes::None) , mString() { }
| Condition::Condition | ( | ConditionTest | type, |
| BWAPI::TechType | tech | ||
| ) |
Definition at line 99 of file Condition.cpp.
: mType(type) , mOperatorType(OperatorType::None) , mLCondition() , mRCondition() , mNeededValue(false) , mExtraInt(0) , mExtraDouble(0) , mUnitType(BWAPI::UnitTypes::None) , mTech(tech) , mUpgrade(BWAPI::UpgradeTypes::None) , mString() { }
| Condition::Condition | ( | ConditionTest | type, |
| BWAPI::UpgradeType | upgrade, | ||
| int | level = 1 |
||
| ) |
Definition at line 114 of file Condition.cpp.
: mType(type) , mOperatorType(OperatorType::None) , mLCondition() , mRCondition() , mNeededValue(false) , mExtraInt(level) , mExtraDouble(0) , mUnitType(BWAPI::UnitTypes::None) , mTech(BWAPI::TechTypes::None) , mUpgrade(upgrade) , mString() { }
| Condition::Condition | ( | ConditionTest | type, |
| std::string | string | ||
| ) |
Definition at line 129 of file Condition.cpp.
: mType(type) , mOperatorType(OperatorType::None) , mLCondition() , mRCondition() , mNeededValue(false) , mExtraInt(0) , mExtraDouble(0) , mUnitType(BWAPI::UnitTypes::None) , mTech(BWAPI::TechTypes::None) , mUpgrade(BWAPI::UpgradeTypes::None) , mString(string) { }
| Condition::Condition | ( | const Condition & | other | ) | [inline] |
Definition at line 60 of file Condition.h.
: mType(other.mType) , mOperatorType(other.mOperatorType) , mLCondition(other.mLCondition ? new Condition(*other.mLCondition) : NULL) , mRCondition(other.mRCondition ? new Condition(*other.mRCondition) : NULL) , mNeededValue(other.mNeededValue) , mExtraInt(other.mExtraInt) , mExtraDouble(other.mExtraDouble) , mUnitType(other.mUnitType) , mTech(other.mTech) , mUpgrade(other.mUpgrade) , mString(other.mString) { }
| Condition::Condition | ( | const Condition & | left, |
| OperatorType::type | opType, | ||
| const Condition & | right | ||
| ) | [inline, private] |
Definition at line 133 of file Condition.h.
: mType(ConditionTest::None) , mOperatorType(opType) , mLCondition(new Condition(left)) , mRCondition(new Condition(right)) , mNeededValue(false) , mExtraInt(0) , mExtraDouble(0) , mUnitType(BWAPI::UnitTypes::None) , mTech(BWAPI::TechTypes::None) , mUpgrade(BWAPI::UpgradeTypes::None) , mString() {}
| bool Condition::evauluate | ( | ) | const [inline] |
Definition at line 93 of file Condition.h.
References OperatorTypeDef::And, mLCondition, mOperatorType, mRCondition, OperatorTypeDef::None, OperatorTypeDef::Or, and passesValue().
Referenced by UnitToProduce::canBuildFactory(), UnitToProduce::canBuildUnit(), and BuildOrder::isStartBuild().
{
if(mOperatorType == OperatorType::None)
return passesValue();
else if(mOperatorType == OperatorType::And)
return mLCondition->evauluate() && mRCondition->evauluate();
else if(mOperatorType == OperatorType::Or)
return mLCondition->evauluate() || mRCondition->evauluate();
return false;
}


Definition at line 105 of file Condition.h.
References OperatorTypeDef::And, and Condition().
{
return Condition(*this, OperatorType::And, other);
}

Definition at line 75 of file Condition.h.
References mExtraDouble, mExtraInt, mLCondition, mNeededValue, mOperatorType, mRCondition, mString, mTech, mType, mUnitType, and mUpgrade.
{
mType = other.mType;
mOperatorType = other.mOperatorType;
mNeededValue = other.mNeededValue;
mExtraInt = other.mExtraInt;
mExtraDouble = other.mExtraDouble;
mUnitType = other.mUnitType;
mTech = other.mTech;
mUpgrade = other.mUpgrade;
mString = other.mString;
mLCondition.reset(other.mLCondition ? new Condition(*other.mLCondition) : NULL);
mRCondition.reset(other.mRCondition ? new Condition(*other.mRCondition) : NULL);
return *this;
}
Definition at line 110 of file Condition.h.
References Condition(), and OperatorTypeDef::Or.
{
return Condition(*this, OperatorType::Or, other);
}

| bool Condition::passesValue | ( | ) | const [private] |
Definition at line 144 of file Condition.cpp.
References BWAPI::Broodwar, ConditionTestDef::canForgeExpand, BWAPI::Player::deadUnitCount(), ConditionTestDef::enemyDoesntHasUnitLessThan, ConditionTestDef::enemyHasResearched, ConditionTestDef::enemyUnitCountGreaterEqualThan, BWAPI::Game::getStartLocations(), BWAPI::Player::getUpgradeLevel(), BWAPI::Player::hasResearched(), Singleton< T >::Instance(), ConditionTestDef::isEnemyProtoss, ConditionTestDef::isEnemyTerran, ConditionTestDef::isEnemyZerg, ConditionTestDef::isResearched, ConditionTestDef::isResearching, BWAPI::Player::isResearching(), ConditionTestDef::isUpgraded, ConditionTestDef::isUpgrading, BWAPI::Player::isUpgrading(), MapHelper::mapIs(), ConditionTestDef::mapIs, ConditionTestDef::mapSize, mExtraInt, ConditionTestDef::minDistanceBetweenMainsGreaterThan, ConditionTestDef::minDistanceBetweenMainsLessThan, mNeededValue, mString, mTech, mType, mUnitType, mUpgrade, ConditionTestDef::myPlannedUnitTotalGreaterEqualThan, ConditionTestDef::myPlannedUnitTotalLessThan, ConditionTestDef::myUnitTotalBuildCountGreaterEqualThan, ConditionTestDef::myUnitTotalBuildCountLessThan, ConditionTestDef::None, ConditionTestDef::numberOfEnemies, BWAPI::Races::Protoss, BWAPI::Game::self(), BWAPI::Races::Terran, SafeEnum< def, inner >::underlying(), and BWAPI::Races::Zerg.
Referenced by evauluate().
{
switch(mType.underlying())
{
case ConditionTest::myUnitTotalBuildCountGreaterEqualThan:
return BWAPI::Broodwar->self()->deadUnitCount(mUnitType) + MacroManager::Instance().getPlannedTotal(mUnitType) >= mExtraInt;
case ConditionTest::myUnitTotalBuildCountLessThan:
return BWAPI::Broodwar->self()->deadUnitCount(mUnitType) + MacroManager::Instance().getPlannedTotal(mUnitType) < mExtraInt;
case ConditionTest::enemyUnitCountGreaterEqualThan:
return PlayerTracker::Instance().enemyUnitCount(mUnitType) >= mExtraInt;
case ConditionTest::enemyDoesntHasUnitLessThan:
return PlayerTracker::Instance().enemyUnitCount(mUnitType) < mExtraInt;
case ConditionTest::minDistanceBetweenMainsLessThan:
//return MapInformation::Instance().minMainDistance() < mExtraFloat;
case ConditionTest::minDistanceBetweenMainsGreaterThan:
//return MapInformation::Instance().minMainDistance() > mExtraFloat;
case ConditionTest::None:
return mNeededValue;
case ConditionTest::isEnemyProtoss:
return PlayerTracker::Instance().isEnemyRace(BWAPI::Races::Protoss) == mNeededValue;
case ConditionTest::isEnemyZerg:
return PlayerTracker::Instance().isEnemyRace(BWAPI::Races::Zerg) == mNeededValue;
case ConditionTest::isEnemyTerran:
return PlayerTracker::Instance().isEnemyRace(BWAPI::Races::Terran) == mNeededValue;
case ConditionTest::enemyHasResearched:
return PlayerTracker::Instance().enemyHasReseached(mTech);
case ConditionTest::mapSize:
return BWAPI::Broodwar->getStartLocations().size() == mExtraInt;
case ConditionTest::numberOfEnemies:
return PlayerTracker::Instance().getEnemies().size() == mExtraInt;
case ConditionTest::canForgeExpand:
return WallTracker::Instance().canForgeExpand();
case ConditionTest::myPlannedUnitTotalGreaterEqualThan:
return MacroManager::Instance().getPlannedTotal(mUnitType) >= mExtraInt;
case ConditionTest::myPlannedUnitTotalLessThan:
return MacroManager::Instance().getPlannedTotal(mUnitType) < mExtraInt;
case ConditionTest::mapIs:
return MapHelper::mapIs(mString);
case ConditionTest::isResearching:
return BWAPI::Broodwar->self()->isResearching(mTech) || BWAPI::Broodwar->self()->hasResearched(mTech);
case ConditionTest::isResearched:
return BWAPI::Broodwar->self()->hasResearched(mTech);
case ConditionTest::isUpgrading:
return BWAPI::Broodwar->self()->isUpgrading(mUpgrade) && (mExtraInt == 1 || BWAPI::Broodwar->self()->getUpgradeLevel(mUpgrade) == mExtraInt-1);
case ConditionTest::isUpgraded:
return BWAPI::Broodwar->self()->getUpgradeLevel(mUpgrade) == mExtraInt;
}
return false;
}


double Condition::mExtraDouble [private] |
Definition at line 124 of file Condition.h.
Referenced by operator=().
int Condition::mExtraInt [private] |
Definition at line 123 of file Condition.h.
Referenced by operator=(), and passesValue().
boost::scoped_ptr<Condition> Condition::mLCondition [private] |
Definition at line 119 of file Condition.h.
Referenced by evauluate(), and operator=().
bool Condition::mNeededValue [private] |
Definition at line 122 of file Condition.h.
Referenced by operator=(), and passesValue().
OperatorType Condition::mOperatorType [private] |
Definition at line 118 of file Condition.h.
Referenced by evauluate(), and operator=().
boost::scoped_ptr<Condition> Condition::mRCondition [private] |
Definition at line 120 of file Condition.h.
Referenced by evauluate(), and operator=().
std::string Condition::mString [private] |
Definition at line 129 of file Condition.h.
Referenced by operator=(), and passesValue().
BWAPI::TechType Condition::mTech [private] |
Definition at line 127 of file Condition.h.
Referenced by operator=(), and passesValue().
ConditionTest Condition::mType [private] |
Definition at line 116 of file Condition.h.
Referenced by operator=(), and passesValue().
BWAPI::UnitType Condition::mUnitType [private] |
Definition at line 126 of file Condition.h.
Referenced by operator=(), and passesValue().
BWAPI::UpgradeType Condition::mUpgrade [private] |
Definition at line 128 of file Condition.h.
Referenced by operator=(), and passesValue().
1.7.6.1