Java-Gaming.org    
Featured games (79)
games approved by the League of Dukes
Games in Showcase (476)
Games in Android Showcase (106)
games submitted by our members
Games in WIP (530)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  Seeded Generated Random Maps  (Read 3318 times)
0 Members and 1 Guest are viewing this topic.
Offline Sanxion

Junior Member




Java games rock!


« Posted 2005-03-02 06:32:07 »

I have a client - server situation where I need to generate maps. Rather than sending the entire map to the client I would simply like to send a set of numbers. The client would use these numbers to generate an identical map.

I need an aglorithm that does not need to generate the entire map before I can use it. I need a simple function that only takes a location, e.g.

getTerrain(x,y);
getVegetation(x,y); // would return an integer representing a plant

I need some help, as I don't know where to start. Can this be done?
Offline Hansdampf

Senior Member


Projects: 3


too offending?


« Reply #1 - Posted 2005-03-02 06:51:57 »

you could use Perlin Noise
http://freespace.virgin.net/hugo.elias/models/m_perlin.htm

I use it for many things like terrain generation, movement paths, textures,...
You need just a few numbers to generate a mostly endless map
Smiley

lots of sillystupid games: http://www.emaggame.com
Offline Sanxion

Junior Member




Java games rock!


« Reply #2 - Posted 2005-03-02 07:18:06 »

I looked at the article and I think I can use the 1 dimensional and 2 dimensional noise he is talking about. Just a small routine question. Is there a Java Perlin Class? I do not want to re-invent the wheel if it is available by a better programmer than myself.  Smiley
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline Hansdampf

Senior Member


Projects: 3


too offending?


« Reply #3 - Posted 2005-03-02 07:35:29 »

http://potatoland.com/blog/text/meander/PerlinNoise.java

lots of sillystupid games: http://www.emaggame.com
Offline Sanxion

Junior Member




Java games rock!


« Reply #4 - Posted 2005-03-02 19:36:14 »

I went to this site:
http://freespace.virgin.net/hugo.elias/models/m_perlin.htm

And implemented a 2D noise function:
     public static double intNoise2d(int x, int y){
           int n = x + y * 57;
           n = n << 13 ^ n;
         return ( 1.0 - ( (n * (n * n * 15731 + 789221) + 1376312589) & 0x7fffffff) / 1073741824.0);  
     }


This gives me values between -1 and 1, which is enough for me. I can generate terrain and trees etc. based on the numbers it gives me.

My question is, how do I seed it? Now it will give me the exactly same map each time.  Grin
Offline Hansdampf

Senior Member


Projects: 3


too offending?


« Reply #5 - Posted 2005-03-03 04:27:54 »

just vary the numbers...
- make an offset
1  
2  
3  
4  
5  
6  
7  
 public static double intNoise2d(int x, int y){
  x+=100000;
 y+=evenmore
int n = x + y * 57;
  n = n << 13 ^ n;
     return ( 1.0 - ( (n * (n * n * 15731 + 789221) + 1376312589) & 0x7fffffff) / 1073741824.0);  
 }


or
- change the 57 to a bigger prime
- change the numbers in the brackets (15731 to another prime)
not very difficult   Wink

lots of sillystupid games: http://www.emaggame.com
Offline appel

JGO Wizard


Medals: 50
Projects: 4


I always win!


« Reply #6 - Posted 2005-12-19 15:25:02 »

This might be very interesting, especially for the 4k java competition.

You could skip defining map data in some text file, and simply define seeds for the levels/maps.

Check out the 4K competition @ www.java4k.com
Check out GAMADU (my own site) @ http://gamadu.com/
Pages: [1]
  ignore  |  Print  
 
 
You cannot reply to this message, because it is very, very old.

 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

pw (13 views)
2014-07-24 01:59:36

Riven (11 views)
2014-07-23 21:16:32

Riven (12 views)
2014-07-23 21:07:15

Riven (13 views)
2014-07-23 20:56:16

ctomni231 (43 views)
2014-07-18 06:55:21

Zero Volt (38 views)
2014-07-17 23:47:54

danieldean (32 views)
2014-07-17 23:41:23

MustardPeter (34 views)
2014-07-16 23:30:00

Cero (50 views)
2014-07-16 00:42:17

Riven (50 views)
2014-07-14 18:02:53
HotSpot Options
by dleskov
2014-07-08 03:59:08

Java and Game Development Tutorials
by SwordsMiner
2014-06-14 00:58:24

Java and Game Development Tutorials
by SwordsMiner
2014-06-14 00:47:22

How do I start Java Game Development?
by ra4king
2014-05-17 11:13:37

HotSpot Options
by Roquen
2014-05-15 09:59:54

HotSpot Options
by Roquen
2014-05-06 15:03:10

Escape Analysis
by Roquen
2014-04-29 22:16:43

Experimental Toys
by Roquen
2014-04-28 13:24:22
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!