本文整理汇总了C++中Stage::getState方法的典型用法代码示例。如果您正苦于以下问题:C++ Stage::getState方法的具体用法?C++ Stage::getState怎么用?C++ Stage::getState使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Stage
的用法示例。
在下文中一共展示了Stage::getState方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: stage
string AI01::useRockfall_E(const Status& enemy) {
string str;
const auto ninjas = enemy.getNinjas();
const Stage stage(enemy.getStageDogStatus());
for (const auto ninja : ninjas)
{
int count = 0;
for (const auto dir : directionPoint)
{
const Point p1 = ninja.point + dir;
const Point p2 = ninja.point + dir + dir;
if (stage.getState(p1) == Stage::State::Rock)
{
if (stage.getState(p2) != Stage::State::None)
{
count++;
}
}
}
if (count < 2) continue;
for (const auto dir : directionPoint)
{
const Point p1 = ninja.point + dir;
const Point p2 = ninja.point + dir + dir;
if (stage.getState(p1) == Stage::State::None)
{
if (stage.getState(p2) != Stage::State::None)
{
str = "2 " + to_string(p1.y) + " " + to_string(p1.x);
return str;
}
}
else if (stage.getState(p1) == Stage::State::Rock)
{
if (stage.getState(p2) == Stage::State::None)
{
str = "2 " + to_string(p1.y) + " " + to_string(p1.x);
return str;
}
}
}
}
return str;
}
示例2: status
void AI01::think(const Status& my, const Status& enemy) {
setCost(my.getNinjutsuCost());
ninjutsuPoint = Point(-1, -1);
array<vector<MoveCommand>, 2> move;
Status status(my);
for (int i = 0; i < 2; i++)
{
try
{
move[i] = dogEscape.getCommand2(i, status);
int ninryoku = my.getNinryoku() - defenceSort[3].first;
if (ninryoku > 0)
{
if (ninryoku >= Status::getNinjutsuCost(NinjutsuCommand::RotatinCut))
{
const auto ninjas = my.getNinjas();
const Stage stage(my.getStageDogStatus());
int dogCount[2] = { 0 };
for (int j = 0; j < 2; j++)
{
for (int y = -1; y < 2; y++)
{
for (int x = -1; x < 2; x++)
{
if (stage.getState(ninjas[j].point + Point(x, y)) == Stage::State::Dog)
{
dogCount[j]++;
}
}
}
}
if (dogCount[i] >= dogCount[1 - i])
{
if (dogCount[i] >= 3)
{
cerr << "回転斬!" << endl;
ninjutsuFlag = true;
ninjutsuString = "7 " + to_string(i);
}
}
}
else
{
useNinjutsuA(enemy, ninryoku);
}
}
}
catch (logic_error e)
{
if (!ninjutsuFlag)
{
try
{
move[i] = useNinjutsuD(my, status, e.what(), i);
}
catch (invalid_argument)
{
return;
}
}
}
if (move[i].empty())
{
move[i] = soulFind.getCommand2(i, status);
if (move[i].size() == 1)
{
Status nextStatus(status);
auto soul = status.getSoulPoints();
auto stage = status.getStage();
const auto p = Stage::moveSimulation(status.getNinjas()[i].point, move[i][0], stage);
for (auto it = soul.begin(); it != soul.end();)
{
if (p == *it) it = soul.erase(it);
else ++it;
}
nextStatus.setSoulPoints(soul);
auto m = soulFind.getCommand2(i, status);
move[i].push_back(m[0]);
}
}
Point p = status.getNinjas()[i].point;
Stage stage = status.getStage();
auto soulPoints = status.getSoulPoints();
for (const auto& c : move[i]) {
p = Stage::moveSimulation(p, status.getNinjas()[(i + 1) % 2].point, c, stage, status.getDogs());
for (auto it = soulPoints.begin(); it != soulPoints.end();)
{
if (p == *it) it = soulPoints.erase(it);
else ++it;
}
}
array<Character, 2> nextNinjas = status.getNinjas();
nextNinjas[i] = Character{ i, p };
//.........这里部分代码省略.........