I am trying to make a program for rock paper scissors, and this is what I have come up with. It is complete and works, but seems far too inefficient. How can I make this code more simple and efficient? I feel like this is way too much code for a simple game, but I'm not sure what to change. Any advice and tips would be greatly appreciated.
The biggest improvement you could make is to get rid of the totally pointless class. It's just a way of using global variables while pretending not to. None of your functions take any parameters or return anything. It's just silly.
srand should only be called once in the program.
You should include all headers that you require (e.g., <cstdlib> for system, rand, srand).
What if you had a table of human vs ai? Let the human be rows... and Win/Lose/Draw (these could be strings, and probably should be)
RPS
______
R|DLW
P|WDL
S|LWD
the its simply
cin human
roll AI
cout << table[humanentry][aichoice];
with a few statements to do some additional menu/output/etc stuff.