Matrix moved.
This commit is contained in:
parent
5863920105
commit
0064664556
20 changed files with 22 additions and 22 deletions
36
src/algos/matrix.cpp
Normal file
36
src/algos/matrix.cpp
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
#include "algos/matrix.hpp"
|
||||
#include <fmt/core.h>
|
||||
#include "constants.hpp"
|
||||
|
||||
using namespace fmt;
|
||||
using std::min, std::max;
|
||||
|
||||
namespace matrix {
|
||||
void dump(const std::string &msg, Matrix &map, int show_x, int show_y) {
|
||||
println("----------------- {}", msg);
|
||||
|
||||
for(each_row it{map}; it.next();) {
|
||||
int cell = map[it.y][it.x];
|
||||
|
||||
if(int(it.x) == show_x && int(it.y) == show_y) {
|
||||
if(cell == WALL_PATH_LIMIT) {
|
||||
print("!<", cell);
|
||||
} else {
|
||||
print("{:x}<", cell);
|
||||
}
|
||||
} else if(cell == WALL_PATH_LIMIT) {
|
||||
print("# ");
|
||||
} else if(cell == 0) {
|
||||
print(". ");
|
||||
} else if(cell > 15 && cell < 32) {
|
||||
print("{:x}+", cell - 16);
|
||||
} else if(cell > 31) {
|
||||
print("* ");
|
||||
} else {
|
||||
print("{:x} ", cell);
|
||||
}
|
||||
|
||||
if(it.row) print("\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
43
src/algos/matrix.hpp
Normal file
43
src/algos/matrix.hpp
Normal file
|
|
@ -0,0 +1,43 @@
|
|||
#pragma once
|
||||
#include "shiterator.hpp"
|
||||
|
||||
namespace matrix {
|
||||
using Row = shiterator::BaseRow<int>;
|
||||
using Matrix = shiterator::Base<int>;
|
||||
|
||||
using viewport = shiterator::viewport_t<Matrix>;
|
||||
|
||||
using each_cell = shiterator::each_cell_t<Matrix>;
|
||||
|
||||
using each_row = shiterator::each_row_t<Matrix>;
|
||||
using box = shiterator::box_t<Matrix>;
|
||||
using compass = shiterator::compass_t<Matrix>;
|
||||
using circle = shiterator::circle_t<Matrix>;
|
||||
using rectangle = shiterator::rectangle_t<Matrix>;
|
||||
using rando_rect = shiterator::rando_rect_t<Matrix>;
|
||||
using rando_rect = shiterator::rando_rect_t<Matrix>;
|
||||
using rando_box = shiterator::rando_box_t<Matrix>;
|
||||
using line = shiterator::line;
|
||||
|
||||
void dump(const std::string &msg, Matrix &map, int show_x=-1, int show_y=-1);
|
||||
|
||||
inline Matrix make(size_t width, size_t height) {
|
||||
return shiterator::make<int>(width, height);
|
||||
}
|
||||
|
||||
inline bool inbounds(Matrix &mat, size_t x, size_t y) {
|
||||
return shiterator::inbounds(mat, x, y);
|
||||
}
|
||||
|
||||
inline size_t width(Matrix &mat) {
|
||||
return shiterator::width(mat);
|
||||
}
|
||||
|
||||
inline size_t height(Matrix &mat) {
|
||||
return shiterator::height(mat);
|
||||
}
|
||||
|
||||
inline void assign(Matrix &out, int new_value) {
|
||||
shiterator::assign(out, new_value);
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue