How can i make a 1 count as 11 if its best in blackjack
2 views (last 30 days)
Show older comments
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
Accepted Answer
More Answers (0)
See Also
Categories
Find more on String in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!