#include "matrix.hpp" #include "constants.hpp" #include using namespace fmt; using matrix::Matrix; namespace matrix { each_cell::each_cell(Matrix &mat) { height = mat.size(); width = mat[0].size(); } bool each_cell::next() { x++; x *= (x < width); y = y + (x == 0); return y < height; } each_row::each_row(Matrix &mat) : $mat(mat) { height = $mat.size(); width = $mat[0].size(); } bool each_row::next() { x++; x *= (x < width); y = y + (x == 0); row = x == width - 1; cell = y < height ? $mat[y][x] : -1; return y < height; } void dump(const std::string &msg, Matrix &map, int show_x, int show_y) { println("----------------- {}", msg); for(each_row it{map}; it.next();) { if(int(it.x) == show_x && int(it.y) == show_y) { print("{:x}<", it.cell); } else if(it.cell == WALL_PATH_LIMIT) { print("# "); } else if(it.cell > 15) { print("* "); } else { print("{:x} ", it.cell); } if(it.row) print("\n"); } } }