Bay 12 Games Forum

Please login or register.

Login with username, password and session length
Advanced search  
Pages: 1 ... 250 251 [252] 253 254 ... 796

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

GalenEvil

  • Bay Watcher
    • View Profile
    • Mac-Man Games
Re: if self.isCoder(): post() #Programming Thread
« Reply #3765 on: January 29, 2013, 02:41:40 am »

Skyrunner: Not sure if this applies to you but Perlin noise returns 0 at all integer values. So 0,1,2,3,4,etc will all return integers no matter where they are. While 0.5, 1.5, 2.5 may all return different values. The key is to utilize this to produce a high quality gradient. if you have a map size of say 64 in length, you would use a step size of 1/64 along the perlin gradient. Perlin is generally best used when taken from a 0 to 1 value in any dimension since it avoids needless repetitions and is scalable to act as a 'zoom' level. 1/2 scale {0,0.5,1} in all dimensions would yield similar results to 1/4 scale {0, 0.25, 0.5, 0.75, 1} in all dimensions except with a slightly higher zoom level.

Hope that helps, and that the information is correct :)
Logged
Fun is Fun......Done is Done... or is that Done is !!FUN!!?
Quote from: Mr Frog
Digging's a lot like surgery, see -- you grab the sharp thing and then drive the sharp end of the sharp thing in as hard as you can and then stuff goes flying and then stuff falls out and then there's a big hole and you're done. I kinda wish there was more screaming, but rocks don't hurt so I guess it can't be helped.

Skyrunner

  • Bay Watcher
  • ?!?!
    • View Profile
    • Portfolio
Re: if self.isCoder(): post() #Programming Thread
« Reply #3766 on: January 29, 2013, 03:01:20 am »

... So Perlin noise is assured to return 0 at all integer values?
If that's correct, I can see where my problem is :P
Logged

bay12 lower boards IRC:irc.darkmyst.org @ #bay12lb
"Oh, they never lie. They dissemble, evade, prevaricate, confoud, confuse, distract, obscure, subtly misrepresent and willfully misunderstand with what often appears to be a positively gleeful relish ... but they never lie" -- Look To Windward

GalenEvil

  • Bay Watcher
    • View Profile
    • Mac-Man Games
Re: if self.isCoder(): post() #Programming Thread
« Reply #3767 on: January 29, 2013, 04:19:42 am »

yeah just gotta move between 0 and 1 and all is well :D Simplex is a little more lenient since you can use the integer scale, but for zooming you still have to deal with the partial movements in the 0-1 scale along whatever zoom area/volume/hyperwhatever you are looking at. You can't just say 'i was at 0-1 and now zooming im at 0-20 or whatever, since that will screw up things a bit. Take whatever scale you begin at (perlin being 0-1 nominally and simplex being whatever to whatever) and scale within that range.

Perlin works as a gradient that is always 0 (parallel to the world) at integers. It looks vaguely like a sin/cos wave function since it is deterministic at integers, but gives more interesting results the more dimensions you use. While Perlin noise uses exponentially larger numbers of gradient points the higher dimension that is observed, Simplex noise is therefore faster the higher dimension you are looking at due to the number of points within the simplex defining how fast it runs.

A 2d Simplex uses d+1 points to define its simplex, so for a 2D grid it uses equilateral triangles to define it. For a 3D volume it uses the 4 point tetrahedron. 4D is difficult to visualize, sadly, but follows the same ruleset of N+1 gradient points instead of Perlin's N^2 points ( I think this is correct, has been a few months since I played with Perlin directly so numbers may be a little off).

Hope this information helps :D
Logged
Fun is Fun......Done is Done... or is that Done is !!FUN!!?
Quote from: Mr Frog
Digging's a lot like surgery, see -- you grab the sharp thing and then drive the sharp end of the sharp thing in as hard as you can and then stuff goes flying and then stuff falls out and then there's a big hole and you're done. I kinda wish there was more screaming, but rocks don't hurt so I guess it can't be helped.

Skyrunner

  • Bay Watcher
  • ?!?!
    • View Profile
    • Portfolio
Re: if self.isCoder(): post() #Programming Thread
« Reply #3768 on: January 29, 2013, 04:33:12 am »

I guess I could rotate the points, change the frequncy, or offset by a non-integer.
Logged

bay12 lower boards IRC:irc.darkmyst.org @ #bay12lb
"Oh, they never lie. They dissemble, evade, prevaricate, confoud, confuse, distract, obscure, subtly misrepresent and willfully misunderstand with what often appears to be a positively gleeful relish ... but they never lie" -- Look To Windward

Siquo

  • Bay Watcher
  • Procedurally generated
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #3769 on: January 29, 2013, 04:39:55 am »

You're using C++, right? From working with it for a few days now, I can highly recommend libnoise over trying simplex/perlin yourself.
Logged

