The professional, friendly Java community. 21,500 members and growing!

The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.

Okay Here Goes...World and Map Generation. ##Mods: Is this in the right place?##

tl;dr version: I'm a fairly new-ish hobbiest java programmer teaching himself how to code, please don't hold "bad" coding practices against me, I did the best I knew how with what the google had to offer. =) This is my first *true post* on the forums. Thanks!

I know there must be an easier way to do this, though I can't follow along with the examples I see on /the/ Google, so I attempted to write my own, and I have something now that works, albeit very shaky.

So here it is. I'm trying to write the World and Map generator for a game. There is as of yet no real game, and just an Island Generator, and its shaky at best. It likes to randomly go out of bounds.

MapBuilder.java <-This class is responsible for managing all of the other builders, and telling them when to run. So far only Island Builder is Implemented, and assembling the map based on their output.

Cell.java <-This class describes an individual Cell. Cells can be one of several terrain types and have several properties including passable, swimmable, buildable, value etc. The only implemented terrain types currently are Shore, Ocean, and Grassland.

A zipped file of my source will be included with this post, as well as the eclipse project data.

My question here is this, is there an easier/"better" way to code this that will make it a) more stable and b)more predictable, although still essentially random?

I've learned a lot to get as far as I have, however I still don't know enough to go further much further along these lines, so I would greatly appreciate somebody being able to take a quick peek at my code and see if it can be fixed or if it should just be scratched all together.

Re: Okay Here Goes...World and Map Generation.

Hi rooster5105. Welcome to Java Programming Forums

A very common and simple algotihm for generating, random but can also be controlled to an extent 3D terrain, obviously it is easily adaptable to 2D also is called the Diamond-Square Algorithm. It's uses a mid-point technique to slowely make smaller and smaller alterations to a terrain, which can be modelling initially to give the algorithm guidance as to what you want, or completely left to its own devices.