Subject: Re: Endless and seamless wilderness (was: Re: A predictably random game: One more try) Date: Mon, 25 Feb 2002 16:14:10 +0100 From: Hansjörg Malthaner Newsgroups: rec.games.roguelike.development Jesse Welton wrote: > > Hansjörg Malthaner wrote: > > > > The wilderness is virtually endless. It is divided into areas of 100x100 > > squares. The areas overlap by 20 sqaures. If you walk within 10 sqaures > > to the border of one area the game will flip to the new area. The flip > > is clearly noticeable by the player. If you watch carefully you'll find > > the areas fit seemlessly together [...] > > > > I'll write an explantion how the algorithm works tomorrow, I'm running > > out of time. If someone needs a windows version, just let me know. > > How about just a couple of screenshots, showing two neighboring regions? If I get to my computer today evening I'll make two screenshots of adjacent regions. Currently I'm in the office and have no access to a Linux system. > I'm looking forward to your description of the algorithm. It sounds > like an interesting idea, blending the edges of neighboring regions. > I'm quite curious how well this works. The explanation: The idea is not to build the world from tiles, but to have a big, rather endless world. The worlds contents are determined by a number sequence generator (usually known as random number generator). I'm using a standard RNG which takes a seed and produces a sequence of numbers from this seed. My RNG produces positive 24 bit numbers I.e. If I want to scatter some cities around the world, I can seed the RNG with say (x+C*y) and if the first number produced is, say, below 20, a city is build there. All layout and buildings and everything in that city are then created from subsequent numbers of the sequence. If we want to render the area the player is within, iterate over all sqaures of that area, and seed the RNG according to (x+C*y) and place the city as determined by the RNG. If parts of the generated city are outside the area, just don't relaize them, but let the algorithm work as usual; it must be always use the same sequence of calls to the RNG. C (in x+C*y) usually is a big number preferably a prime number to avoid repetitive patterns. This way the program can realize any area of the world, it's easy to let the player wander around. If he reaches a new area, just create it. Because the areas are part of a bigger world they are seamless by nature. I chose to let the regions overlap a bit (20%) in H-World, because this seems to be more comfortable to the player. Being really clever even continuous movement can be implemented, by always generating the new border sqaures once the player moved, and keep the generated area cenetred on the player. But this will cause problems with monsters and item, see below. Currently I'm just placing trees, and determine location and type of the trees with the RNG. But because the RNG can produce a endless sequence of numbers for a seed this approach can build structures of any complexity on any location - maybe it must be assured by the algorithm that the structures cannot overlap. In another game I produced solar systems for locations, very similar to the city placment mentioned above. Choosing a sun size, then create randomly modified a set of planets, their circles (word?) around the sun, space stations, ecenomic type and few more details. (Unfortunately that game is all german langauge, and it has very old graphics - non-textured filled vector graphics - and it was never completed, so I think it won't be a good example in this context.) Monsters that are able to move and items that can be dropped somwhere need special treatment. Either they disappear if the player left an area and reenters it, becuase the area will be regenerated by the algorithm, or the generated area must be modified after creation by a change list that was persistently stored when the player left the area. If a player wanders around lots, the game must save lots of those change lists, and finally the storeage space will limit the worlds size - without saving the differences there is no limit on the world size, becuase the RNG will happily generate new areas for all seeds. Well, in my implementation the seed is only a 32 bit number. That means at most 2**32-1 different locations can exits in the world. This is probaly big but not endless as I proposed - but will the player regognize 'twin' locations in sucha big world? Maybe he'll not even ever encounter the twin. > By the way, it's "seamless", not "seemless". Thanks! > -Jesse c.u. Hajo