This one thread is mine. MIIIIINE!!! And it will remain a happy, friendly, encouraging place, whether you lot like it or not. 
will rena,eme sique to sique sxds-- siquo if sucessufil
(cant spel siqou a. every speling looks wroing (hate this))

Skyrunner

  • Bay Watcher
  • ?!?!
    • View Profile
    • Portfolio
Re: if self.isCoder(): post() #Programming Thread
« Reply #3770 on: January 29, 2013, 05:27:00 am »

I'm using libnoise :D
My project that uses libtcod takes advantage of its built-in generators, but my other projects use libnoise. It's nice.
Logged

bay12 lower boards IRC:irc.darkmyst.org @ #bay12lb
"Oh, they never lie. They dissemble, evade, prevaricate, confoud, confuse, distract, obscure, subtly misrepresent and willfully misunderstand with what often appears to be a positively gleeful relish ... but they never lie" -- Look To Windward

GlyphGryph

  • Bay Watcher
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #3771 on: January 29, 2013, 09:23:48 am »

Though, Python is the same with Java in that you can develop bad practices.  (Like omitting ;'s since they arent required in Python(As far as I remember?))
There's nothing "bad practice" about following the standard syntax of a language.

Eh, if you want to introduce the layman with no intent of doing anything too serious, then a scripting language is a good start. For a first year CS student with a some knowledge of basic programming concepts, you'll want a high-level OOP programming language, like Java, C# or C++.
Err... Java IS a scripting language, isn't it? Like Ruby or Lisp, a LOT of higher level languages are scripting languages, i.e. they can be/are run through an interpreter.
Logged

Mego

  • Bay Watcher
  • [PREFSTRING:MADNESS]
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #3772 on: January 29, 2013, 09:29:31 am »

I managed to succesufully sign up for AP Computer Science the other day, and I have a question-
How easy is Java to learn?
How similar is it to C++?

In my opinion, Java is very easy to learn, but difficult to master. It gives you a lot of slack with concepts, so it's great for introduction to programming. However, it doesn't do so great of a job of weaning you off of those bad practices, so when you move to more complex programming, you run into brick walls frequently. See Stargrasper's rant about Strings; link is in the OP.
Not to steer off his question, but imo scripting languages like Python are much better for an introduction to programming. Though, Python is the same with Java in that you can develop bad practices.  (Like omitting ;'s since they arent required in Python(As far as I remember?))
Though, taken from a different post, the Java and Python are very different:
Code: [Select]
#In python:
name, age = john.summary()

//In Java:
Object[] summary = john.summary();
String name = (String) summary[0];
int age = ((Integer) summary[1]).intValue(); #primitive types require boxing

Nope. Primitive types don't require boxing, at least not in 1.7.

Code: [Select]
Integer a = new Integer(3);
int b = a;
System.out.println(b); // output: 3

But, I'm not talking about bad practices like omitting semicolons. There are plenty of languages that don't use them (BASIC comes to mind, but I prefer not to think of it as an actual language). I'm talking about bad practices like not keeping track of object creation, and creating more objects than necessary. Those kind of things don't affect Java so much with small classes, but with more complex classes, you feel the hurt. And, when you try to move into a language that doesn't have garbage collection standard, you've got to be careful not to leak memory all over the place.

And yes, I agree that scripting languages are better for introductory programming. Most universities still prefer Java, because it takes less effort to teach. And, because of this, APCS students get subjected to the horror that is Java.

Blegh.

Skyrunner

  • Bay Watcher
  • ?!?!
    • View Profile
    • Portfolio
Re: if self.isCoder(): post() #Programming Thread
« Reply #3773 on: January 29, 2013, 10:21:29 am »


Rage.

libnoise's perlin module isn't working for some reason Dx Only uniform gradients are produced.


noise::module::Perlin mapPerlin;
gen.seed(time(0));
boost::random::uniform_int_distribution<> dist(0, numeric_limits<int>::max());
mapPerlin.SetSeed(dist(gen));

//assuming the iterating is done correctly
//rotate_pivot rotates the entire input values around a point by an angle.
x = xcounter / 10;
y = ycounter / 10;
rotate_point(pivot, x, y, angle);
*at(xcounter, ycounter) = mapPerlin.GetValue(x, y, 1.23);


Uniform values. :< Could it be that seeding Perlin is a bad idea?

Used libraries include libnoise, Allegro 5, and boost::random.

I tried changing the frequency, the octave count, the angle its rotated; I tried not rotating it, I tried dividing the x/y by the width and height... DX Nothing helped. Just the identical bars standing in lines. It looks like my generator is just outputting the raw gradients in the cells.
Logged

bay12 lower boards IRC:irc.darkmyst.org @ #bay12lb
"Oh, they never lie. They dissemble, evade, prevaricate, confoud, confuse, distract, obscure, subtly misrepresent and willfully misunderstand with what often appears to be a positively gleeful relish ... but they never lie" -- Look To Windward

Siquo

  • Bay Watcher
  • Procedurally generated
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #3774 on: January 29, 2013, 10:29:10 am »

Are x and y floats? Doing x / 10 might result in an integer, because 10 is an integer.
x / 10.0f might help?
Logged

This one thread is mine. MIIIIINE!!! And it will remain a happy, friendly, encouraging place, whether you lot like it or not. 
will rena,eme sique to sique sxds-- siquo if sucessufil
(cant spel siqou a. every speling looks wroing (hate this))

Skyrunner

  • Bay Watcher
  • ?!?!
    • View Profile
    • Portfolio
Re: if self.isCoder(): post() #Programming Thread
« Reply #3775 on: January 29, 2013, 10:50:35 am »


  al_set_target_bitmap(bitmap);
  al_lock_bitmap(bitmap, al_get_bitmap_format(bitmap), ALLEGRO_LOCK_READWRITE);

  for (int ycounter = 0; ycounter < w; ycounter++)
    for (int xcounter = 0; xcounter < h; xcounter++)
      al_put_pixel(xcounter, ycounter, al_map_rgb( 0, 0, (int)topograph.at(xcounter, ycounter)));

  al_unlock_bitmap(bitmap);


I think the problem is actually in the rendering. :/ Inserting rand() instead of Perlin noise still gives me the exact same result. Is anyone here knowledgeable in Allegro 5? Is the above code right? It seems to be, but... nope. I suspect the al_map_rgb() is the culprit here.
Logged

bay12 lower boards IRC:irc.darkmyst.org @ #bay12lb
"Oh, they never lie. They dissemble, evade, prevaricate, confoud, confuse, distract, obscure, subtly misrepresent and willfully misunderstand with what often appears to be a positively gleeful relish ... but they never lie" -- Look To Windward

MorleyDev

  • Bay Watcher
  • "It is not enough for it to just work."
    • View Profile
    • MorleyDev
Re: if self.isCoder(): post() #Programming Thread
« Reply #3776 on: January 29, 2013, 10:56:32 am »

Err... Java IS a scripting language, isn't it? Like Ruby or Lisp, a LOT of higher level languages are scripting languages, i.e. they can be/are run through an interpreter.

Depends what you call a scripting language. It's not particularly well defined as a term.  If you're gonna include anything that eventually gets compiled to a form that goes through some form of virtual machine then technically no programming language isn't a scripting language.

The usage usually determines if it's a scripting or not, and a language used predominately for scripting is a scripting language. I'd call scripting when the process has a specific job it uses the script to carry out, whilst the JRE too generic and purposeless by itself to match that description.
« Last Edit: January 29, 2013, 02:39:19 pm by MorleyDev »
Logged

Nadaka

  • Bay Watcher
    • View Profile
    • http://www.nadaka.us
Re: if self.isCoder(): post() #Programming Thread
« Reply #3777 on: January 29, 2013, 11:45:23 am »

Java is not at all a scripting language. It is compiled into a binary machine language like any other compiled language. Most of the time, that byte code is run in a virtual machine, but java real machines do exist.
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.

alway

  • Bay Watcher
  • 🏳️‍⚧️
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #3778 on: January 29, 2013, 11:54:14 am »


  al_set_target_bitmap(bitmap);
  al_lock_bitmap(bitmap, al_get_bitmap_format(bitmap), ALLEGRO_LOCK_READWRITE);

  for (int ycounter = 0; ycounter < w; ycounter++)
    for (int xcounter = 0; xcounter < h; xcounter++)
      al_put_pixel(xcounter, ycounter, al_map_rgb( 0, 0, (int)topograph.at(xcounter, ycounter)));

  al_unlock_bitmap(bitmap);


I think the problem is actually in the rendering. :/ Inserting rand() instead of Perlin noise still gives me the exact same result. Is anyone here knowledgeable in Allegro 5? Is the above code right? It seems to be, but... nope. I suspect the al_map_rgb() is the culprit here.
Having never used Allegro 5, the locking/unlocking looks like it's probably correct; it's very similar to DirectX's writing to textures.
I recommend printing out the results of topograph.at(xcounter,ycounter) to see what that is doing. My guess would be that's being somehow set to equal (x%10)/10. Also try setting it with al_map_rgb(rand()%256,rand()%256,rand()%256). That should give a random noise pattern, which should tell you if al_map_rgb is the issue.
Logged

eerr

  • Bay Watcher
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #3779 on: January 29, 2013, 01:00:56 pm »

Java is not at all a scripting language. It is compiled into a binary machine language like any other compiled language. Most of the time, that byte code is run in a virtual machine, but java real machines do exist.

Real Java machines can't update properly due to the nature of the beast. An Os that is never updated specifically for hardware works poorly
Logged
Pages: 1 ... 250 251 [252] 253 254 ... 796