Hmm in the last C++ compiler I was working on I believe it was g++ (linux) rand() was not an accepted function because it was not counted as pure C++ in the compiler
I was making a dice roller program and the error I kept getting was after I did find the randomize function it needed a seed number and boundaries to operate, aka randomize(somenumber,lowerboundary,upperboundary) and it would use the number you put in as a jumping off point for the randomization.
I put in some random junk, and tested it, unfortunately for me since I used a static variable for the seed it always cued up the same string of numbers.
so I tired grabbing the date and time from the computer and running that as the random seed number, it seemed to do the trick, till I tried rolling multiple dice, as they all rolled at the same time, the seed remained the same.
I thought of putting the seed number is as the date and time++1 or adding 1 every time the function was ran, well thinking of that since this was just as small part of a d20 based mud I was working on, as many times as the dice were to be rolled it would not take to horribly long to exceed the maximum number size, even putting it in as a double long. ( not sure if that is still around, it has been a while )
At last I got a final solution with grabbing the date and time and cpu ticks , putting them together as one integer and using that as the seed number, worked like a charm.
I really hope they have rand() back or some version of it on g++ next time I dig back into it, will make it so much easier..
Ended up making the dice roller class operable and created static variables of the class named D6 for 6 sided dice, etc, all the common dice up to D100, worked quite well as I could use this class as an integer anywhere I needed a dice roll.
if any of you have played a table top rpg such as D&D there are quite a lot of them all I had to do was cout<<D10 to reflect the roll of a 10 sided dice on the screen, or in rolling attacks using simple addition
example
Player attack bonus is 10
Weapon has attack bonus of 2
Using power attack for a negative bonus of -5
so to calculate the roll and display the results was
monsters ac = 18
int hitroll = (10+2-5+D20);
if ((hitroll == ac) || (hitroll > ac))
cout<<"you hit the monster for %i damage",damage;
else cout<<"Missed";
might have messed up on the syntax, I am rusty as hell, lol
I love programming, you never know what weird problem you will run into next =D