필터 지우기
필터 지우기

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 CenterFile Exchange에서 Lighting, Transparency, and Shading에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by