Black Jack input and output

Hello, I am writing a function called check_possibilities.m where it takes as input the vector possibilities, and returns as output either I get stuck on the largest element of possibilities which is greater than or equal to 17, and less than or equal to 21.

3 commentaires

Walter Roberson
Walter Roberson le 7 Déc 2022
What do the elements of Arg1 represent? Do they represent individual cards, or do they represent the total for a series of hands that the dealer is running simultaneously?
If they are hands that the dealer is running simultaneously, then is the question whether all of the hands are bust, or if at least one hand needs another card, or else (at least one hand is hold and no hands need cards) ?
Or if they are hands that the dealer is running simultaneously then should the output be a vector reflecting what to do with each hand, bust (999), take another (-999) or hand value if in the range 17 to 21 ?
If it is a list of cards, then does the function need to decide whether an ace should be treated as 1 or 11 or has something already done that?
Walter Roberson
Walter Roberson le 7 Déc 2022
So if "all" elements of the vector are greater than 21 return scalar 999, if "all" elements are 16 or lower return scalar -999 and otherwise return max of the vector?
Walter Roberson
Walter Roberson le 7 Déc 2022
Suppose that the vector of possibilities is [7 17] . Should it say "Oh, at least one value is in the range 17 to 21, so hold" ? Or should it say "Oh, at least one value is not in that range, so ask for another card" ?
If the current values were [11 21] you would certainly want to hold, but at [7 17] you might want to take another card in hopes of getting higher than 17 without going bust.

Connectez-vous pour commenter.

Réponses (1)

Arif Hoq
Arif Hoq le 7 Déc 2022
try this:
a=[9 13];
output_1=check_possibilities(a)
output_1 = -999
b=[23 34];
output_2=check_possibilities(b)
output_2 = 999
c=[9 20 19 22];
output_3=check_possibilities(c)
output_3 = 20
function y = check_possibilities(Arg1)
if min(Arg1) > 21
y=999;
end
if min(Arg1) < 21
y=-999;
end
if max(Arg1(Arg1>=17 & Arg1<=21)) >=17 & max(Arg1(Arg1>=17 & Arg1<=21))<=21
y=max(Arg1(Arg1>=17 & Arg1<=21));
end
end

Catégories

En savoir plus sur Card games dans Centre d'aide et File Exchange

Question posée :

le 7 Déc 2022

Commenté :

le 8 Déc 2022

Community Treasure Hunt

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

Start Hunting!

Translated by