Retrieve random point inside regions of Perlin noise?

To be frank—I’m not entirely certain this is the correct place to post a question like this. Should you (some random moderator) feel this is the wrong place, feel free to move it! ::slight_smile:

Let’s say we’re procedurally generating an infinite level as we walk around using the following:

if(perlinNoise.noise2(x / scale, y / scale) > .2)
	makeTileSomethingInteresting(x, y);

Based on the Perlin noise, the world will place in interesting tiles for us! In fact, it’s going to generate a world that features certain “chunks”—or regions—that will have that interesting looking tile.

Assume we wanted to procedurally generate in one—and only one—nasty looking tile somewhere inside every single one of the regions generated by the noise. Somehow, we’d need to know what those tiles are on the fly, as the world is infinite. :cranky:

I’ve been messing about with this for a while—and honestly—I have no clue as to how this might be solved without using some sort of flood fill to make sure an area always has the same random seed for the position of the random point.

Perhaps someone can come up with a suggestion?

Should you have a good answer as to how one might achieve this, do leave a post! If your answer is fully functional, you’ll be featured in the credits of my upcoming game! :point:

Use floodfill indeed. And drop the requirement that your game is supposed to be infinite. Not a single gamer cares about infinity :slight_smile:

Try to make a relatively small world, and make a fun, functioning game - that is hard enough!

You’re ruining my moments of “infinity” bliss Riven. I like infinity! :frowning:

On the other hand, what you’re saying is very much true! This game, however, features millions of extremely large planets and sort of requires infinity in a way. That’s enough spoilers, though! ::slight_smile:

I suppose one could generate a noise with a smaller scale and pray to the Lord that about one of them are inside every larger chunk of noise. It wouldn’t be perfect—but that’s the way game development usually is! :slight_smile:

As a gamer, when I see “infinite” anywhere in a game, it instantly tells me a few things :

  • if it does seem interesting enough to play, it wont last long
  • there’s a high likelihood of IAP to keep people playing a few minutes longer
  • there’s little to no depth or story beyond a premise.

Bottom line, making an infinite game tells me that the maker(s) were too lazy to think up a good story and make an ending… very different from a game where the maps are infinitely variable, if there’s a good story, that = replayability.

Hopefully that doesn’t make me come across like an a-hole…

I’m not sure if I understand the scenario.

Perlin returns [-1…1], and you wish for noise values > 0.2 to be of a certain special type.
A variable number of contiguous tiles generated this way, forming blobs or islands.
On each island, there should be one “special” tile, which I will call the X tile.
Given the goal of “infinite world” it would be good to be able to identify the X tile procedure based upon the region itself, rather than maintaining some sort of list.

It occurs to me that some of the islands will be quite large, and some will be as small as a single tile. I’m thinking you will want a minimum number of tiles to be fulfilled before you include the X tile, e.g., there must be at least 10 tiles in the island if there is going to also be an X tile.

One could work with the geometry of the shape itself: using a floodfill algorithm to determine the complete extent of the island when you come across it. Then apply a hash function to the shape.

I like the idea of a hash giving 13 possible outcomes. With 13, one could have a “clock” of 12 regions and a central area. Then, place the X tile in the center of the hash-derived sector. Or, if one wants more variety, give the hash more possibilities, and break the island into corresponding sectors.

What would be a good hash? I don’t know. Maybe use the number of tiles in the island, but also add in the number of corners or the side lengths, and then do a mod division? How divide the varied island shapes into sectors? I’d have to think about that, as well. The main requirement is that it is a function of the shape that is found.

Riven and philfrei
I guess flood fill it’s going have to be. :slight_smile:

This does however require saving the world data in order for the whole flood fill business not to affect the game’s performance too much. But this also means towns will have the possibility of having names! Did you hear that? Names! Well, anyhow, there went that beautiful evening of solving things by quick and simple means. :’(

bmanmcfly
These are good points, indeed. I’m going to need to reconsider whether I really want my game world (worlds) to be infinite. :point:

There’s no reason why you cant have the best of both… based on the description, its something like being able to go from world to world where each world is potentially infinite.

Take the approach of the rogue-like games; there is potential for infinite replayability in the sense that each round of the game creates a randomized world where each challenge will be different from the last… so, there’s endless potential, yet, there’s still an overarching goal, sometimes even a story tying things all together.

If all you really WANT is just to have the challenge be “how far can you make it”, then by all means, go ahead and do that. There’s a reason why there are so many variations on the “infinite runner” games, it’s that they get downloads and I’m sure there’s profits to be made.

IMO, and even though you did not ask for my advice on the matter, but I would consider, use the mechanics of the infinite game you want, and then develop the infinite game into a “full” game… that said, you should also keep in mind that I’ve never published a game for sale, and never completed a game that was much more drastically complex than tetris, so, my advice should be taken with as much salt.

By “full”, I’m assuming you mean it should be as complex as a game “should” be? That is, something that isn’t overly repetitive as for gameplay?

The idea is that it shall be some day. :slight_smile:

Sorry, that was somewhat sarcastic…

I did mean in the sense that there would be a story, that has a beginning to an end… which isn’t really a good measure, since even tetris is an “infinite” game (especially if you’re my mom, who managed to play until the game stopped counting up… lvl 25 if memory serves), but it’s still a full game in the more common sense where it’s got a title, menu, options, music, sfx, controls, no game breaking bugs, etc.

Similarly, even though i’m not a fan (but I do still give them a chance once in a while), there are many infinite games that do fit the common description of being a full game.

The way I meant in the earlier, was more in the sense of there’s a beginning, a plot, and an ending… which isn’t really necessary for many types of games anyway.