Borrar filtros
Borrar filtros

How to rank cards

2 visualizaciones (últimos 30 días)
Lynn Boudani
Lynn Boudani el 29 de Nov. de 2020
Respondida: Manas el 1 de Ag. de 2022
I'm trying to rank the different cards, but I'm struggling with the if statements and on how to assign a value to my different suits. Basically, if the 'tarneeb' is spades that means spades is the highest ranking suit, I'm struggling on how to code that.
  2 comentarios
Rik
Rik el 29 de Nov. de 2020
If you ask a specific question related to Matlab you increase your chances of getting an answer. I'm not sure which game you refer to, nor what you have already done.
Lynn Boudani
Lynn Boudani el 29 de Nov. de 2020
I did this excel file. The card game is called Trumps. I'm trying to assign values to these different suits.
if contains(tarneeb_input,'S')
%spades is the highest ranking
%for the hearts: Ace is the strongest(val = 13) but spades always beats it (spades>13)
end

Iniciar sesión para comentar.

Respuestas (1)

Manas
Manas el 1 de Ag. de 2022
Having an if condition to check the value and suit is more than enough here.
tarneeb_input = input("Enter Card");
score = 0;
if(contains(tarneeb_input, "Spades"))
score = 39;
elseif(contains(tarneeb_input, "Hearts"))
score = 26;
elseif(contains(tarneeb_input, "Clubs"))
score = 13;
else
score = 0;
end
if(tarneeb_input(1) == '2')
score = score + 1;
elseif(tarneeb_input(1) == '3')
score = score + 2;
elseif(tarneeb_input(1) == '4')
score = score + 3;
elseif(tarneeb_input(1) == '5')
score = score + 4;
elseif(tarneeb_input(1) == '6')
score = score + 5;
elseif(tarneeb_input(1) == '7')
score = score + 6;
elseif(tarneeb_input(1) == '8')
score = score + 7;
elseif(tarneeb_input(1) == '9')
score = score + 8;
elseif(tarneeb_input(1) == '10')
score = score + 9;
elseif(tarneeb_input(1) == 'J')
score = score + 10;
elseif(tarneeb_input(1) == 'Q')
score = score + 11;
elseif(tarneeb_input(1) == 'K')
score = score + 12;
else
score = score + 13;
end
disp(score);

Categorías

Más información sobre Lighting, Transparency, and Shading en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by