Note that there are some explanatory texts on larger screens.

plurals
  1. POHow can I generate an "unlimited" world?
    primarykey
    data
    text
    <p>I would like to create a game with an endless (in reality an extremely large) world in which the player can move about. Whether or not I will ever get around to implement the game is one matter, but I find the idea interesting and would like some input on how to do it. </p> <p>The point is to have a world where all data is generated randomly on-demand, but in a <em>deterministic</em> way. </p> <p>Currently I focus on a large 2D map from which it should be possible to display any part without knowledge about the surrounding parts.</p> <p>I have implemented a prototype by writing a function that gives a random-looking, but deterministic, integer given the x and y of a pixel on the map (see <a href="https://stackoverflow.com/questions/3043521/a-function-where-small-changes-in-input-always-result-in-large-changes-in-output">my recent question about this function</a>). Using this function I populate the map with "random" values, and then I smooth the map using a simple filter based on the surrounding pixels. This makes the map dependent on a few pixels outside its edge, but that's not a big problem. The final result is something that at least looks like a map (especially with a good altitude color map). Given this, one could maybe first generate a coarser map which is used to generate bigger differences in altitude to create mountain ranges and seas.</p> <p>Anyway, that was <em>my</em> idea, but I am sure that there exist ways to do this already and I also believe that given the specification, many of you can come up with better ideas. </p> <p><strong>EDIT:</strong> Forgot the link to my question.</p> <p><strong>EDIT 2:</strong> I think I'll have to clarify that it is important that two adjacent parts of the map, generated separately, needs to smoothly connect to each other.</p> <p><strong>EDIT 3:</strong> Some more information was asked for in the comments.</p> <p>Here's an image taken <a href="http://www.neilblevins.com/cg_education/fractal_noise/fractal_noise.html" rel="nofollow noreferrer">from a page about fractal and Perlin Noise</a> that looks much like what I have produced myself previously (since my best attempt probably used Perlin Noise):</p> <p><a href="http://www.neilblevins.com/cg_education/fractal_noise/perlin_fractal_max_levels2.jpg" rel="nofollow noreferrer">http://www.neilblevins.com/cg_education/fractal_noise/perlin_fractal_max_levels2.jpg</a></p> <p>Think of black pixels as deep sea and white pixels as mountain tops. This is what I need, a simple 2D elevation map.</p> <p>What I want to be able to do is to pick any rectangle from the very large world (in the range of MAXINT * MAXINT pixels) and generate it. If I would generate any part of the image above it should get exactly the same pixels as if I generated a bigger part encompassing the smaller one.</p> <p>Now on to Unreason's questions:</p> <p><em>Required performance</em>: My main aim would be a turn based RPG, so performance could be quite low, but I think it would be very interesting to see if it is possible to create a fast algorithm.</p> <p><em>Memory requirements</em>: Preferably nothing should be pregenerated, but other than that, memory usage should match any ordinary game or application.</p> <p><em>Required detail</em>: Well, if you look at the image, you get the idea. It would be very nice though, if it was possible to zoom out and pan without having to calculate the map at the most zoomed in level first.</p> <p><em>Required types of objects and object properties to generate</em>: Nothing fancy, I am happy with the terrain according to the image above. But I admit I've been thinking of a similar setup where everything is a very very big city. That would be another question, though.</p> <p><strong>EDIT 4:</strong> Hopefully the final one.</p> <p>OK, after reading a bit it seems that Perlin Noise is the way to go. I have one more question though (if someone cares to answer now that I have accepted one (actually two) answers :) ).</p> <p>The perlin noise function takes doubles. What's the range for these doubles? [0-1[ ? Or can I happily send in my large integers?</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

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