83 const bool wall_front =
84 mazeTarget.
isWall(currentPos, currentDir + Direction::Front);
85 const bool wall_left =
86 mazeTarget.
isWall(currentPos, currentDir + Direction::Left);
87 const bool wall_right =
88 mazeTarget.
isWall(currentPos, currentDir + Direction::Right);
90 maze.
updateWall(currentPos, currentDir + Direction::Front, wall_front);
91 maze.
updateWall(currentPos, currentDir + Direction::Left, wall_left);
92 maze.
updateWall(currentPos, currentDir + Direction::Right, wall_right);
95 if (std::find(goals.cbegin(), goals.cend(), currentPos) != goals.cend())
99 maze, currentPos, maze.
getGoals(),
false,
true);
101 if (moveDirs.empty()) {
102 MAZE_LOGE <<
"Failed to Find a path to goal!" << std::endl;
106 for (
const auto nextDir : moveDirs) {
110 const auto relativeDir =
Direction(nextDir - currentDir);
113 currentPos = currentPos.
next(nextDir);
114 currentDir = nextDir;
117 "Searching for Goal");
123 const bool wall_front =
124 mazeTarget.
isWall(currentPos, currentDir + Direction::Front);
125 const bool wall_left =
126 mazeTarget.
isWall(currentPos, currentDir + Direction::Left);
127 const bool wall_right =
128 mazeTarget.
isWall(currentPos, currentDir + Direction::Right);
130 maze.
updateWall(currentPos, currentDir + Direction::Front, wall_front);
131 maze.
updateWall(currentPos, currentDir + Direction::Left, wall_left);
132 maze.
updateWall(currentPos, currentDir + Direction::Right, wall_right);
138 for (
const auto nextDir : shortestDirs) {
139 pos = pos.
next(nextDir);
140 if (maze.
unknownCount(pos)) shortestCandidates.push_back(pos);
143 if (shortestCandidates.empty())
break;
146 maze, currentPos, shortestCandidates,
false,
true);
148 if (moveDirs.empty()) {
149 MAZE_LOGE <<
"Failed to Find a path to goal!" << std::endl;
153 for (
const auto nextDir : moveDirs) {
157 const auto relativeDir =
Direction(nextDir - currentDir);
160 currentPos = currentPos.
next(nextDir);
161 currentDir = nextDir;
164 "Searching for Shortest Path Candidates");
170 if (currentPos == maze.
getStart())
break;
173 maze, currentPos, {maze.
getStart()},
true,
true);
175 if (moveDirs.empty()) {
176 MAZE_LOGE <<
"Failed to Find a path to goal!" << std::endl;
180 for (
const auto nextDir : moveDirs) {
182 const auto relativeDir =
Direction(nextDir - currentDir);
185 currentPos = currentPos.
next(nextDir);
186 currentDir = nextDir;
189 "Going Back to Start");
迷路上の方向を表す。
Definition: Maze.h:145
const Position & getStart() const
スタート区画を取得
Definition: Maze.h:834
bool updateWall(const Position p, const Direction d, const bool b, const bool pushRecords=true)
既知の壁情報と照らしあわせながら、壁を更新する関数
Definition: Maze.cpp:130
int8_t unknownCount(const Position p) const
引数区画に隣接する未知壁の数を返す
Definition: Maze.cpp:125
bool isWall(const WallIndex i) const
壁の有無を返す
Definition: Maze.h:669
区画ベースのステップマップを管理するクラス
Definition: StepMap.h:19
Directions calcShortestDirections(const Maze &maze, const Position start, const Positions &dest, const bool knownOnly, const bool simple)
与えられた区画間の最短経路を導出する関数
Definition: StepMap.cpp:221
void MoveRobot(const Direction relativeDir)
ロボットを動かす模擬関数
Definition: main.cpp:29
void ShowAnimation(const StepMap &stepMap, const Maze &maze, const Position &pos, const Direction &dir, const std::string &msg)
アニメーション状に迷路を表示する関数
Definition: main.cpp:52
std::vector< Position > Positions
Position 構造体の動的配列、集合
Definition: Maze.h:375
迷路の区画の位置(座標)を定義。
Definition: Maze.h:268
Position next(const Direction d) const
自分の引数方向に隣接した区画の Position を返す
Definition: Maze.cpp:22