Staredit Network

Staredit Network -> Computers and Technical -> errr...i need an algorithm
Report, edit, etc...Posted by Zeratul_101 on 2007-01-01 at 12:59:29
essentially, i am gonig to have an arena(represented by a matrix aka multidimensional array) composed of land and water. what i need is an algorithm that makes all of the land connected and guarantees that at least 70% of the total area is land.

this is probably really easy, but i am a programming noob pinch.gif
Report, edit, etc...Posted by Doodle77(MM) on 2007-01-01 at 13:51:20
Does the land have to be random?
Report, edit, etc...Posted by AFL-InuYasha on 2007-01-01 at 14:08:29
One way that I would do it would be to create "water seeds" that expand out then check if the land is connected everywhere and if not, find the closest points on two seperate land masses and connect them. By the way, what language?
Report, edit, etc...Posted by Doodle77(MM) on 2007-01-01 at 14:19:41
I would do the opposite, and have a 'land seed', so that i didnt have to check to see if all the land was connected
Report, edit, etc...Posted by Zeratul_101 on 2007-01-01 at 15:04:44
java(no language bashing tongue.gif, its for school)

i am creating the 'arena' from scratch so i figured i would use something similiar to a random maze algorithm(i can't use that because i don't want skinny paths).

yes, the land should be random.
Report, edit, etc...Posted by DiscipleOfAdun on 2007-01-01 at 17:55:20
I agree with the land seeding. Start out with all water, add a random point for land. Then, connect all the land. Then, check the percentage of land(if it isn't already connected). Repeat until you have 70% land. If you need it to be from 70 - 100, just use another random number for the percentage.
Report, edit, etc...Posted by green_meklar on 2007-01-01 at 19:30:42
QUOTE
java(no language bashing tongue.gif, its for school)

Tell you what, there are any elitists around who want to pwn pr0gr4mm1ng n00bz w/ their l33t $k1llz, leave off poor Zeratul_101 here and attack me instead. I love programming, but knowing only Excel 4.0, TI-Basic and a little Javascript I'm sure I'd be very satisfying as some worthless scripter dirt for you guys to insult and feel superior to.
Report, edit, etc...Posted by Centreri on 2007-01-01 at 20:11:00
Nuvzz0rz, Ti-Basic is 4 t2h n00bz0rz. Overall, I agree. It's easier to start with default and put what you need later. Connecting it, of course.
Report, edit, etc...Posted by SI on 2007-01-01 at 22:21:01
go with one or more land seeds which expand randomly until n% is covered, should be fairly simple to do
Report, edit, etc...Posted by Zeratul_101 on 2007-01-01 at 23:04:57
well, the thing is, i don't want to end up getting stringy 1 unit-wide strips of land. how certain is it that this wont happen?
Report, edit, etc...Posted by CheeZe on 2007-01-01 at 23:38:47
Make sure the size of the matrix is smaller than the needed amount for 70% land. For example, if you want a land with 7 squares, make the lengths 3.
Report, edit, etc...Posted by Zeratul_101 on 2007-01-03 at 18:39:48
okay, the land-seed idea works, not as random as i would like it, but its good enough. thanks guys smile.gif
Next Page (1)