Split area within worldborder into several worldguard regions

Discussion in 'Spigot Plugin Development' started by John55223, Apr 17, 2017.

  1. This is more of an algorithm question than a spigot question, but we have some smart people here so I figured I would ask here first.

    For the sake of simplicity, I have a 4000x4000 square, and I want to split it up randomly into smaller rectangles. Something like this.

    I can't wrap my head around how this would be accomplished. Each of the smaller rectangles is supposed to be a plot of land, that will be assigned to a player, so I don't want to have the square broken up evenly into a grid, I want some variation (ideally in increments of 16).

    Although, assuming I broke the square up evenly into a grid pattern, I could go back through and merge some of the new rectangles together, but I don't want to create L shaped rectangles.

    Anyone have any idea of how to accomplish this? I couldn't really find much explaining how to do something like this, apart from this, however, the only real answer to the problem was drawing lines to split rectangles into two, but I didn't really understand it.

    Any help appreciated :D
  2. maybe you could use a Random integer that is dividable by 4
  3. I appreciate your time, but that doesn't help me at all. Assuming I make a region of random x and y, I could make the first "row" of regions starting at a y value of 0, easily.... like this

    However, once I start to make the second "row" if you will, If I start each rectangle at the bottom left corner of each rectangle in the first row, say this happens, then, this, how would I make the next rectangle fit in there? I am not sure how I would determine how to draw all the rectangles.