Fixed the bug that made walls not receive the algorithm.
This commit is contained in:
parent
4d748d1f48
commit
ebb5360c5c
3 changed files with 30 additions and 30 deletions
10
map.cpp
10
map.cpp
|
@ -5,8 +5,8 @@
|
|||
using std::vector, std::pair;
|
||||
using namespace fmt;
|
||||
|
||||
void dump_map(Matrix &map) {
|
||||
println("-----------------");
|
||||
void dump_map(const std::string &msg, Matrix &map) {
|
||||
println("----------------- {}", msg);
|
||||
for(auto row : map) {
|
||||
for(auto col : row) {
|
||||
print("{} ", col);
|
||||
|
@ -40,15 +40,15 @@ Matrix dijkstra_map(Matrix &input_map, Matrix &walls_map, int limit) {
|
|||
size_t w = input_map[0].size();
|
||||
|
||||
// Initialize the new array with every pixel at limit distance
|
||||
Matrix new_arr = Matrix(h, MatrixRow(w, 1));
|
||||
// NOTE: this is normally ones() * limit
|
||||
Matrix new_arr = Matrix(h, MatrixRow(w, limit));
|
||||
Matrix closed = walls_map;
|
||||
PairList starting_pixels;
|
||||
PairList open_pixels;
|
||||
limit = limit == 0 ? h * w : limit;
|
||||
|
||||
|
||||
// First pass: Add starting pixels and put them in closed
|
||||
for(size_t counter = 0; counter < h * w; counter++) {
|
||||
for(size_t counter = 0; counter < h * w; counter++) {
|
||||
size_t i = counter % w;
|
||||
size_t j = counter / w;
|
||||
if(input_map[j][i] == 0) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue