Better lighting and a circle algorithm that works more reliably.

This commit is contained in:
Zed A. Shaw 2024-12-25 00:27:45 -05:00
parent 03fe9b3d01
commit 35f2defc11
9 changed files with 97 additions and 87 deletions

View file

@ -226,22 +226,28 @@ TEST_CASE("prototype line algorithm", "[matrix:line]") {
}
TEST_CASE("prototype circle algorithm", "[matrix:circle]") {
size_t width = Random::uniform<size_t>(10, 13);
size_t height = Random::uniform<size_t>(10, 15);
Map map(width,height);
// create a target for the paths
Point start{.x=map.width() / 2, .y=map.height()/2};
for(int count = 0; count < 20; count++) {
size_t width = Random::uniform<size_t>(10, 13);
size_t height = Random::uniform<size_t>(10, 15);
int pos_mod = Random::uniform<int>(-3,3);
Map map(width,height);
// create a target for the paths
Point start{.x=map.width() / 2 + pos_mod, .y=map.height()/2 + pos_mod};
for(int radius = 2; radius < 5; radius++) {
// use an empty map
Matrix result = map.walls();
for(int radius = 2; radius < 10; radius++) {
// use an empty map
Matrix result = map.walls();
for(matrix::circle it{start, radius}; it.next();) {
for(int i = it.x0; i < it.x1; i++) {
result[it.y][i] += 1;
for(matrix::circle it{start, radius}; it.next();) {
for(int x = it.left; x < it.right; x++) {
// println("top={}, bottom={}, center.y={}, dy={}, left={}, right={}, x={}, y={}", it.top, it.bottom, it.center.y, it.dy, it.left, it.right, x, it.y);
if(matrix::inbounds(result, x, it.y)) {
result[it.y][x] += 1;
}
}
}
}
// matrix::dump("RESULT AFTER CIRCLE", result, start.x, start.y);
// matrix::dump("RESULT AFTER CIRCLE", result, start.x, start.y);
}
}
}