Share your repls and programming experiences

← Back to all posts
Rock Paper Scissors in C++! [Game]
h
RohilPatel (1535)

Hey there people,

this is my first ever game posted to repl talk in a console. I usually try to avoid this, but since I am a slow learner, I need to think more and make less.

Please let me know other ideas to make with this project. I would greatly appreciate this, as it helps me get better.

Thanks.

Comments
hotnewtop
Coder100 (17134)

well at least you didn't use namespace std so here's an upvote ig
one thing you should work on is that there's an easier way to generate random numbers, and that is to use C's stdlib:

#include <stdlib.h>

int main() {
  printf("%d", rand() % (MIN) + MAX);
}
RohilPatel (1535)

yeah i know, but my friend told me not to use it cuz it was bad. I don't know tho @Coder100

Coder100 (17134)

use rand lol don't hurt yourself @RohilPatel

Theboys619 (63)

Yea but you would have to seed it using srand @RohilPatel

RohilPatel (1535)

ok lol yeah i suggested it to my friend but he said no when i asked. so i just used this lol @Coder100

zplusfour (892)

@Coder100 :(
I prefer doing

using namespace std;
RohilPatel (1535)

Lol I thought u we're gonna drill me for a sec @xxpertHacker

Coder100 (17134)

i sstill don't see why that's greater than cs rand() @xxpertHacker

xxpertHacker (871)

@RohilPatel Na, I had to hate on Coder100 suggesting to use C instead of C++.

xxpertHacker (871)

@Coder100 It's C++. That alone makes a major difference.

Also, they're actually random, they aren't based on time or order, like C's random.h is.

https://www.cplusplus.com/reference/random/random_device

xxpertHacker (871)

@Coder100 Crazy stuff developed by experts with years of professional experience in C, C++, and Asm languages.

Simply put: I have no clue, and I won't know for a long time (probably never). But I know that the people who made it were good at their jobs, so I trust that it works. (and the website is credible too, so there's that)

Coder100 (17134)

@xxpertHacker i have never heard of random being created other than time.

Theboys619 (63)

Oh I know about the <random> header. I created the random.cpp file for him and tried to explain it to him.
There is also some unnecessary things in there that I could of done so much easier. My brain was just dying from other things.
@xxpertHacker

fishyCoding (3)

Very good game in general, gave u an upvote but.... dude! use rand!

xxpertHacker (871)

Please, use a loop instead of making the player type (./main).

Ruined the game tbh.

KENNETHTRIPP (50)

You should have it ask you to play again.
I made a repl very similar to this here it is: https://repl.it/@KENNETHTRIPP/Rock-Paper-Scissors#main.py

RohilPatel (1535)

It kinda does. Just run ./main. I get it's not the most practical, but I was lazy @KENNETHTRIPP

Arbiter1227 (4)

Cool! I'm gonna try making a clone in Node.js!

guy4 (1)

this is rigged + it's the Linux terminal

programmeruser (572)

One suggestion: replace

cin >> my_var;

with

std::getline(std:cin, my_var);

and

std::endl

with

"\n"

Also, the convention in C++ is to use snake_case instead of camelCase.

RohilPatel (1535)

nah, i like the endl cuz u can seperate long writes cleanly with the code, and cin cuz its shorter @programmeruser

programmeruser (572)

@RohilPatel with cin, if you enter

John Smith

the program will recieve it as

John