This Is the instructions of my project that has to be done by using MATLAB . ..o
ID: 3854689 • Letter: T
Question
This Is the instructions of my project that has to be done by using MATLAB . ..ooo T-Mobile 9:07 PM As a small group of 3-4 students, design your own version of the gameshow "Deal or No Deal" is how the game works that contains at least 10 cases with hidden prize values. The values should be randomized. Here r A contestant randomly chooses a case to keep. The monetary prize value is not revealed to anyone The contestant must choose a series of cases to open. The values are revealed one by one > After a series of choices, an offer is given to the contestant. He or she can either keep their case and move on with the game or take a buyout value determined by you to end the game. It should be enticing enough so that they would take the deal, but not extraordinary so that they won't keep playing The contestant must choose a series of more cases to open and the next buyout value is given This can be repeated from 2 to 4 times If the coetestant makes it to the end where only 2 cases are remaining (the one they are holding and another one on the board), the contestant can choose to keep the original case or switch. That will be their prizse Incorporate aspects of probability that were discussed in class Here is a13 minute synopsis of the whole showExplanation / Answer
Solution: See the code below
---------------------------------------------------
num_cases=10; %number of cases available
case_values=ones(1,num_cases); %vector to store case values
cases_opened=0;
%populate case values
for i=2:num_cases
case_values(i)=case_values(i-1)*10;
end
%disp("before shuffling");
%disp(case_values);
%shuffle cases
case_values=case_values(randperm(length(case_values)));
%disp("after shuffling");
%disp(case_values);
disp("Now we start the game.");
disp("What to say?");
disp("Deal or No Deal!!!");
name=input("Hello Contestant, please enter your name:",'s'); %ask contestant's name
printf("Hello, %s, now enter case no. to keep with you! ",name);
case_selected=input("Enter case number:"); %case selected by contestant to keep
case_selected=int8(case_selected);
printf("So case selected by Mr./Ms. %s:%d ",name,case_selected);
cases_left=num_cases;
%loop to play game
j=1; %counter for cases opened
for i=1:num_cases
printf("Hello, %s, now enter case no. to open! ",name);
case_to_open=input("Enter case number:"); %case selected by contestant to open
case_to_open=int8(case_to_open);
if(case_to_open==case_selected || ismember(case_to_open,cases_opened))
continue;
end
cases_opened(j)=case_to_open;
j=j+1;
printf("Dear %s, the value of opened case %d is %d ",name,case_to_open,case_values(case_to_open));
%check whether to make a offer to contestant or not
rnd=randperm(num_cases,1); %some random number
if(rnd==i) %if true, then make offer
printf("Well played till now Mr./Ms. %s! ",name);
disp("Now an offer for you!!!");
offer=randperm(max(case_values),1);
printf("Offer $:%d ",offer);
choice=input("Want to select this offer(y/n)",'s');
if(choice=='y')
printf("Thank you Mr./Ms. %s for selecting the offer. ",name);
printf("You have won $%d. You can leave game now. ",offer);
disp("Thanks for playing with us!");
exit(1);
end
end
cases_left=cases_left-1;
if(cases_left==1)
break;
end
end
%decide which case is still not opened
for i=1:num_cases
if(i==case_selected || ismember(i,cases_opened))
continue;
end
case_still_closed=i;
end
printf("Now do you want to keep your selected case and switch it with %d?");
choice=input("Switch(y/n)",'s');
if(choice=='y')
disp("You have switched!");
printf("Your prize money is $%d ",case_values(case_still_closed));
else
disp("You have not switched!");
printf("Your prize money is $%d ",case_values(case_selected));
end
disp("Thanks for playing with us!");
----------------------------------
Output:
------------------------------
Now we start the game.
What to say?
Deal or No Deal!!!
Hello Contestant, please enter your name:sb
Hello, sb, now enter case no. to keep with you!
Enter case number:5
So case selected by Mr./Ms. sb:5
Hello, sb, now enter case no. to open!
Enter case number:1
Dear sb, the value of opened case 1 is 1000
Hello, sb, now enter case no. to open!
Enter case number:2
Dear sb, the value of opened case 2 is 10
Hello, sb, now enter case no. to open!
Enter case number:3
Dear sb, the value of opened case 3 is 10000000
Well played till now Mr./Ms. sb!
Now an offer for you!!!
Offer $:867126230
Want to select this offer(y/n)y
Thank you Mr./Ms. sb for selecting the offer.
You have won $867126230. You can leave game now.
-------------------------------------------
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.