#random rectangle partitioning

48 messages · Page 1 of 1 (latest)

upbeat glade
#

I need a method of generating a random partitioning of a rectangle into sub rectangles. This method must have a chance of generating any potential rectangle partitioning. Here is an example.

split relicBOT
sinful dust
#

are the coordinates integers?

upbeat glade
#

yes

#

subpartitioning a w by h rectangle with everything integer coordinates

sinful dust
#

any other conditions?

#

like the number of rectangles?

upbeat glade
#

atleast n rectangles

#

thats it

#

it can be a little more

#

the naive solution is recursively splitting rectangles along the x or y axis

#

but that can't generate a lot of partitions

#

that are more complex

sinful dust
#

imma call

#

!xy

split relicBOT
#

Please show the original problem, exactly as it was stated to you, with the entire original context. A picture or screenshot is best. If the original problem is not in English, then post it anyway! The additional context might still be helpful. Do your best to provide a translation.

sinful dust
#

maybe a bit more context behind this? i assume this is a programming task

upbeat glade
#

yes

#

I am making a puzzle game played on a rectangular partitioning grid

sinful dust
#

i found some answers for this online

upbeat glade
#

thats the naive solution

#

i believe

#

ill read the first one

sinful dust
#

in the first one the answer was specifically avoiding it

upbeat glade
#

the first one implemented one specific case

#

but there's more than one of these rectangular partitioning that aren't just made by horizontal/vertical splits

#

i did some research on this

sinful dust
#

like this

#

turn the orange and part of a purple rectangle into one (blue outline) and the rest of the purple one just keep as another rectangle

#

although i cannot guarantee that this will generate every pattern ever

upbeat glade
#

this is the most basic one that can't be generated by the naive solution

#

i wonder if its possible with that technique

#

hm

#

ok yes it is possible cause what you would do is

#

have vertical lines at x=1 and x=3

#

have horizontal lines at y = 1 and y = 3

#

then merge some stuff

#

and you get that

#

not a bad solution but I feel like there has to be something more elegant

proper ocean
#

.close