•      Sign In
• Create Account

Need scary sound effects or creepy audio loops for your next horror-themed game? Check out Highscore Vol.3 - The Horror Edition in our marketplace. 50 sounds and 10 loops for only \$9.99!

### #ActualDan Violet Sagmiller

Posted 18 April 2013 - 09:04 AM

I have a random map generator, that essentially uses the X/Y location of the tile as the seed to identify its tile type.  (infinite terrain without needing to save it)

However, its too random.  the terrain is peppered with any terrain type.  I would like it to be more splotchy.

What I was planning, was to divide it into regions (like x >> 4, y >> 4) of 16x16 to increase the likely hood of a particular type, but then I end up with squares.  any thoughts?

Here is the code I use:

    public static int PickANumber0ThoughN(int seed, int x, int y, int range)
{
uint hash = (uint)seed;
hash ^= (uint)x;
hash *= 0x51d7348d;
hash ^= 0x85dbdda2;
hash = (hash << 16) ^ (hash >> 16);
hash *= 0x7588f287;
hash ^= (uint)y;
hash *= 0x487a5559;
hash ^= 0x64887219;
hash = (hash << 16) ^ (hash >> 16);
hash *= 0x63288691;
return (int)(hash % range);
}
int tileTypeId = PickANumber0ThoughN(playerid, tileX, tileY, TileTypes.Length) - returns a seemingly random tile, that is the same every time the method is called.  I'm considering ways. to improve that to make larger blocks of random code, without adding much cost here.  Any ideas? I'm not opposed to using polar coordinates,

### #2Dan Violet Sagmiller

Posted 18 April 2013 - 09:03 AM

I have a random map generator, that essentially uses the X/Y location of the tile as the seed to identify its tile type.  (infinite terrain without needing to save it)

However, its too random.  the terrain is peppered with any terrain type.  I would like it to be more splotchy.

What I was planning, was to divide it into regions (like x >> 4, y >> 4) of 16, but then I end up with squares.  any thoughts?

Here is the code I use:

    public static int PickANumber0ThoughN(int seed, int x, int y, int range)
{
uint hash = (uint)seed;
hash ^= (uint)x;
hash *= 0x51d7348d;
hash ^= 0x85dbdda2;
hash = (hash << 16) ^ (hash >> 16);
hash *= 0x7588f287;
hash ^= (uint)y;
hash *= 0x487a5559;
hash ^= 0x64887219;
hash = (hash << 16) ^ (hash >> 16);
hash *= 0x63288691;
return (int)(hash % range);
}
int tileTypeId = PickANumber0ThoughN(playerid, tileX, tileY, TileTypes.Length) - returns a seemingly random tile, that is the same every time the method is called.  I'm considering ways. to improve that to make larger blocks of random code, without adding much cost here.  Any ideas? I'm not opposed to using polar coordinates,

### #1Dan Violet Sagmiller

Posted 18 April 2013 - 09:02 AM

I have a random map generator, that essentially uses the X/Y location of the tile as the seed to identify its tile type.  (infinite terrain without needing to save it)

However, its too random.  the terrain is peppered with any terrain type.  But I would like it to be more splotchy.

What I was planning, was to divide it into regions (like x >> 4, y >> 4) of 16, but then I end up with squares.  any thoughts?

Here is the code I use:

    public static int PickANumber0ThoughN(int seed, int x, int y, int range)
{
uint hash = (uint)seed;
hash ^= (uint)x;
hash *= 0x51d7348d;
hash ^= 0x85dbdda2;
hash = (hash << 16) ^ (hash >> 16);
hash *= 0x7588f287;
hash ^= (uint)y;
hash *= 0x487a5559;
hash ^= 0x64887219;
hash = (hash << 16) ^ (hash >> 16);
hash *= 0x63288691;
return (int)(hash % range);
}
int tileTypeId = PickANumber0ThoughN(playerid, tileX, tileY, TileTypes.Length) - returns a seemingly random tile, that is the same every time the method is called.  I'm considering ways. to improve that to make larger blocks of random code, without adding much cost here.  Any ideas? I'm not opposed to using polar coordinates,

PARTNERS