|
|
|
@ -120,8 +120,8 @@ inline int make_split(std::mt19937 &gen, Partition &cur, bool horiz) { |
|
|
|
|
println("MAKE SPLIT horiz={}, y={}, w={}, h={}", horiz, |
|
|
|
|
cur.y, cur.width, cur.height); |
|
|
|
|
size_t dimension = horiz ? cur.height : cur.width; |
|
|
|
|
int min = dimension / 4; // 25% of the dimension
|
|
|
|
|
int max = dimension - min; // 25% off the other side
|
|
|
|
|
int min = dimension / 4; |
|
|
|
|
int max = dimension - min; |
|
|
|
|
println("dimension={}, min={}, max={}", dimension, min, max); |
|
|
|
|
std::uniform_int_distribution<int> rand_dim(min, max); |
|
|
|
|
return rand_dim(gen); |
|
|
|
@ -176,16 +176,21 @@ void partition_map(std::mt19937 &gen, Partition &cur, int depth) { |
|
|
|
|
}; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if(depth > 0 && left.width > 5 && left.height > 5) { |
|
|
|
|
println("### LEFT h={}, w={}", left.width, left.height); |
|
|
|
|
if(depth > 0 && left.width > 4 && left.height > 4) { |
|
|
|
|
println("DOWN LEFT h={}, w={}", left.height, left.width); |
|
|
|
|
partition_map(gen, left, depth-1); |
|
|
|
|
cur.next.push_back(left); |
|
|
|
|
} else { |
|
|
|
|
println("!!!!LEAF LEFT ROOM h={}, w={}", left.height, left.width); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if(depth > 0 && right.width > 5 && right.height > 5) { |
|
|
|
|
println("### RIGHT h={}, w={}", right.width, right.height); |
|
|
|
|
|
|
|
|
|
if(depth > 0 && right.width >= 4 && right.height >= 4) { |
|
|
|
|
println("DOWN RIGHT h={}, w={}", right.height, right.width); |
|
|
|
|
partition_map(gen, right, depth-1); |
|
|
|
|
cur.next.push_back(right); |
|
|
|
|
} else { |
|
|
|
|
println("!!!!LEAF RIGHT ROOM h={}, w={}", right.height, right.width); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -193,13 +198,16 @@ void draw_map(Map *map, Partition &cur) { |
|
|
|
|
if(cur.x + cur.width <= map->width() |
|
|
|
|
&& cur.y + cur.height <= map->height()) |
|
|
|
|
{ |
|
|
|
|
map->make_room(cur.x, cur.y, cur.width, cur.height); |
|
|
|
|
|
|
|
|
|
if(cur.next.size() == 2) { |
|
|
|
|
println("CUR NEXT SIZE: {}", cur.next.size()); |
|
|
|
|
if(cur.next.size() == 1) { |
|
|
|
|
draw_map(map, cur.next[0]); // left
|
|
|
|
|
} else if(cur.next.size() == 2) { |
|
|
|
|
draw_map(map, cur.next[0]); // left
|
|
|
|
|
draw_map(map, cur.next[1]); // right
|
|
|
|
|
} else { |
|
|
|
|
println("LEAF NODE NO CHILDREN"); |
|
|
|
|
println("LEAF NODE NO CHILDREN x={}, y={}, w={}, h={}", cur.x, cur.y, cur.width, cur.height); |
|
|
|
|
map->make_room(cur.x+1, cur.y+1, cur.width-2, cur.height-2); |
|
|
|
|
} |
|
|
|
|
} else { |
|
|
|
|
println("ABORT in draw_map, x={}, y={}, w={}, h={}, map.w={}, map.h={}", |
|
|
|
|