Created
January 2, 2022 20:08
-
-
Save logankilpatrick/e6bccf4a413ba6303533895d1246e768 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Rock πΏ, Paper π, Scissors βοΈ Game in Julia | |
function play_rock_paper_scissors() | |
moves = ["πΏ", "π", "βοΈ"] | |
computer_move = moves[rand(1:3)] | |
# Base.prompt is similar to readline which we used before | |
human_move = Base.prompt("Please enter πΏ, π, or βοΈ") | |
# Appends a ": " to the end of the line by default | |
print("Rock...") | |
sleep(0.8) | |
print("Paper...") | |
sleep(0.8) | |
print("Scissors...") | |
sleep(0.8) | |
print("Shoot!\n") | |
if computer_move == human_move | |
print("You tied, please try again") | |
elseif computer_move == "πΏ" && human_move == "βοΈ" | |
print("You lose, the computer won with πΏ, please try again") | |
elseif computer_move == "π" && human_move == "πΏ" | |
print("You lose, the computer won with π, please try again") | |
elseif computer_move == "βοΈ" && human_move == "π" | |
print("You lose, the computer won with βοΈ, please try again") | |
else | |
print("You won, the computer lost with $computer_move, nice work!") | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment