Rock Paper Scissors
Mix.install([
{:jason, "~> 1.4"},
{:kino, "~> 0.9", override: true},
{:youtube, github: "brooklinjazz/youtube"},
{:hidden_cell, github: "brooklinjazz/hidden_cell"}
])
Navigation
Home Report An Issue Naming Numbers ModulesCreate The Perfect AI
You’re going to create the perfect AI for rock paper scissors that will always win.
flowchart LR
scissors --beats--> paper --beats--> rock --beats--> scissors
Generate a random player choice of :rock ,:paper, or :scissors or manually enter :rock, :paper, and :scissors to determine your program works correctly.
player_choice = Enum.random([:rock, :paper, :scissors])
Then, return the winning choice of either :rock, :paper, or :scissors that beats the player’s choice.
Enter your solution below.
Create Two Player Rock Paper Scissors
Now that you know how to create a rock paper scissors AI, you’re going to create a two player game of rock paper scissors.
Bind a player1_choice and player2_choice variable to :rock, :paper, or :scissors.
-
If
player1_choicebeatsplayer2_choice, return"Player 1 wins!". -
If
player2_choicebeatsplayer1_choice, return"Player 2 wins!". -
If both players have the same choice, then return
"Draw".
Enter your solution below.
Commit Your Progress
DockYard Academy now recommends you use the latest Release rather than forking or cloning our repository.
Run git status to ensure there are no undesirable changes.
Then run the following in your command line from the curriculum folder to commit your progress.
$ git add .
$ git commit -m "finish Rock Paper Scissors exercise"
$ git push
We’re proud to offer our open-source curriculum free of charge for anyone to learn from at their own pace.
We also offer a paid course where you can learn from an instructor alongside a cohort of your peers. We will accept applications for the June-August 2023 cohort soon.