-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathrock_paper_scissors.jl
34 lines (26 loc) · 1.05 KB
/
rock_paper_scissors.jl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# 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