This is a read-only archive of the old Scratch 1.x Forums.
Try searching the current Scratch discussion forums.

#1 2012-10-23 12:12:07

elfin8er
Scratcher
Registered: 2012-01-15
Posts: 1000+

Minecraft Text Based Game [Help With World Generation]

I am not very good with world generation. Right now, I'm trying to make a minecraft text based game. I want it to be as close to the real thing as possible. The thing I am finding the hardest right now, is random world generation. I would like the world to be infinite but I have no clue how to go about it.

What I tried
First I had several lists (one for each block) that would keep track of how many blocks there were at each coordinate. I had x.dirt, y.dirt, x.stone, y.stone, ect. When the player got to new coordinates, it would pick a random number and insert that into x.dirt, y.dirt, x.stone, and y.stone. It would then add the numbers together, and base the generation off of that. There are two problems with doing it that way.

1. Generation isn't as it would be in real life
2. I can't generate random numbers. This means that the player can't go south from spawn, and makes the world "ilinfinate"


http://i1340.photobucket.com/albums/o723/stevetheipad/goldlittlesig.png

Offline

 

#2 2012-10-23 22:55:58

SOScratch
Scratcher
Registered: 2010-02-01
Posts: 100+

Re: Minecraft Text Based Game [Help With World Generation]

You would have to script a way to make blocks appear in random orders and not overlap, but also factor in how deep the block has to be.

I cannot show you because that would take hours and I cannot include all that in a forums post and if I did it in a Scratch project, I would probably be in the top-viewed right now.

But there is not much you can do with Scratch on that, unless you somehow hack/find a way to compress everything to do that or do it on another game creator.


-SOScratch
Scratch On!

Offline

 

#3 2012-10-23 23:01:02

elfin8er
Scratcher
Registered: 2012-01-15
Posts: 1000+

Re: Minecraft Text Based Game [Help With World Generation]

SOScratch wrote:

You would have to script a way to make blocks appear in random orders and not overlap, but also factor in how deep the block has to be.

I cannot show you because that would take hours and I cannot include all that in a forums post and if I did it in a Scratch project, I would probably be in the top-viewed right now.

But there is not much you can do with Scratch on that, unless you somehow hack/find a way to compress everything to do that or do it on another game creator.

You mean because the script would be too big? Even for just a text based game with no graphics or anything?

I've seen it done in javascript. I don't know javascript, but maybe I can take a look at the code and try and make sense of it. It's worth a try, and maybe something will come to me.


http://i1340.photobucket.com/albums/o723/stevetheipad/goldlittlesig.png

Offline

 

#4 2012-10-25 02:40:51

elfin8er
Scratcher
Registered: 2012-01-15
Posts: 1000+

Re: Minecraft Text Based Game [Help With World Generation]

bump


http://i1340.photobucket.com/albums/o723/stevetheipad/goldlittlesig.png

Offline

 

#5 2012-10-25 05:56:19

Maki-Tak
Scratcher
Registered: 2008-03-10
Posts: 100+

Re: Minecraft Text Based Game [Help With World Generation]

I'm not sure what you're trying to describe here. Firstly, is the world scrolling?
There's a couple of simple minecraft terrain generators on scratch already. What you are suggesting is a step further from that. I think lists is definitely the way to go.


http://i.cubeupload.com/zZE0XJ.png

Offline

 

#6 2012-10-25 10:48:46

elfin8er
Scratcher
Registered: 2012-01-15
Posts: 1000+

Re: Minecraft Text Based Game [Help With World Generation]

Maki-Tak wrote:

I'm not sure what you're trying to describe here. Firstly, is the world scrolling?
There's a couple of simple minecraft terrain generators on scratch already. What you are suggesting is a step further from that. I think lists is definitely the way to go.

Yea, I want a scrolling terrain generator, but it's going to be a text based game. No images. I don't think there are any good scrolling random terrain generators.


http://i1340.photobucket.com/albums/o723/stevetheipad/goldlittlesig.png

Offline

 

#7 2012-10-30 19:58:07

MoreGamesNow
Scratcher
Registered: 2009-10-12
Posts: 1000+

Re: Minecraft Text Based Game [Help With World Generation]

You'll probably want to look into interpolation.  Interpolation is taking a set of points and finding what the points between them are.

An example of very simple interpolation is this:
http://i50.tinypic.com/2qnnk42.gif

An example of more natural and terrain-looking interpolation could be this:
http://i50.tinypic.com/z4igm.gif

Essentially, you'll pick a few random points (or let the computer pick them), and let the computer connect them with calculated points.  There are a number of ways to interpolate.  The one I am most familiar with that yields fairly good is something like this:

the height (H) of a point is equal to the height of the points around it, each weighted by the inverse of its distance to the point, squared.  In other words, if you have two points (point A and point B), the point somewhere in the middle is equal to:
(((height of A)/(distance to point A)^2)+((height of B)/(distance to point B)))/((1/(distance to point A)^2)+(1/(distance to point B)^2))

In other words, divide the height of A by its distance, squared, to the point you want to find, and do the same for all other points and their respective distances.  Then divide the resulting number by the sum of the distances squared.  Broken into two parts:

(((height of A)/(distance to point A)^2)+((height of B)/(distance to point B))) = x
height you want = x / ((1/(distance to point A)^2)+(1/(distance to point B)^2))

An actual application of this technique (so you can see the result) is actually part of a project I just posted here.


http://images2.layoutsparks.com/1/218929/rubiks-cube-animated-rotating.gif
"Cogito ergo sum" --  I think, therefore I am

Offline

 

Board footer