Rock/Paper/Scissor game for C++ help!



The rules are that:
Scissors > Paper
Paper > Rock
Rock > Lizard
Lizard > Spock
Spock > Scissors
Scissors > Lizard
Lizard > Paper
Paper > Spock
Spock > Rock
Rock > Scissors

My code is running fine and playing the game but my code is not giving me the output of the game. If you win, loose or tie it does not tell you even though I thought I had put that loop at the end of my program. Please take a look at my program and let me know what you guys think.

Here is my code:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
  #include <iostream>
#include <cstdlib>
#include <limits>
#include <ctime>
#include <string>
#include <cmath>

using namespace std;

int main()
{
       while ( 2==2 )
{
	int choice; // Player Choices
	int comp; // Computer Choices
	 
	
    cout << "The Big Bang Theory! Rock/Paper/scissors/Lizard/Spock is a simple game. The rules are: \n Rock beats scissors. \n Scissors beats Paper. \n Paper beats rock. \n Rock beats Lizard. \n Lizard beats Spock. \n Spock beats Scissors. \n Scissors beats Lizard. \n Lizard beats Paper. \n Paper beats Spock. \n Spock beats Rock. \n Rock beats Scissors. \n";    
    //The choices
    cout << "Game Choices.\n\n";
    cout << "1. Rock\n";
    cout << "2. Paper\n";
    cout << "3. Scissors\n";
	cout << "4. Lizard\n";
	cout << "5. Spock\n";
    cout << "6. Quit, exits the game.\n";
    cout << "Please enter your choice.";
    cin >> choice;
	
	 if ( choice == 1 )
    {
        
        
        cout <<" Player Chooses: Rock " << endl;
    }
    
    else if ( choice == 2 )
    {
        
        cout <<" Player Chooses: Paper " << endl;
    }
    
    else if ( choice == 3 )
    {
        
        cout <<" Player Chooses: Scissors " << endl;
    }
    
    else if ( choice == 4 )
    {
        
        cout << " Player Chooses: Lizard " << endl;
    }
    
    else if ( choice == 5 )
    {
        
        cout << " Player Chooses: Spock " << endl;
    }
    else if ( choice == 6)
    {
        return 0;
    }
    
    
    srand(time(0));
    
    comp = rand() % 5 + 1;
    
    if ( comp == 1 )
    {
        comp = '1';
        cout << " Computer Chooses: Rock " << endl;
    }
    
    else if ( comp == 2 )
    {
        comp = '2';
        cout << " Computer Chooses: Paper " << endl;
    }
    
    else if ( comp == 3 )
    {
        comp = '3';
        cout << " Computer Chooses: Scissors " << endl;
    }
    
    else if ( comp == 4 )
    {
        comp = '4';
        cout << " Computer Chooses: Lizard " << endl;
    }
    else if ( comp == 5 )
    {
        comp = '5';
        cout << " Computer Chooses: Spock " << endl;
        
    }
    {
    if ( ( choice == 1 && comp == 1 ) ||
        ( choice == 2 && comp == 2 )  ||
        ( choice == 3 && comp == 3 )  ||
        ( choice == 4 && comp == 4 )  ||
        ( choice == 5 && comp == 5 ) )
    {
        cout << " It's a Tie! " << endl;
    }
    
    else if (( choice == 3 && comp == 2 ) ||
             ( choice == 2 && comp == 1 ) ||
             ( choice == 1 && comp == 4 ) ||
             ( choice == 4 && comp == 5 ) ||
             ( choice == 5 && comp == 3 ) ||
             ( choice == 3 && comp == 4 ) ||
             ( choice == 4 && comp == 2 ) ||
             ( choice == 2 && comp == 5 ) ||
             ( choice == 5 && comp == 1 ) ||
             ( choice == 1 && comp == 3 ))
    {
        cout << " Congratulations, you Win! " << endl;
    }
    
    else if (( choice == 2 && comp == 3 ) ||
             ( choice == 1 && comp == 2 ) ||
             ( choice == 4 && comp == 1 ) ||
             ( choice == 5 && comp == 4 ) ||
             ( choice == 3 && comp == 5 ) ||
             ( choice == 4 && comp == 3 ) ||
             ( choice == 2 && comp == 4 ) ||
             ( choice == 5 && comp == 2 ) ||
             ( choice == 1 && comp == 5 ) ||
             ( choice == 3 && comp == 1 ))
    {
        cout << " Too Bad, You Lost! " << endl;
    }
    }
    
    int playAgain;
    
 
      cout << "Would you like to play again? Press 2 to Exit. Press 1 to play again!" << endl;
      cin >> playAgain;
       if (playAgain == 2)
     {
          return 0;
      }
}
    return 0;



}
Last edited on
Why did you put ' ' for your variables values?

Remove them and that's solved.
Thank you so much! I though it would be something stupid like that.
You're welcome! :)
HAHA I just yesterday saw this episode of The Big Bang Theory .. Thats awesome!!
Topic archived. No new replies allowed.