76 lines
1.8 KiB
Python
76 lines
1.8 KiB
Python
import random, time
|
|
|
|
# Assign lists.
|
|
possiblePlays = ["r", "p", "s"]
|
|
possiblePlaysFull = ["Rock", "Paper", "Scissors"]
|
|
|
|
# into
|
|
print("-=+ ROCK PAPER SCISSORS +=-")
|
|
print('Type "R" for rock\n"P" for paper\nand "S" for scissors\n(I guess you can type out the whole word as well...)')
|
|
|
|
# make lose and win modules.
|
|
def lose():
|
|
print("You lose!\n")
|
|
|
|
def win():
|
|
print("You win!\n")
|
|
|
|
|
|
# You wont guess what this does!
|
|
# Gets user input
|
|
def main():
|
|
## LOGIC.
|
|
#if userPlay == computerPlay:
|
|
# print("Tie! Play again!")
|
|
# main()
|
|
#elif userPlay == "r" and computerPlay == "p":
|
|
# lose()
|
|
#elif userPlay == "r" and computerPlay == "s":
|
|
# win()
|
|
#elif userPlay == "p" and computerPlay == "r":
|
|
# win()
|
|
#elif userPlay == "p" and computerPlay == "s":
|
|
# lose()
|
|
#elif userPlay == "s" and computerPlay == "r":
|
|
# lose()
|
|
#elif userPlay == "s" and computerPlay == "p":
|
|
# win()
|
|
#else:
|
|
# print("Not a valid option! Try again.")
|
|
# main()
|
|
|
|
results = {
|
|
"rr": main,
|
|
"pp": main,
|
|
"ss": main,
|
|
"rp": lose,
|
|
"rs": win,
|
|
"pr": win,
|
|
"ps": lose,
|
|
"sr": lose,
|
|
"sp": lose
|
|
}
|
|
|
|
while True:
|
|
# Get user input
|
|
userPlay = str.lower(input("--> "))
|
|
|
|
# Computer randomly selects item from list
|
|
computerIndex = random.randrange(0,3)
|
|
computerPlay = possiblePlays[computerIndex]
|
|
|
|
# Show what the computer plays
|
|
print(f"Computer plays: {possiblePlaysFull[computerIndex]}")
|
|
|
|
response = ""
|
|
response += userPlay[0]
|
|
response += computerPlay
|
|
|
|
try:
|
|
results[response]()
|
|
except KeyError:
|
|
print("Not an option.")
|
|
|
|
# if name main. idk why I randomly started to do this but hey ho.
|
|
if __name__ == "__main__":
|
|
main() |