disable field limits
This commit is contained in:
parent
636596a2cf
commit
219f454e6c
18
src/main.cc
18
src/main.cc
|
@ -55,7 +55,6 @@ class Bot {
|
|||
int x, y;
|
||||
bool up, right, down, left;
|
||||
std::map<std::pair<int, int>, unsigned> known_map;
|
||||
int field_width, field_height;
|
||||
|
||||
asio::awaitable<void> Protocol();
|
||||
asio::awaitable<void> Join();
|
||||
|
@ -201,23 +200,19 @@ unsigned Bot::ShortestPath(int x, int y) {
|
|||
if (visited.count(position)) {
|
||||
continue;
|
||||
}
|
||||
if (!(known_map[position] & static_cast<unsigned>(Direction::LEFT)) &&
|
||||
position.first > 0) {
|
||||
if (!(known_map[position] & static_cast<unsigned>(Direction::LEFT))) {
|
||||
auto pos = std::make_pair(position.first - 1, position.second);
|
||||
queue.emplace(distance + 1 + AStarHeuristic(pos), pos);
|
||||
}
|
||||
if (!(known_map[position] & static_cast<unsigned>(Direction::RIGHT)) &&
|
||||
position.first < field_width) {
|
||||
if (!(known_map[position] & static_cast<unsigned>(Direction::RIGHT))) {
|
||||
auto pos = std::make_pair(position.first + 1, position.second);
|
||||
queue.emplace(distance + 1 + AStarHeuristic(pos), pos);
|
||||
}
|
||||
if (!(known_map[position] & static_cast<unsigned>(Direction::UP)) &&
|
||||
position.second > 0) {
|
||||
if (!(known_map[position] & static_cast<unsigned>(Direction::UP))) {
|
||||
auto pos = std::make_pair(position.first, position.second - 1);
|
||||
queue.emplace(distance + 1 + AStarHeuristic(pos), pos);
|
||||
}
|
||||
if (!(known_map[position] & static_cast<unsigned>(Direction::DOWN)) &&
|
||||
position.second < field_height) {
|
||||
if (!(known_map[position] & static_cast<unsigned>(Direction::DOWN))) {
|
||||
auto pos = std::make_pair(position.first, position.second + 1);
|
||||
queue.emplace(distance + 1 + AStarHeuristic(pos), pos);
|
||||
}
|
||||
|
@ -228,11 +223,6 @@ unsigned Bot::ShortestPath(int x, int y) {
|
|||
}
|
||||
|
||||
asio::awaitable<void> Bot::ChooseMove() {
|
||||
if (known_map.empty()) {
|
||||
field_width = x;
|
||||
field_height = y;
|
||||
}
|
||||
|
||||
// update map
|
||||
known_map[std::make_pair(x, y)] =
|
||||
(up ? static_cast<unsigned>(Direction::UP) : 0) |
|
||||
|
|
Loading…
Reference in a new issue