# Rock Paper Scissors Game

• 07-05-2007
tbca
Rock Paper Scissors Game
I am currently trying to make like a text based rock paper scissors game and i need to find a way to make my computer do a random order of three numbers each to equal rock paper or scissors
• 07-05-2007
Salem
See the FAQ ?
• 07-05-2007
tbca
just checked nothing about a random pattern
• 07-05-2007
laserlight
Just checked and found How do I... Generate random numbers?

Using rand()
Random Numbers Tutorial
• 07-05-2007
tbca
Quote:

Originally Posted by laserlight
Just checked and found How do I... Generate random numbers?

Using rand()
Random Numbers Tutorial

but i need to get the numbers 1 2 and 3 in random order I don't need random numbers
• 07-05-2007
Salem
Oh, you mean a "shuffle" - rearrange a set of things into a random order, like one would do for a deck of cards.

Search the board, there are some examples of that.
• 07-05-2007
tbca
yeah a shuffle
• 07-05-2007
Daved

In this case, since there are only three numbers, you can also use rand. Just pick a random number in the range [1,3] and let that be first, then pick another random number. If it is even switch the order of the two leftover numbers.
• 07-06-2007
CodeMonkey
Besides, wouldn't the possibility of the computer opponent repeating a throw be integral? One could easily figure out that the computer will throw all three in three moves, and gain a statistical advantage.
Consider just making each of the computer's moves random.
• 07-06-2007
tbca
Quote:

Originally Posted by Daved

Ummm........ I'm not that good with arrays and or vectors is there somewhere online I could learn about them
• 07-06-2007
h_howee
• 07-07-2007
tbca
ty for the help

but I still cant figure out what rand or random_shuffle has to do with arrays and or vectors

i mean for rand you don't even need arrays do u?
• 07-09-2007
Daved
What did you ding when you looked up random_shuffle? There should be examples. It is simple to use, for an array:
Code:

`random_shuffle(arr, arr+size);`
For a vector:
Code:

`random_shuffle(vec.begin(), vec.end());`
Depending on your platform you might have to call srand() once at the start of your program just like if you use rand().

>> i mean for rand you don't even need arrays do u?
You don't need an array if you only have three values. The point of using an array or vector as well as random_shuffle is that those solutions scale to larger problems. For three values it is overkill, we are mostly just giving solutions assuming the point is to learn how to do it for bigger problems.