This commit is contained in:
Eric Mertens 2022-11-27 11:01:31 -08:00
parent 7d9692efa4
commit 07567e4c8a

View File

@ -8,7 +8,7 @@
#include <sstream>
#include <string>
#include <tuple>
#include <vector>
#include <queue>
#include <doctest.h>
@ -114,18 +114,18 @@ auto Game::Move(Coord my_coord, char my_team) -> std::optional<Coord>
Coord best_end; // initialized when best_start is non-empty
int best_distance; // initialized when best_start is non-empty
std::deque<std::tuple<Coord, Coord, int>> todo;
std::queue<std::tuple<Coord, Coord, int>> todo;
for (auto const dir : reading_order) {
auto const start = my_coord + dir;
if (grid_[start] == '.') {
todo.push_back({start, start, 1});
todo.push({start, start, 1});
}
}
std::set<Coord> seen;
while (!todo.empty()) {
auto const [start, cursor, steps] = todo.front();
todo.pop_front();
todo.pop();
if (best_start) {
if (best_distance < steps) break;
@ -135,7 +135,7 @@ auto Game::Move(Coord my_coord, char my_team) -> std::optional<Coord>
for (auto const dir : reading_order) {
auto const next = cursor + dir;
if (grid_[next] == '.') {
todo.push_back({start, cursor + dir, steps+1});
todo.push({start, cursor + dir, steps+1});
}
}
}