In class this week, we will work on simulating the game of Yahtzee. In the game of Yahtzee, five dice are tossed, and various combinations of numbers, similar to poker hands, are assigned point values. In the game, dice can be selected and re-tossed, but we will focus on calculating the probabilities for the first toss only. We will also deal only with the "lower half" of the score card in the game. For the interested student, continuing this project to account for the complete rules of play would be an entertaining challenge. Anyone not familiar with Yahtzee should try a web search for the rules of the game. Some sites have applets that let you play online. All you really need to know for this lesson, though, is which combinations are counted. We will call these "hands," as the combinations in poker are called. The hands in Yahtzee are: Three of a Kind (three of one number and two others that are different) Full House (three of one number and two of another number) Four of a Kind (four of one number and one other) Yahtzee (five of the same number) Small Straight (four consecutive numbers) Large Straight (five consecutive numbers) Chance (anything that does not fit the above patterns) We begin by simulating dice rolls. For example we can simulate one roll of a die to be: library(tidyverse)roll <- sample(1:6, size=1, replace=T)roll   Given this information, please answer the following question attached using R. Show the R code.

C++ for Engineers and Scientists
4th Edition
ISBN:9781133187844
Author:Bronson, Gary J.
Publisher:Bronson, Gary J.
Chapter13: Structures
Section: Chapter Questions
Problem 4PP
icon
Related questions
Question

In class this week, we will work on simulating the game of Yahtzee. In the game of Yahtzee, five dice are tossed, and various combinations of numbers, similar to poker hands, are assigned point values. In the game, dice can be selected and re-tossed, but we will focus on calculating the probabilities for the first toss only. We will also deal only with the "lower half" of the score card in the game. For the interested student, continuing this project to account for the complete rules of play would be an entertaining challenge.

Anyone not familiar with Yahtzee should try a web search for the rules of the game. Some sites have applets that let you play online.

All you really need to know for this lesson, though, is which combinations are counted. We will call these "hands," as the combinations in poker are called. The hands in Yahtzee are:

  • Three of a Kind (three of one number and two others that are different)
  • Full House (three of one number and two of another number)
  • Four of a Kind (four of one number and one other)
  • Yahtzee (five of the same number)
  • Small Straight (four consecutive numbers)
  • Large Straight (five consecutive numbers)
  • Chance (anything that does not fit the above patterns)

We begin by simulating dice rolls. For example we can simulate one roll of a die to be:

library(tidyverse)roll <- sample(1:6, size=1, replace=T)roll
 
Given this information, please answer the following question attached using R. Show the R code.
1.1.1. Problem 1.
Using a loop create a matrix of 10 rolls all consisting of 5 dice in each roll. Then, rewrite your code to avoid
using a loop.
[2]: # Solution with Loop:
[3]: # Solution without loop:
Transcribed Image Text:1.1.1. Problem 1. Using a loop create a matrix of 10 rolls all consisting of 5 dice in each roll. Then, rewrite your code to avoid using a loop. [2]: # Solution with Loop: [3]: # Solution without loop:
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps

Blurred answer
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
C++ for Engineers and Scientists
C++ for Engineers and Scientists
Computer Science
ISBN:
9781133187844
Author:
Bronson, Gary J.
Publisher:
Course Technology Ptr