JavaScript port of Amit Patel's mapgen2 https://github.com/amitp/mapgen2