Bay 12 Games Forum

Please login or register.

Login with username, password and session length
Advanced search  
Pages: 1 ... 105 106 [107] 108 109 ... 796

Author Topic: if self.isCoder(): post() #Programming Thread  (Read 882782 times)

Max White

  • Bay Watcher
  • Still not hollowed!
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #1590 on: February 18, 2012, 01:47:18 am »

So, anybody ever really done a lot with world gen before? I have a plan down for how to construct a nice looking world, but always nice to see if anybody has a second opinion.

So firstly I use 2d perlin noise to get a height map, pretty standard so far.

Then I use the function t = a - b|Y|, where the centre of the map is (0,0) to get a line for temperature where it is hotter at the equator, and cooler at the poles. I then super impose noise map to get variance in temperature from east to west, and make it look a lot more natural.
Then I lower the temperature at each point inversely relative to to the height with a minimum of sea level, so beaches seem relatively tropical, while the top of large mountains are very cold.

Then I need rainfall. I start with r = a - b(t - c)^2 where r is rainfall, a is the maximum rainfall, t is temperature and c is the average rainfall. This should give me a sort of bell curve, although with very sharp ends, I will need to work on that, but the point is that the highest rain would be in places with moderate temperature, while the very hot and very cold would be lacking rain. Would that be right, lowering rain in cold areas?
Anyway, then, once again, impose a noise function to get variance.
I'm thinking maybe then impose a function so that higher elevation = less rainfall. Not sure.

And from that I can figure out the specific biome from temperature and rainfall. Sounds good, anybody?

MadocComadrin

  • Bay Watcher
  • A mysterious laboratory goblin!
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #1591 on: February 18, 2012, 01:59:03 am »

If you're doing seasons as well, you may want to lower the range of temperatures possible around large bodies of water, as they cause the climate around them to be more moderate. Eg, for two areas of the same elevation and latitude, the one next to a lrage body of water (lake or ocean) will be cooler in the summer and warmer in the winter than the one surrounded by land.
Logged

Willfor

  • Bay Watcher
  • The great magmaman adventurer. I do it for hugs.
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #1592 on: February 18, 2012, 10:41:22 am »

Well, there's always this to consider. Noise based continents might look somewhat natural to the untrained eye, but as soon as you realise that mountains should rarely form in the centre of a landmass it ruins the effect. They should form at the edges of a plate. If there's some way you can work with this information, and get around this problem, it would put you a step ahead of most world builders.

Logged
In the wells of livestock vans with shells and garden sands /
Iron mixed with oxygen as per the laws of chemistry and chance /
A shape was roughly human, it was only roughly human /
Apparition eyes / Apparition eyes / Knock, apparition, knock / Eyes, apparition eyes /

Fayrik

  • Bay Watcher
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #1593 on: February 18, 2012, 01:14:52 pm »

This is the answer to my prayers, I swear.
I've been meaning to ask about some of the basics of world gen for a few days, and then suddenly this pops up.

This reddit link is gunna keep me busy for the next few days, at least. Thanks guys!
Logged
So THIS is how migrations start.
"Hey, dude, there's this crazy bastard digging in the ground for stuff. Let's go watch."

Nadaka

  • Bay Watcher
    • View Profile
    • http://www.nadaka.us
Re: if self.isCoder(): post() #Programming Thread
« Reply #1594 on: February 18, 2012, 01:21:30 pm »

Noise works just fine if you are not trying to mimic massive continents.
Logged
Take me out to the black, tell them I ain't comin' back...
I don't care cause I'm still free, you can't take the sky from me...

I turned myself into a monster, to fight against the monsters of the world.

Virex

  • Bay Watcher
  • Subjects interest attracted. Annalyses pending...
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #1595 on: February 18, 2012, 01:26:46 pm »

Well, there's always this to consider. Noise based continents might look somewhat natural to the untrained eye, but as soon as you realise that mountains should rarely form in the centre of a landmass it ruins the effect. They should form at the edges of a plate. If there's some way you can work with this information, and get around this problem, it would put you a step ahead of most world builders.
I've done something similar in Teragen long ago, but no doubt it'd work better in a real programming language (the mountain ranges worked pretty well, but procedural rivers required some ugly hacks). The idea is that you make plates using a voronoi noise algorithm, which yields something like this. Now, if you map the image (x' y') coordinates to the worlds (x y) coordinates using a very smooth perlin functions you get wavy plates. Next, you use another perlin noise function ranging from -1 to 1 to make through or mountains out of the plate boundaries. Next, you give each plate a mean height and interpolate between the edge values and the center value. By varying the steepness of the interpolation function you can get different kinds of mountain ranges, from broad to narrow and steep.
« Last Edit: February 18, 2012, 01:28:55 pm by Virex »
Logged

MorleyDev

  • Bay Watcher
  • "It is not enough for it to just work."
    • View Profile
    • MorleyDev
Re: if self.isCoder(): post() #Programming Thread
« Reply #1596 on: February 18, 2012, 03:07:52 pm »

Does the C++11 std::thread really not provide any kind of "timed join" functionality like boost::thread does? :S That's...what? I mean I know it could easily be simulated with a conditional variable as they have a timed wait, but that just seems an odd thing to miss out...
Logged

Mego

  • Bay Watcher
  • [PREFSTRING:MADNESS]
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #1597 on: February 18, 2012, 03:13:18 pm »

Does the C++11 std::thread really not provide any kind of "timed join" functionality like boost::thread does? :S That's...what? I mean I know it could easily be simulated with a conditional variable as they have a timed wait, but that just seems an odd thing to miss out...

