Code example in the book

    This site uses cookies. By continuing to browse this site, you are agreeing to our Cookie Policy.

    • Code example in the book

      I am just learning how to program, and am using this book to learn some good practices for game programing. Loving this book by the way. However I have a question about the code examples in the book.

      Are they complete?

      I was reading in chapter 3 about the Random Number Generator, and It seems like the example is not complete. It is clearly stated that it is a implementation of the mersenne twister pseudo random number generator, however, here is what is found in the book:
      class CRandom {
      // DATA
      unsigned int rseed;
      unsigned long mt[CMATH_N]; /* the array for the state vector */
      int mti; /* mti==N+1 means mt[N] is not initialized */


      // FUNCTIONS
      public:
      CRandom(void);

      unsigned int Random( unsigned int n );
      void SetRandomSeed(unsigned int n);
      unsigned int GetRandomSeed(void);
      void Randomize(void);
      };

      This is all there is though... and it seems incomplete. I may be missing something... I did find the google code project with the full version, but is this how every example in the book is going to be? Are they all incomplete examples that I need to look up in the source code, or are they complete in most cases, and this is an exception, not a rule. Thanks for anyone who can clarify for me.
      Birdemic
    • A lot of books you find will explain some concept, and than show you a page or 2 of full complete code, I think in the case of GCC this would likely make the book twice as big. You're going to find some sections which more thoroughly explain code snippet, where some will give you the general idea, and than point you to the google code project. I actually enjoy this more personally opposed to other books with their walls of code you have to read through.
      PC - Custom Built
      CPU: 3rd Gen. Intel i7 3770 3.4Ghz
      GPU: ATI Radeon HD 7959 3GB
      RAM: 16GB

      Laptop - Alienware M17x
      CPU: 3rd Gen. Intel i7 - Ivy Bridge
      GPU: NVIDIA GeForce GTX 660M - 2GB GDDR5
      RAM: 8GB Dual Channel DDR3 @ 1600mhz
    • OK, thank you for the clarification! I was just a bit lost... probably cause I don't sleep enough. I have been using the google code project, and it is really useful to see the code all typed out, makes it way easier to go over. Thanks for the help again!
      Birdemic
    • No problem, let us know if you have any more questions.
      PC - Custom Built
      CPU: 3rd Gen. Intel i7 3770 3.4Ghz
      GPU: ATI Radeon HD 7959 3GB
      RAM: 16GB

      Laptop - Alienware M17x
      CPU: 3rd Gen. Intel i7 - Ivy Bridge
      GPU: NVIDIA GeForce GTX 660M - 2GB GDDR5
      RAM: 8GB Dual Channel DDR3 @ 1600mhz