How to rank cards
2 ビュー (過去 30 日間)
古いコメントを表示
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
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.
回答 (1 件)
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);
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Lighting, Transparency, and Shading についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!