Sorting Values my Integer and Decimal Values

4 visualizzazioni (ultimi 30 giorni)
MattLab
MattLab il 30 Set 2022
Risposto: Chunru il 30 Set 2022
Hello, I am attempting to create a poker hand Analyser. Right now I have all cards (2-A) correlated to an integer value (2-14). Then depending on their Suite (Heart, Diamond,Spade,Club) I add a decimal value ( .1, .2, .3, .4). Is there a way to have my code differentiate between the integers and decimal values?
For ex.) A pair would be 8.1 and 8.2.
and a flash would be 2.1 , 3.1 , 4.1, 5.1, 6.1
I want to say something like:
if integer= integer then hand is a pair
if deciemal = deciemal then we have a flush
Thank you

Risposte (1)

Chunru
Chunru il 30 Set 2022
p = [8.1 8.2];
if floor(p(1)) == floor(p(2))
disp("A pair.")
end
A pair.
f = [2.1 , 3.1 , 4.1, 5.1, 6.1];
if all(abs(diff(mod(f,1))) < 1e-5)
disp("A Flush")
end
A Flush

Categorie

Scopri di più su Get Started with MATLAB in Help Center e File Exchange

Tag

Community Treasure Hunt

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

Start Hunting!

Translated by