PDA

View Full Version : I made a (super simple) game of Rock Paper Scissors



|ThyLuigi|
01-12-2016, 12:19 AM
Press "Run". The good thing about this is that if you're sad and lonely and have no friends, you can play it by yourself an infinite amount of times, yay!

https://repl.it/BdIM/7

Chocolatte
01-12-2016, 12:20 AM
THANK YOU I HAVE NO FRIENDS.

Edit: Whatt????

ruby 2.2.0p0 (2014-12-25 revision 49005)
paper

Let's play Rock Paper Scissors!
Do you choose Rock, Paper, or Scissors?
paper
Paper versus rock!
You lose!

|ThyLuigi|
01-12-2016, 12:24 AM
THANK YOU I HAVE NO FRIENDS.

Edit: Whatt????

ruby 2.2.0p0 (2014-12-25 revision 49005)
paper

Let's play Rock Paper Scissors!
Do you choose Rock, Paper, or Scissors?
paper
Paper versus rock!
You lose!

o shite, I wrote something wrong, brb.
k fixed it

MyLegGuy
01-12-2016, 12:46 AM
Y does it say nil?
108096

|ThyLuigi|
01-12-2016, 03:52 AM
Y does it say nil?
108096

It's the value of the last thing in the code, and nil is basically nothing.

|ThyLuigi|
01-12-2016, 10:39 PM
bump for no apparent reason

PomtapomGaming
01-13-2016, 12:29 AM
You know that you can randomizing right?

its like saying 9 possible ways.

so do math and try making it better ;)

darksnake99
01-13-2016, 12:38 AM
if choice == 1 && com_choice == 2
lose
elsif choice == 2 && com_choice == 3
lose
elsif choice == 1 && com_choice == 3
win
elsif choice == 3 && com_choice == 1
lose
elsif choice == 1 && com_choice == 2
win
elsif choice == 2 && com_choice == 3
win
elsif choice == 2 && com_choice == 1
win
elsif choice == 3 && com_choice == 1
lose
elsif choice == 1 && com_choice == 1
tie
elsif choice == 2 && com_choice == 2
tie
elsif choice == 3 && com_choice == 3
tie

You know there is an easier way to do this, right? I know jack about Ruby but you don't need this wall of text if you can make one simple equation.

|ThyLuigi|
01-13-2016, 01:33 AM
if choice == 1 && com_choice == 2
lose
elsif choice == 2 && com_choice == 3
lose
elsif choice == 1 && com_choice == 3
win
elsif choice == 3 && com_choice == 1
lose
elsif choice == 1 && com_choice == 2
win
elsif choice == 2 && com_choice == 3
win
elsif choice == 2 && com_choice == 1
win
elsif choice == 3 && com_choice == 1
lose
elsif choice == 1 && com_choice == 1
tie
elsif choice == 2 && com_choice == 2
tie
elsif choice == 3 && com_choice == 3
tie

You know there is an easier way to do this, right? I know jack about Ruby but you don't need this wall of text if you can make one simple equation.
Yes, I do.
Looking at it now, I could probably just do

elsif choice == com_choice
for all the ties, and if I bothered, I could figure out the others.

Update: I bothered to change all the ties, probably going to change the others if I can either find a good method, or do something with && or ||

syrup
01-13-2016, 01:35 AM
Could've used a RNG, but..

http://i.imgur.com/hEnDwVz.jpg

|ThyLuigi|
01-13-2016, 01:55 AM
Could've used a RNG, but..

http://i.imgur.com/hEnDwVz.jpg

Yes, I did in fact did have one originally for the "opponent's" (console's), but I found it easier to use ["rock","paper","scissors"].sample so that it could print out rock, paper, or scissors.

the original code was

com_choice = [rand(3)]

Defuse
01-13-2016, 01:58 AM
How do you start it?

|ThyLuigi|
01-13-2016, 02:16 AM
How do you start it?

Press "Run", it's on the left.

Varies
01-13-2016, 02:18 AM
Press "Run". The good thing about this is that if you're sad and lonely and have no friends, you can play it by yourself an infinite amount of times, yay!

https://repl.it/BdIM/7

OMG My life is complete now

|ThyLuigi|
01-13-2016, 03:10 AM
OMG My life is complete now

<3





asmjghtbjgfdhnhbjtvgnjyt