Rock, Paper, Scissors in MATLAB?
23 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Brian Tiffman
el 12 de Nov. de 2015
Comentada: Brian Tiffman
el 13 de Nov. de 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 comentarios
Respuesta aceptada
Image Analyst
el 12 de Nov. de 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 comentarios
Image Analyst
el 12 de Nov. de 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.
Más respuestas (0)
Ver también
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!