title: How do I write the diamond-square algorithm in C++?
body: <blockquote>
    <p><strong>Possible Duplicate:</strong><br>
    <a href="https://stackoverflow.com/questions/2755750/diamond-square-algorithm">Diamond square algorithm</a>  </p>
  </blockquote>
  
  
  
  <p>I'm trying to use the diamond-square algorithm to generate terrain in my 2D game. I have found many resources explaining the algorithm but none actually showing how to implement it in C++. I am creating a tile based game and would like to use the algorithm to generate a random world (water, sand, grass, mountains). My plan is to use the values of the diamond-square algorithm to determine the tile. Ex. If the value is less than 1, water. If the value is greater than 10, mountain. Etc.</p>
  
  <p>So basically what I'm asking is, does anyone have a C++ example of the diamond square algorithm that I can look at and tweak?</p>