MATLAB Answers

How can i make a 1 count as 11 if its best in blackjack

6 views (last 30 days)
Matwiz
Matwiz on 24 Jan 2020
Answered: Walter Roberson on 24 Jan 2020
i want to create a function that optimally calculates a hand of cards according to blackjack rules
this is what i have so far, but it doesnt seem to be able to count ace as 11
does any1 know why the if sentence doesnt work or what i could do instead?
function score = blackjack(hand)
hand = [10 1]
score = sum(hand);
if score <= 11 & hand==1
score = score + 10;
end
if (score > 21)
score = 0;
end

  0 Comments

Sign in to comment.

Accepted Answer

Walter Roberson
Walter Roberson on 24 Jan 2020
if score <= 11 && ismember(1, hand)

  0 Comments

Sign in to comment.

More Answers (0)

Sign in to answer this question.

Products


Release

R2019b

Translated by