[Boards: 3 / a / aco / adv / an / asp / b / biz / c / cgl / ck / cm / co / d / diy / e / fa / fit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mu / n / news / o / out / p / po / pol / qa / r / r9k / s / s4s / sci / soc / sp / t / tg / toy / trash / trv / tv / u / v / vg / vp / vr / w / wg / wsg / wsr / x / y ] [Home]
4chanarchives logo
Quick question /g/, Whats a good way to 'group' random
Images are sometimes not shown due to bandwidth/network limitations. Refreshing the page usually helps.

You are currently reading a thread in /g/ - Technology

Thread replies: 21
Thread images: 1
File: land-water0.5.png (319 KB, 1436x705) Image search: [Google]
land-water0.5.png
319 KB, 1436x705
Quick question /g/,

Whats a good way to 'group' random objects together?
>>
Put em up yer pooper
>>
>>51573240
Explain your pic.
>>
>>51573288

I want to create a grid with x by x cells/rectangles, a certain percentage should be land, the other water.

in the left pic blue/brown rectangles are getting generated if math.random <0.5

I want land and water to group together while keeping the 50/50 ratio
>>
Quadtrees are good for indexing items in a 2d space, maybe that's what you were looking for.
>>
>>51573307
Adapt this for pixels instead of polygons:
http://www-cs-students.stanford.edu/~amitp/game-programming/polygon-map-generation/
>>
>>51573307
>get a 2d noise function
>cut it on a grid
>set thresholds for mountain/hills/plains/beach/water based on the grayscale median value of the single cell
>???
There's your map.
>>
>>51573307
See this: http://www-cs-students.stanford.edu/~amitp/game-programming/polygon-map-generation/
>>
>>51573307
You want to look at the Dijkstra algo.

You compare each cell and if your cell is surrounded by sand, you can put grass cells into the center...

I think the hardest point is to actually create an algorithm that provides big surfaces, I wouldn't go that far and just randomize the placements of each block...
>>
>>51573354
>>51573374
lel
>>
>>51573307
Look up Perlin Noise.
>>
Thanks guys!
>>
>>51573307
>>51573379
Oh shit, I actually read that post too late, you can get each pixel and the per pixel color value, based on those outputs, you will be able to place/replace it with a specific color/pixel
>>
>>51573240
k nearest neighbor. Often written as KNN. Find a free online course on machine learning, or even just some tutorials.
>>
google k means
>>
k-means
>>
For 2d just generate noise, like diamond square or perlin noise.

For 3d terrain generation with overhangs and shit, you can use 3d noise but for each elevation lower value, so that higher elevations is mostly air and lower elevations is mostly solid.
>>
>>51573240
You're not providing enough information fa.m

Probably a hashtable tb.h
Divide your group in smaller groups. Hash them.
>>
>>51573288
>minecraft
>>
>>51575759
You got any good articles on this (especially with respect to overhangs-problem)?.. Just setting a lower threshold for arbitrary elevation-levels could create floating islands and such, right (which is uwanted)?
>>
>>51575885

Yes it would, you would have to implement some type of post processing algorithm which would detect islands and remove them.
Thread replies: 21
Thread images: 1

banner
banner
[Boards: 3 / a / aco / adv / an / asp / b / biz / c / cgl / ck / cm / co / d / diy / e / fa / fit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mu / n / news / o / out / p / po / pol / qa / r / r9k / s / s4s / sci / soc / sp / t / tg / toy / trash / trv / tv / u / v / vg / vp / vr / w / wg / wsg / wsr / x / y] [Home]

All trademarks and copyrights on this page are owned by their respective parties. Images uploaded are the responsibility of the Poster. Comments are owned by the Poster.
If a post contains personal/copyrighted/illegal content you can contact me at [email protected] with that post and thread number and it will be removed as soon as possible.
DMCA Content Takedown via dmca.com
All images are hosted on imgur.com, send takedown notices to them.
This is a 4chan archive - all of the content originated from them. If you need IP information for a Poster - you need to contact them. This website shows only archived content.