Hey everybody, I am trying to write a very simple blackjack code where the player either hits 21 and wins, or busts and loses. So far i have this,
function card = dealcard;%This program will allow someone to draw a card at random from a full deck
and see what that card would be. you can go through the whole deckpersistent dec; %persistent makes it so matlab stores this variable
if length(dec)<53 dec=[1:52]; %one deck of cards
dec=dec(randperm(length(dec))); %this shuffles the cards
end; card=dec(end);
I do not know how to define the cards as being an ace, 2,3,…queen, and king. If anyone could help me with this that would be great. Thank you.
Best Answer