blackjack adding another number to a vector in a while loop & input words for a if loop
Ältere Kommentare anzeigen
im trying to make a simple vertion of blackjack and im not sure how to give another card to the players hand on a hit i am also having difficulty having a word input turn into a if loop for the game any help would be greatly appreciated
spade = 1:13;
diamond = 1:13;
heart = 1:13;
clubs = 1:13;
cards = [clubs heart diamond spade];
suffledcards = cards(randperm(numel(cards)));
playerhand = suffledcards(1:2);
dealerhand = round(13*rand()+8);
sum = 0;
for i=1:length(playerhand)
sum = playerhand;
end
while(sum < 22)
disp(sum)
A = input("stand or hit: ");%fix error
if A == stand
break
end
if A == hit
%give another card
end
end
%display win or lose
Akzeptierte Antwort
Weitere Antworten (0)
Kategorien
Mehr zu Clocks and Timers finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!