필터 지우기
필터 지우기

In the game of Monopoly, a pair of dice are rolled to move a player's piece around the board. If a double is rolled (the dice show the same number), the player receives another roll of the dice. If a double is rolled a second time, a third roll of

조회 수: 31 (최근 30일)
In the game of Monopoly, a pair of dice are rolled to move a player's piece around the board. If a double is rolled (the dice show the same number), the player receives another roll of the dice. If a double is rolled a second time, a third roll of the dice is received. If a double is rolled on the third occasion, the player forfeits their turn (and goes to Jail). Write a program which simulates two players having 50 turns each (a turn is however many dice rolls a player has in a row before it's the other player's turn) and determines:
a) the total number of spaces moved by each player; and
b) how many times a player rolls a double which results in movement of a piece.
Use the randi function.
Incorporate the rule that a player cannot leave Jail (cannot move) unless they either roll a double or three turns have passed without rolling a double.
  댓글 수: 2
Steven Lord
Steven Lord 2017년 8월 21일
If you post what you've done to try to solve this problem and ask a specific question you may receive some suggestions about how to move forward.
James Boyle
James Boyle 2017년 8월 22일
A good place to start would be
dice1 = randi(6,1,1);
dice2 = randi(6,1,1);
That will give two random numbers between 6 and 1, which you can compare, and loop again if they match.

댓글을 달려면 로그인하십시오.

답변 (0개)

카테고리

Help CenterFile Exchange에서 Board games에 대해 자세히 알아보기

태그

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by