For this assignment you will be replicating the game of Roshambo (aka rock, paper, scissors). Please answer both parts a and b of the following question below. Show the R code in your answer and annotate all parts of the code. a.) First, you need to come up with a strategy to win the game. Write a function in R that takes in a vector of past plays for your opponent (each play should be represented as "R", "P", or "S") and outputs the next move ("R", "P", or "S"). Your strategy should at least depend on the last two moves used, but you should return a random move if there is not enough past history to use the strategy. b.) Now, play your strategy against a random player who uses rock, paper, or scissors with 1/3 probability each. Who wins the most rounds after 100 rounds of play? Write a function in R.
For this assignment you will be replicating the game of Roshambo (aka rock, paper, scissors). Please answer both parts a and b of the following question below. Show the R code in your answer and annotate all parts of the code.
a.) First, you need to come up with a strategy to win the game. Write a function in R that takes in a
b.) Now, play your strategy against a random player who uses rock, paper, or scissors with 1/3 probability each. Who wins the most rounds after 100 rounds of play? Write a function in R.
Trending now
This is a popular solution!
Step by step
Solved in 2 steps