本文整理汇总了C++中bwapi::Position::makeValid方法的典型用法代码示例。如果您正苦于以下问题:C++ Position::makeValid方法的具体用法?C++ Position::makeValid怎么用?C++ Position::makeValid使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类bwapi::Position
的用法示例。
在下文中一共展示了Position::makeValid方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: move
void UnitMng::move()
{
BWAPI::Position* currentPosition= new BWAPI::Position((this->conUnit)->getPosition());
BWAPI::Position *movePosition;
int updown=128*(outputs[3]-0.5);
int leftright=128*(outputs[4]-0.5);
movePosition= new BWAPI::Position((currentPosition->x() + updown),(currentPosition->y()+leftright));
movePosition->makeValid();
this->conUnit->move(*movePosition);
}
示例2: executeMicro
void WraithManagerExt::executeMicro(const UnitVector & targets)
{
const UnitVector & selectedUnits = getUnits();
_noTurretTargetsNo = 0;
// figure out targets
UnitVector selectedUnitTargets;
for (size_t i(0); i<targets.size(); i++)
{
// conditions for targeting
if (targets[i]->isVisible())
{
selectedUnitTargets.push_back(targets[i]);
if (!isTurret(targets[i]))
{
_noTurretTargetsNo++;
}
}
}
setAverageEnemyPosition(selectedUnitTargets);
// For each unit
BOOST_FOREACH(BWAPI::Unit * selectedUnit, selectedUnits)
{
// Adjust cloak to the situation
manageCloak(selectedUnit, selectedUnitTargets);
// if the order is to attack or defend
if (order.type == order.Attack || order.type == order.Defend)
{
// if there are targets
if (!selectedUnitTargets.empty())
{
// find the best target for this unit
BWAPI::Unit * target = getTarget(selectedUnit, selectedUnitTargets);
// attack it
kiteTarget(selectedUnit, target);
}
// if there are no targets
else
{
// if we're not near the order position
if (selectedUnit->getDistance(order.position) > 100)
{
// move to it
// Border movement
BWAPI::Position movePosition;
if (order.type == SquadOrder::Attack
&& (StrategyManager::Instance().getCurrentStrategy() == StrategyManager::Instance().TerranWraithRush1Port))
{
movePosition = UnitManagerExt::Instance().getMovePosition(selectedUnit);
}
else
{
movePosition = order.position;
}
// eof Border movement
if (!movePosition.isValid())
{
movePosition.makeValid();
}
smartAttackMove(selectedUnit, movePosition);
}
}
}
if (Options::Debug::DRAW_UALBERTABOT_DEBUG)
{
BWAPI::Broodwar->drawLineMap(selectedUnit->getPosition().x(), selectedUnit->getPosition().y(),
selectedUnit->getTargetPosition().x(), selectedUnit->getTargetPosition().y(), Options::Debug::COLOR_LINE_TARGET);
}
}