![]() |
|
#11
|
||||
|
||||
Re: Decks and DiceOf course, the code I posted above will require that the compiler emit separate code for each N that you use in your program, rather than in the non-template version that uses a member variable for sides. Since the typical game will not have more than about a half-dozen different N's, this is not likely to be a concern.
With a simple program that does nothing but instantiate an instance of Dice for N=4,6,8,10,12,20, and call each member function once, I measured the code bloat as shown below (g++ 4.0). Without compiler optimization (other than default): Code:
Code:
Matthew P.S. I forgot to mention something again. I did not use the RNG class, but simply called the rand() function for my test. It is just meant to give a rough idea anyhow. __________________
I was born not knowing and have only had a little time to change that here and there. -- Richard P. Feynman Boris Podolsky: James! How's the rat business? James Moreland: Well, actually it's mostly students I'm experimenting on now. Kurt Gödel: My God, the mazes must be enormous. |
||||
|
#12
|
||||
|
||||
Re: Decks and DiceThanks QED. I'm out of town working until this weekend but with davis' and your suggestions I am looking forward to playing with this when I get home. Your tips jive with the lines I had been thinking along.
Mark __________________
"Opportunity is missed by most people because it comes dressed in overalls and looks like work." --Thomas Alva Edison "Those who would give up essential liberty to purchase a little temporary safety, deserve neither liberty nor safety." --Benjamin Franklin "A happy person is not a person in a certain set of circumstances, but rather a person with a certain set of attitudes." --Hugh Downs |
|
#13
|
|||
|
|||
Re: Decks and DiceQuote:
We both need to modify our code such that Dice<0> isn't allowed... Of course, Dice<1> is of little use too, huh? :davis: |
Recent GIDBlog
Once again, no time for hobbies by crystalattice
| Thread Tools | Search this Thread |
| Rate This Thread | |
|
|
Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The