本文整理汇总了C++中Plan::movesToEnemyCrown方法的典型用法代码示例。如果您正苦于以下问题:C++ Plan::movesToEnemyCrown方法的具体用法?C++ Plan::movesToEnemyCrown怎么用?C++ Plan::movesToEnemyCrown使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Plan
的用法示例。
在下文中一共展示了Plan::movesToEnemyCrown方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Action
lionheart::Action lionheart::MathewWarenski::playSmartCharge(
Unit const &u, SituationReport report, Plan p)
{
if (u.getType() == CROWN)
{
// if (p.movesToEnemy() < 6) return p.moveToLocation(15, 15);
return Action();
}
if (p.movesToEnemyCrown() <= u.getMoveSpeed())
{
if (!p.hasAttack())
{
return p.moveToEnemyCrown();
}
}
if (u.getType() == ARCHER)
{
if (!p.hasAttack())
{
if (enemyWaiting)
{
bool kingOnWall = false;
for (int i = 0; i < 30; i++)
{
for (int j = 1; j <= 2; j++)
{
auto backwall = flipIfWest(ENEMY_EAST_WALL - j, 29);
if (report.things[i][backwall].unit == CROWN)
{
kingY = i;
kingX = backwall;
kingOnWall = true;
}
}
}
if (kingOnWall)
{
auto col = flipIfWest(29, 29);
auto loc = u.getLocation();
if (loc.row == kingY && loc.col == col)
{
if (facingEast && u.getFacing() != lionheart::Direction::WEST)
{
return turn(lionheart::Direction::WEST);
}
else if (!facingEast && u.getFacing() != lionheart::Direction::EAST)
{
return turn(lionheart::Direction::EAST);
}
return lionheart::attack({ kingY, kingX });
}
else if (report.things[kingY][col].unit == ARCHER)
{
return p.attackEnemy();
}
return p.moveToLocation(kingY, col);
}
}
return p.moveToEnemyCrown();
}
}
if (p.hasAttack())
{
return p.attackEnemy();
}
return p.moveToEnemyCrown();
}
示例2: turn
//.........这里部分代码省略.........
}
if ((!west) &&
(report.things[19][26].type == lionheart::SituationReport::ALLY))
{
return p.moveToLocation(19, 27);
}
if ((!west) &&
(report.things[10][26].type == lionheart::SituationReport::ALLY))
{
return p.moveToLocation(10, 27);
}
if (!west)
{
return p.moveToLocation(19, 27);
}
break;
case 4:
if (akingloc.row > 15)
{
if (p.hasAttack())
return p.attackEnemy();
else
return lionheart::turn(lionheart::Direction::NORTH);
}
else if (p.hasAttack())
return p.attackEnemy();
else
return lionheart::turn(lionheart::Direction::SOUTH);
break;
case 5:
case 6:
case 7:
if (safe(row, col, report))
{
return wait();
}
else
return p.attackEnemy();
break;
}
}
if (safe(row, col, report))
{
return wait();
}
else
return p.attackEnemy();
}
if ((numberofturns / 30) <
10) // tells everyone what direction to face for defense;
{
if ((u.getFacing()) != defdir)
return turn(defdir);
else
return wait();
}
if ((numberofturns / 30) <
50) // this will stall in defense for half the game then attack
{
if (p.hasAttack()) return p.attackEnemy();
if (enemyinthebox(report))
{
return p.attackEnemy();
}
if ((u.getId() == 39) || (u.getId() == 40))
{
if (p.movesToEnemy() < 3) return p.moveToEnemy();
if ((row != drow) || (col != dcol)) return p.moveToLocation(drow, dcol);
if ((u.getFacing()) != defdir)
return turn(defdir);
else
return wait();
}
if ((u.getType() == KNIGHT) && (p.movesToEnemy() < 2))
return p.moveToEnemy();
if ((u.getType() != KNIGHT) && (p.movesToEnemy() < 5))
return p.moveToEnemy();
if ((row != drow) || (col != dcol)) return p.moveToLocation(drow, dcol);
if ((u.getFacing()) != defdir)
return turn(defdir);
else
return wait();
}
if (u.getType() == ARCHER) // sends archers around the fort if they can shoot
// over the wall and kill the king
{
return shootoverwall(u, report, p);
}
// tells everyone to attack
if (p.hasAttack()) return p.attackEnemy();
if (enemyinthebox(report)) return p.attackEnemy();
if (p.movesToEnemyCrown() < 2)
return p.moveToEnemyCrown();
else
return p.attackEnemy();
}