
-----------------------------------
majorwinters202
Thu Oct 07, 2004 7:50 am

Rock, Paper, Scissors
-----------------------------------
Hey guys,
I need some help with a rock, paper, scissors game i made. I did that i could but it messes up. I got this:

var fname : string % The first name
var lname : string % The last name
var fname2 : string % Player 2 First Name
var lname2 : string % Player 2 Last Name
var input : string % Player 1's Choice
var input2 : string % Player 2's Choice
var wino := Window.Open ("graphics: 640; 480,nobuttonbar")
var winc := Window.Close
var continue : string
% Get input from user

put "Please enter your first name ===> " ..
get fname
put "Now, please enter your last name ===> " ..
get lname
put "Player 2, please enter first name ===> " ..
get fname2
put "Player 2, please enter last name ===> " ..
get lname2
% Display the report

put "Welcome ", fname, " ", lname
put "Welcome ", fname2, " ", lname2
put "Let's play the game Rock, Paper, Scissors"
delay (1000)
put " The rules are simple, take turns looking away from the computer while the other player types in either R or r, P or p, or S and s"
delay (4000)
put "R = Rock, P = Paper, and S = Scissors"
delay (3000)
loop
    cls
    put "Lets Play!!, your turn ", fname, " ", lname
    get input
    delay (2000)
    put "Now your turn ", fname2, " ", lname2
    get input2
    if input = "R" or input = "r" and input2 = "S" or input2 = "s" then
        put "Player1 Wins"
    elsif input = "R" or input = "r" and input2 = "R" or input2 = "r" then
        put "ITS A TIE!!!"
    elsif input = "R" or input = "r" and input2 = "P" or input2 = "p" then
        put "Player2 Wins"
    elsif input = "S" or input = "s" and input2 = "S" or input2 = "s" then
        put "ITS A TIE!!!"
    elsif input = "S" or input = "s" and input2 = "R" or input2 = "r" then
        put "Player2 Wins"
    elsif input = "S" or input = "s" and input2 = "P" or input2 = "p" then
        put "Player1 Wins"
    elsif input = "P" or input = "p" and input2 = "S" or input2 = "s" then
        put "Player2 Wins"
    elsif input = "P" or input = "p" and input2 = "R" or input2 = "r" then
        put "Player1 Wins"
    elsif input = "P" or input = "p" and input2 = "P" or input2 = "p" then
        put "ITS A TIE!!!"
    else
        put "Invalid Command, please put P, S, or R!"
    end if
    put "Do you wanna play again? Yes or No?"
    get continue
    exit when continue = "No" or continue = "no"
end loop


For some odd reason, when player1 puts paper and player2 puts rock, ITS A TIE!lol. I don't know why this is? anyone know the problem?

-----------------------------------
josh
Thu Oct 07, 2004 8:48 am


-----------------------------------
this shoudl be in the turing help section, and plz use code tags next time.

One suggestion u may wanna clear the screen after one perosn enters their choice so th  other 1 doesn' see it  :wink: 


I frankly can't see n e thing wrong with this code. I suspect that it is conflicting with an earlier elsif statement but can't figure out which 1.

-----------------------------------
Delos
Thu Oct 07, 2004 7:08 pm


-----------------------------------
[sigh]
This is some of the buggiest code I've seen in a long time.  Your problem lies in your multitude of if-elsif statements.  I did some test trials with it and very few of them actually do what you want them to.
My advice is to rewrite that area of the code, tighter and more efficient...consider using ord()s and/or chr()s to simplify your comparisons...

There's a problem with your ors and ands.  Logic...it's a bit more complicated that what it seems...anyway, go fix it and repost with [code] tags!
