Rock, Paper, Scissors in MATLAB?
23 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Brian Tiffman
le 12 Nov 2015
Commenté : Brian Tiffman
le 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 commentaires
Réponse acceptée
Image Analyst
le 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 commentaires
Image Analyst
le 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.
Plus de réponses (0)
Voir également
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!