Rock, Paper, Scissors in MATLAB?
23 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Brian Tiffman
am 12 Nov. 2015
Kommentiert: Brian Tiffman
am 13 Nov. 2015
In the attached document, looking at problem 4, how would I write the code using a matrix and while loop. I know how to write the code using many if statements, but I want some insight on how to use the matrix I created in a while loop. Im just looking for help, and not the answer given to me for my problem. Any help would be greatly appreciated. Thanks!
0 Kommentare
Akzeptierte Antwort
Image Analyst
am 12 Nov. 2015
Here's a hint/snippet
gamesPlayed = 0
while gamesPlayed < 100 % Or whatever max you reasonably expect
% Other Code: menu(), randi(), etc.
% Increment the number of games played
gamesPlayed = gamesPlayed + 1;
promptMessage = sprintf('Do you want to Continue playing,\nor Quit?');
titleBarCaption = 'Continue?';
button = questdlg(promptMessage, titleBarCaption, 'Continue', 'Quit', 'Continue');
if strcmpi(button, 'Quit')
break;
end
end
3 Kommentare
Image Analyst
am 12 Nov. 2015
Your code has to get the computer and your choice. Then use those as rows and columns into the matrix to decide if you won, the computer won, or it was a tie. Then increment the wins and losses and ties for you and the computer.
Weitere Antworten (0)
Siehe auch
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!