diff --git a/src/main.cc b/src/main.cc index 4d62a63..49af91e 100644 --- a/src/main.cc +++ b/src/main.cc @@ -200,7 +200,8 @@ unsigned Bot::ShortestPath(int x, int y) { if (visited.count(position)) { continue; } - if (!(known_map[position] & static_cast(Direction::LEFT))) { + if (!(known_map[position] & static_cast(Direction::LEFT)) && + position.first > 0) { auto pos = std::make_pair(position.first - 1, position.second); queue.emplace(distance + 1 + AStarHeuristic(pos), pos); } @@ -208,7 +209,8 @@ unsigned Bot::ShortestPath(int x, int y) { auto pos = std::make_pair(position.first + 1, position.second); queue.emplace(distance + 1 + AStarHeuristic(pos), pos); } - if (!(known_map[position] & static_cast(Direction::UP))) { + if (!(known_map[position] & static_cast(Direction::UP)) && + position.second > 0) { auto pos = std::make_pair(position.first, position.second - 1); queue.emplace(distance + 1 + AStarHeuristic(pos), pos); }