Bay 12 Games Forum

Please login or register.

Login with username, password and session length
Advanced search  
Pages: 1 ... 56 57 [58] 59 60 ... 796

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

Nadaka

  • Bay Watcher
    • View Profile
    • http://www.nadaka.us
Re: if self.isCoder(): post() #Programming Thread
« Reply #855 on: January 24, 2012, 11:50:42 pm »

My plans for learning java opengl and making a video game? SCREWED.

My web app is getting crashes I need to investigate, so its off to c# asp.net land.
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.

Max White

  • Bay Watcher
  • Still not hollowed!
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #856 on: January 24, 2012, 11:52:05 pm »

So, for the library I am working on, it will be able to handle sprite sheets potentially much larger than your standard curses. Meaning you could have tiles for different sorts of weapons, books, scrolls potions and all sorts of things. Think if I ever get to the stage of distribution, I should include a spritesheet that includes some weapons and shit?

My plans for learning java opengl and making a video game? SCREWED.

My web app is getting crashes I need to investigate, so its off to c# asp.net land.
one of us one of us...

Valid_Dark

  • Bay Watcher
  • If you wont let me Dream, I wont let you sleep.
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #857 on: January 25, 2012, 12:42:44 am »

games almost done


you taught me to juggle, but you never taught me to love. -Jugglebot


does anyone have a good random number c++ code snippet?
the one I'm using right now isn't very random.
Logged
There are 10 types of people in this world. Those that understand binary and those that don't


Quote
My milkshake brings all the criminals to justice.

Gatleos

  • Bay Watcher
  • Mournhold... City of Light... City of MAGIC!
    • View Profile
    • Someone Sig This
Re: if self.isCoder(): post() #Programming Thread
« Reply #858 on: January 25, 2012, 03:50:47 am »

does anyone have a good random number c++ code snippet?
the one I'm using right now isn't very random.
Here's a self-contained c++ implementation of the Mersenne Twister RNG.

The readme does a good job of explaining how to use it. Just put it directly in your project.
Logged
Think of it like Sim City, except with rival mayors that seek to destroy your citizens by arming legions of homeless people and sending them to attack you.
Quote from: Moonshadow101
it would be funny to see babies spontaneously combust
Gat HQ (Sigtext)
++U+U++ // ,.,.@UUUUUUUU

Valid_Dark

  • Bay Watcher
  • If you wont let me Dream, I wont let you sleep.
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #859 on: January 25, 2012, 04:12:44 am »

That will do Nicely, thank you
Logged
There are 10 types of people in this world. Those that understand binary and those that don't


Quote
My milkshake brings all the criminals to justice.

Mego

  • Bay Watcher
  • [PREFSTRING:MADNESS]
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #860 on: January 25, 2012, 08:26:38 am »

does anyone have a good random number c++ code snippet?
the one I'm using right now isn't very random.
Here's a self-contained c++ implementation of the Mersenne Twister RNG.

The readme does a good job of explaining how to use it. Just put it directly in your project.

Or, you could, you know, use the Mersenne Twister algorithm that is included with C++11.

nitnatsnoc

  • Bay Watcher
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #861 on: January 25, 2012, 12:43:07 pm »

Woot! Made my first game! Sure it's console only.. and pretty terrible. But by golly it works. Now if only I could figure out how to get it out of the console.
Logged

Virex

  • Bay Watcher
  • Subjects interest attracted. Annalyses pending...
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #862 on: January 25, 2012, 12:56:56 pm »

does anyone have a good random number c++ code snippet?
the one I'm using right now isn't very random.
Here's a self-contained c++ implementation of the Mersenne Twister RNG.

The readme does a good job of explaining how to use it. Just put it directly in your project.

Or, you could, you know, use the Mersenne Twister algorithm that is included with C++11.
Or just use just use a library, Plenty of them available
« Last Edit: January 25, 2012, 01:01:52 pm by Virex »
Logged

kaijyuu

  • Bay Watcher
  • Hrm...
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #863 on: January 25, 2012, 12:59:18 pm »

Doesn't rand() come with the standard libraries? I think with math.h.
Logged
Quote from: Chesterton
For, in order that men should resist injustice, something more is necessary than that they should think injustice unpleasant. They must think injustice absurd; above all, they must think it startling. They must retain the violence of a virgin astonishment. When the pessimist looks at any infamy, it is to him, after all, only a repetition of the infamy of existence. But the optimist sees injustice as something discordant and unexpected, and it stings him into action.

Valid_Dark

  • Bay Watcher
  • If you wont let me Dream, I wont let you sleep.
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #864 on: January 25, 2012, 02:00:48 pm »

Well right now I'm using (rand()*time ())% 6+ 1

And I don't like it.
Logged
There are 10 types of people in this world. Those that understand binary and those that don't


Quote
My milkshake brings all the criminals to justice.

Levi

  • Bay Watcher
  • Is a fish.
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #865 on: January 25, 2012, 02:03:37 pm »

Well right now I'm using (rand()*time ())% 6+ 1

And I don't like it.

Why multiply it by the time?  It should work just fine without that.
Logged
Avid Gamer | Goldfish Enthusiast | Canadian | Professional Layabout

Valid_Dark

  • Bay Watcher
  • If you wont let me Dream, I wont let you sleep.
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #866 on: January 25, 2012, 02:07:47 pm »

For extra randomness, duh
Logged
There are 10 types of people in this world. Those that understand binary and those that don't


Quote
My milkshake brings all the criminals to justice.

GlyphGryph

  • Bay Watcher
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #867 on: January 25, 2012, 02:11:00 pm »

Wouldn't you be much better off using the time as a seed?
Logged

MorleyDev

  • Bay Watcher
  • "It is not enough for it to just work."
    • View Profile
    • MorleyDev
Re: if self.isCoder(): post() #Programming Thread
« Reply #868 on: January 25, 2012, 02:11:13 pm »

rand() sucks though. It uses a simplistic Linear congruential generator so isn't all that random (some pretty obvious (mathematically at least) patterns show). To demonstrate what is wrong with it, have it randomly generate numbers between 0 and n with a variety of values of n, where it generates until it has generated every number between 0 and n. For a lot of values of n and depending on the seed, this will often never finish.

C++11 (the latest version of the C++ standard which is being veeerrryyyy sllooowwwlllly adopted by all the major compilers) implements a pretty clever and solid set of random number generators and since the new random generators are already in Visual Studio 2010 and GCC...why not use them? ^^

Code: [Select]
std::uniform_int_distribution<int> distribution(0, 99);
std::mt19937 engine; // Mersenne twister MT19937

int random = distribution(engine); // Generate another sample directly using the distribution and the engine objects.

Alternatively Numerical Recipes has a few decent pseudo-random number generators I'm sure the code is for somewhere (Kinda proud I own the third edition of Numerical Recipes, is that sad? xD)...
« Last Edit: January 25, 2012, 02:23:40 pm by MorleyDev »
Logged

Levi

  • Bay Watcher
  • Is a fish.
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #869 on: January 25, 2012, 02:17:55 pm »

For extra randomness, duh

I'm not convinced it works that way.   :P
Logged
Avid Gamer | Goldfish Enthusiast | Canadian | Professional Layabout
Pages: 1 ... 56 57 [58] 59 60 ... 796