It should, since I'm pretty sure std::thread is just boost::thread, brought into the std namespace.

MorleyDev

  • Bay Watcher
  • "It is not enough for it to just work."
    • View Profile
    • MorleyDev
Re: if self.isCoder(): post() #Programming Thread
« Reply #1598 on: February 18, 2012, 05:41:22 pm »

There are some differences. The std has chrono instead of boost's datetime library so uses that for timings. And no documentation for std::thread has any mention of a timed join anywhere. Just join().
Logged

Max White

  • Bay Watcher
  • Still not hollowed!
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #1599 on: February 18, 2012, 05:44:04 pm »

Well, there's always this to consider. Noise based continents might look somewhat natural to the untrained eye, but as soon as you realise that mountains should rarely form in the centre of a landmass it ruins the effect. They should form at the edges of a plate. If there's some way you can work with this information, and get around this problem, it would put you a step ahead of most world builders.
Well assuming I keep each step of world gen atomic, I can easily switch out the noise for something else. Although looking at every game in all reality, I think noise will game for a decent place holder...
Still something to think about though!

Bauglir

  • Bay Watcher
  • Let us make Good
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #1600 on: February 19, 2012, 03:54:47 am »

From the happy thread.

Heck no.
If you know how many elements you are going to need before you need them, an array is like a bajillion times more efficient.

What the fuck are we doing here in the happy thread? Go to the programming thrread and think about what you have done.
I don't so much know how many elements I'm going to need in advance as I was able to pull shenanigans to get the program to generate that number based on user input. I had guessed from your mention of it that lists would save the step of doing so, but I know basically nothing about any concept I haven't actually studied before, and I have no memory of lists.

Basically the code builds an array to hold the result of each die roll (a number specified by the user), sums the highest X values (where X is a user-specified number), subtracts that result from a target number (specified by the user, can you spot a pattern here >______>), and then stores either a 0 or a 1 in a second array based on which of those two numbers was larger, and does that a number of times specified by guess who. Then it figures out the percentage of 1s and is done.
Logged
In the days when Sussman was a novice, Minsky once came to him as he sat hacking at the PDP-6.
“What are you doing?”, asked Minsky. “I am training a randomly wired neural net to play Tic-Tac-Toe” Sussman replied. “Why is the net wired randomly?”, asked Minsky. “I do not want it to have any preconceptions of how to play”, Sussman said.
Minsky then shut his eyes. “Why do you close your eyes?”, Sussman asked his teacher.
“So that the room will be empty.”
At that moment, Sussman was enlightened.

Max White

  • Bay Watcher
  • Still not hollowed!
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #1601 on: February 19, 2012, 04:01:31 am »

Ok stop, what language are you working in?

Bauglir

  • Bay Watcher
  • Let us make Good
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #1602 on: February 19, 2012, 04:14:20 am »

Java. Only one I'm even vaguely proficient with, and given that I've forgotten basically all the syntax, that's not very. Did I fail to mention that back in the Happy thread? If so, I suck. Sorry about that.
Logged
In the days when Sussman was a novice, Minsky once came to him as he sat hacking at the PDP-6.
“What are you doing?”, asked Minsky. “I am training a randomly wired neural net to play Tic-Tac-Toe” Sussman replied. “Why is the net wired randomly?”, asked Minsky. “I do not want it to have any preconceptions of how to play”, Sussman said.
Minsky then shut his eyes. “Why do you close your eyes?”, Sussman asked his teacher.
“So that the room will be empty.”
At that moment, Sussman was enlightened.

Max White

  • Bay Watcher
  • Still not hollowed!
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #1603 on: February 19, 2012, 04:23:38 am »

Well ok, we have three options. The first is the array. This is the fastest, and least flexible, I think you know how to make this one work. Next we have two types of lists, ArrayList, and LinkedList. Each have their pros and cons.
ArrayLists are fast to get data out of, and has less overhead.
LinkedLists are fast to get data into, and has more overhead.

But anyway, you can use them both in a similar way... I'm going to post some code now, and I want you to tell me if you understand it.
Code: [Select]
import java.util.LinkedList;

public class main {
public static void main(String[] args) {
LinkedList<String> names = new LinkedList<String>();
names.add("Adam");
names.add("Brian");
names.add("Courtney");
names.add("Dirk");

for(String s : names)
{
System.out.println(s);
}
}
}

Do you need that explained?

Bauglir

  • Bay Watcher
  • Let us make Good
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #1604 on: February 19, 2012, 04:44:00 am »

The construction of the list makes sense (never seen any of the actual commands before, but like most things in Java it's kind of "Oh, yeah, that makes sense, I just wouldn't have been able to figure it out without seeing it"). I don't actually understand the

Code: [Select]
for(String s : names)
bit, though. Only syntax they ever put us through was

Code: [Select]
for(initial state; termination state; change after each iteration)
If that format makes any sense.
Logged
In the days when Sussman was a novice, Minsky once came to him as he sat hacking at the PDP-6.
“What are you doing?”, asked Minsky. “I am training a randomly wired neural net to play Tic-Tac-Toe” Sussman replied. “Why is the net wired randomly?”, asked Minsky. “I do not want it to have any preconceptions of how to play”, Sussman said.
Minsky then shut his eyes. “Why do you close your eyes?”, Sussman asked his teacher.
“So that the room will be empty.”
At that moment, Sussman was enlightened.
Pages: 1 ... 105 106 [107] 108 109 ... 796