本文整理汇总了C++中Pos::DistWith方法的典型用法代码示例。如果您正苦于以下问题:C++ Pos::DistWith方法的具体用法?C++ Pos::DistWith怎么用?C++ Pos::DistWith使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Pos
的用法示例。
在下文中一共展示了Pos::DistWith方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
vector<Pos> Board::MoveGung(Pos pos)
{
vector<Pos> candidates;
int curr_id = stage[pos.y][pos.x];
int nx, ny;
for (int dy = -1; dy <= 1; dy++) {
for (int dx = -1; dx <= 1; dx++) {
nx = pos.x + dx;
ny = pos.y + dy;
if ((pos.x == 3 && (pos.y == 1 || pos.y == 8)) ||
(pos.x == 4 && (pos.y == 0 || pos.y == 2 || pos.y == 7 || pos.y == 9)) ||
(pos.x == 5 && (pos.y == 1 || pos.y == 8))) {
// movable to only up, right, left, down side
if (pos.DistWith(nx, ny) > 1)
continue;
}
if (nx >= 3 && nx <= 5
&& ((ny >= 0 && ny <= 2) || (ny >= 7 && ny <= 9))) {
if (curr_id <= 6) {
if (stage[ny][nx]<0 || stage[ny][nx]>6) {
candidates.push_back(Pos(nx, ny));
}
}
else {
if (stage[ny][nx]<0 || stage[ny][nx] <= 6) {
candidates.push_back(Pos(nx, ny));
}
}
}
}
}
return candidates;
}