title: Random world generation of streets
body: <p>I am trying to randomly generate terrain for a game, in such a way that an object at position <code>x, y</code> is of type number <code>f(x, y)</code> (so I don't have to store the values of all the objects. I am trying to generate an environment like a city, with streets and blocks between them.</p>
  
  <p>For example:</p>
  
  <pre><code># # # # #   # # #   # # # # 
  # # # # #   # # #   # # # # 
  # # # # #   # # #   # # # # 
  # # # # #   # # #   # # # #
  # # # # #
  # # # # #   # # # # #   # # 
              # # # # #   # # 
  # # # # #   # # # # #   # #  
  # # # # #   # # # # #   # # 
  
  #   # # # # # # #   # # # # 
  #   # # # # # # #   # # # # 
  #   # # # # # # #   # # # # 
  #   # # # # # # #   # # # #
  </code></pre>
  
  <p>I can generate something kind of like this in a regular pattern, using <code>f(x, y): (x*y) mod n</code>, where <code>n</code> is a constant and a resulting tile is only empty if <code>f(x, y) == 0</code>.</p>
  
  <p>For instance, with <code>n</code> as 5:</p>
  
  <pre><code># # # #   # # # #   # # # # 
  # # # #   # # # #   # # # # 
  # # # #   # # # #   # # # # 
  # # # #   # # # #   # # # # 
  
  # # # #   # # # #   # # # # 
  # # # #   # # # #   # # # # 
  # # # #   # # # #   # # # # 
  # # # #   # # # #   # # # # 
  
  # # # #   # # # #   # # # # 
  # # # #   # # # #   # # # # 
  # # # #   # # # #   # # # # 
  # # # #   # # # #   # # # #
  </code></pre>
  
  <p>How can I alter my algorithm (or get a new one) to get results more like the first example?</p>
  
  <p>Or am I going about this completely the wrong way?</p>