Thursday, June 20, 2013

Robustness

Now I have some geometry that better represents what might actually be used in practice.  How well does it work?  Pretty well on any given side of a building, not so well at the corners.  Remember that the grammar builds each wall separately and (in a horizontal layout) keeps adding floors until the total height of that wall is greater than the height from the input file.  The problem is these new elements are not uniform height (or even integer).  One wall might get a floor that is only short decorative items and another might get several floors with some really tall element. the trouble is one might barely cross the threshold and the other might shoot way past it.
Oops.  
This is another problem, buildings generally have the same number of floors on each side.  Easy enough to just trim off the extra floors on any wall that got too tall, but what about uneven floor heights?  

There are a number of easy, direct solutions.  I could just clamp everything to the average floor height, that wouldn't be too bad.  Simulated annealing might have a better option though.  For each level (equivalent floors on all sides) match the heights of the floors on one of the floors already there.  Its about the same as picking one side and matching all the others to it, but with more possible combinations.  The point of simulated annealing is to optimize something, so lets minimize cost.  Most elements are designed to look a certain way, stitching or squashing them make them look wrong.  So measuring deformation per-element is a good place to start for cost.

On loading each element I can store its aspect ratio and measure the normalized change from that ration after the element has been altered.  It might make sense at this point to exclude the fill element used to take up whatever slack is left at the ends of each floor so that corners match.  These elements are supposed to be so simple that some scaling is not noticeable.  Regardless, the sum of the normalized distortion of all the elements gives a cost for the building.  With a little more experimenting and some hard coded exclusions of situations I know cause problems I got some good looking buildings out of each run.


No comments:

Post a Comment