フィルターのクリア

How to rank cards

2 ビュー (過去 30 日間)
Lynn Boudani
Lynn Boudani 2020 年 11 月 29 日
回答済み: Manas 2022 年 8 月 1 日
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 件のコメント
Rik
Rik 2020 年 11 月 29 日
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 2020 年 11 月 29 日
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

サインインしてコメントする。

回答 (1 件)

Manas
Manas 2022 年 8 月 1 日
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);

カテゴリ

Help Center および File ExchangeLighting, Transparency, and Shading についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by