From 219f454e6ce73feec61e8d5619d39b48a898b2a7 Mon Sep 17 00:00:00 2001 From: Thomas Lindner Date: Sat, 21 May 2022 10:31:55 +0200 Subject: [PATCH] disable field limits --- src/main.cc | 18 ++++-------------- 1 file changed, 4 insertions(+), 14 deletions(-) diff --git a/src/main.cc b/src/main.cc index 44c49ea..4d62a63 100644 --- a/src/main.cc +++ b/src/main.cc @@ -55,7 +55,6 @@ class Bot { int x, y; bool up, right, down, left; std::map, unsigned> known_map; - int field_width, field_height; asio::awaitable Protocol(); asio::awaitable Join(); @@ -201,23 +200,19 @@ unsigned Bot::ShortestPath(int x, int y) { if (visited.count(position)) { continue; } - if (!(known_map[position] & static_cast(Direction::LEFT)) && - position.first > 0) { + if (!(known_map[position] & static_cast(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(Direction::RIGHT)) && - position.first < field_width) { + if (!(known_map[position] & static_cast(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(Direction::UP)) && - position.second > 0) { + if (!(known_map[position] & static_cast(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(Direction::DOWN)) && - position.second < field_height) { + if (!(known_map[position] & static_cast(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 Bot::ChooseMove() { - if (known_map.empty()) { - field_width = x; - field_height = y; - } - // update map known_map[std::make_pair(x, y)] = (up ? static_cast(Direction::UP) : 0) |