本文整理汇总了C++中Skill::run方法的典型用法代码示例。如果您正苦于以下问题:C++ Skill::run方法的具体用法?C++ Skill::run怎么用?C++ Skill::run使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Skill
的用法示例。
在下文中一共展示了Skill::run方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: threeManDefense
//----------------------------------------------------------------------------
void Aggressor::threeManDefense(RobotIndex ID,
BasePlay* play,
const VisionData& field,
RobocupStrategyData* sd)
{
//-------------------
//Display message
//-------------------
sd->setMessage(ID, "AGGRESSOR Three Man Defense");
//-------------------
//get a handle on skillset for this robot
//-------------------
SkillSet* skills = sd->getStrategyModule().getSkillSet(ID);
//-------------------
//get a handle on Agressor Recover Ball skill
//-------------------
// Skill* skillHandle = skills->getSkill(AcquirePossessionSkill::skillNum);
Skill* skillHandle = skills->getSkill(SupplementThreeManSkill::skillNum);
//-------------------
//initialize skill if it is not initialized
//-------------------
if(!skillHandle->isInitialized())
skillHandle->initialize();
//-------------------
//run skill
//-------------------
skillHandle->run();
}
示例2: looseDefense
//----------------------------------------------------------------------------
void Defender::looseDefense(RobotIndex ID,
BasePlay* play,
const VisionData& field,
RobocupStrategyData* sd)
{
//===================
//===================
//Handle the Defender
//===================
//===================
//-------------------
//Display message
//-------------------
sd->setMessage(ID, "DEFENDER Loose Defense");
//-------------------
//get a handle on skillset for this robot
//-------------------
SkillSet* skills = sd->getStrategyModule().getSkillSet(ID);
//-------------------
//get a handle on loose defense defender skill
//-------------------
TandemDefenderSkill* skillHandle =
(TandemDefenderSkill*)skills->getSkill(TandemDefenderSkill::skillNum);
//-------------------
//initialize skill if it is not initialized
//-------------------
if(!skillHandle->isInitialized())
skillHandle->initialize();
//-------------------
//run skill
//-------------------
skillHandle->run();
//===================
//===================
//Handle the Special Op Defender if he exists
//===================
//===================
RobotIndex SpecialOpID = sd->getRobotByPosition(SPECIAL_OP_DEFENDER);
if(SpecialOpID != NO_ROBOT)
{
Pair specialOpDefenderLocation=getLocation(SpecialOpID,field,sd->getSystemParams());
Pair defenderLocation=getLocation(ID,field,sd->getSystemParams());
if(
(specialOpDefenderLocation.getY() > getBallLocation(field).getY() &&
defenderLocation.getY() > sd->getSystemParams().field.SPLIT_LINE) ||
(specialOpDefenderLocation.getY() < getBallLocation(field).getY() &&
defenderLocation.getY() < sd->getSystemParams().field.SPLIT_LINE)
)
{
sd->setMessage(SpecialOpID, "SPECIAL OP DEFENDER Taking over for Defender");
sd->getDestination(SpecialOpID)->setPos(sd->getDestination(ID)->getPos());
}
//-------------------
//Display message
//-------------------
sd->setMessage(SpecialOpID, "SPECIAL OP DEFENDER Loose Defense");
//-------------------
//get a handle on skillset for this robot
//-------------------
SkillSet* skills = sd->getStrategyModule().getSkillSet(SpecialOpID);
//-------------------
//get a handle on loose defense special Op skill
//-------------------
Skill* soSkillHandle;
if(sd->getSystemParams().strategy2002.ENABLE_FOLLOW_DEFNDER_SKILL)
{
soSkillHandle = skills->getSkill(FollowDefenderSkill::skillNum);
}
else
{
soSkillHandle = skills->getSkill(LooseDSpecialOpSkill::skillNum);
}
//-------------------
//initialize skill if it is not initialized
//-------------------
if(!soSkillHandle->isInitialized())
soSkillHandle->initialize();
//-------------------
//run skill
//-------------------
soSkillHandle->run();
}
}
示例3: execute
//===============================================================================
//Execute the skill. This is the main part of the skill, where you tell the
//robot how to perform the skill.
void SupplementThreeManSkill::execute()
{
///If not initialized, dont do anything!
if(!initialized)
{
return;
}
//if the ball is close enough to defenisve players, move next to
//the defensive player that is closer to the ball
//since he'll become the aggresor and move upfield.
//this way we can slide in and form the defensive wall immediately.
Pair ballLoc = getBallLocation(*currentVisionData);
Pair robotLoc = getLocation(robotID, *currentVisionData, *sp);
RobotIndex closeDefensiveID = NO_ROBOT;
float closestDistance;
RobotIndex tempID;
float tempDistance;
tempID = strategy->getCurrentRoboCupFrame()->getRobotByPosition(BLOCKER);
if(tempID != NO_ROBOT)
{
closestDistance = getLocation(tempID, *currentVisionData, *sp).distanceTo(ballLoc);
closeDefensiveID = tempID;
}
tempID = strategy->getCurrentRoboCupFrame()->getRobotByPosition(DEFENDER);
if(tempID != NO_ROBOT)
{
tempDistance = getLocation(tempID, *currentVisionData, *sp).distanceTo(ballLoc);
if(tempDistance < closestDistance)
{
closestDistance = tempDistance;
closeDefensiveID = tempID;
}
if(closeDefensiveID == strategy->getCurrentRoboCupFrame()->getRobotByPosition(BLOCKER))
closeDefensiveID = strategy->getCurrentRoboCupFrame()->getRobotByPosition(DEFENDER);
}
tempID = strategy->getCurrentRoboCupFrame()->getRobotByPosition(SPECIAL_OP_DEFENDER);
if(tempID != NO_ROBOT)
{
tempDistance = getLocation(tempID, *currentVisionData, *sp).distanceTo(ballLoc);
if(tempDistance < closestDistance)
{
closestDistance = tempDistance;
closeDefensiveID = tempID;
}
if(closeDefensiveID == strategy->getCurrentRoboCupFrame()->getRobotByPosition(BLOCKER))
closeDefensiveID = strategy->getCurrentRoboCupFrame()->getRobotByPosition(SPECIAL_OP_DEFENDER);
}
//if closest defensive player
//a.) exists
//b.) within tolerance, then go to side of him
if(closestDistance < 3.0f*sp->general.PLAYER_RADIUS)
{
Pair defensivePlayer = getLocation(closeDefensiveID, *currentVisionData, *sp);
if(defensivePlayer.getY() > sp->field.SPLIT_LINE)
{
command->setYPos(defensivePlayer.getY() + sp->general.PLAYER_RADIUS + 0.02f);
}
else
{
command->setYPos(defensivePlayer.getY() - sp->general.PLAYER_RADIUS - 0.02f);
}
command->setXPos(defensivePlayer.getX());
command->setRotation(angleBetween(robotLoc, ballLoc));
}
//else acquire the ball
else
{
Skill* skillHandle = skillSet->getSkill(AcquirePossessionSkill::skillNum);
if(!skillHandle->isInitialized())
skillHandle->initialize();
skillHandle->run();
}
}