Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>The problem with your question is that 'organic and random' can be many different things. Let me show two links</p> <ul> <li>generating <a href="http://gameprogrammer.com/fractal.html#heightmaps" rel="nofollow noreferrer">random fractal terrain</a> (look at section 'Cloudy Skies' and imagine that you turn it to b/w, or in your case yellow/background).</li> <li>simulating <a href="http://markjstock.org/pages/builder.html" rel="nofollow noreferrer">erosion</a> (look at the image under 'erode')</li> </ul> <p>The two above samples are 'organic and random' to me, but you might not be satisfied with those. So, I think you will have to better define what is 'organic and random'.</p> <p>For now, I'll take your definition of the guiding rule for adding new tiles (but don't think it is necessarily the same problem), which I read as:</p> <blockquote> <p>Given two shapes (assuming bitmaps) find the relative position of the shapes such that the number of touching sides is maximum</p> </blockquote> <p>I will also assume</p> <ul> <li>overlap is not allowed</li> <li>you can leave holes inside the resulting, merged shape</li> <li>you can <strong>not</strong> rotate shapes</li> </ul> <p>Under such conditions you need to test less then x<em>y solutions and in each you need to - discard it if there is an overlap - discard it if they do not touch - if they touch then count the number of edges that are common All three of the above tests can be done in constant time by scanning all the yellow tiles (number of which is konst</em>x*y)</p> <p>So, the above can be easily done in O(n^4), is that good enough for you?</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload