Black jack function for hiding dealers card

1 次查看(过去 30 天)
I have the game pretty much completed. its a text based version of blackjack just focusing on random integers since suits dont really matter.
I need a function to store the hole card, display an empty string (ex: __ / 9 / 2) and then display the value once the player "stays".
Thank you!

采纳的回答

Voss
Voss 2021-12-1
I'll assume the dealer's cards are stored as an array with the hole card being first. Then here's a function that takes two input arguments: (1) dealer's card array, (2) a logical indicating whether to hide the hole card, and returns a character array representing the cards:
function str = get_str(d,do_hide)
d = num2cell(d);
str = sprintf('%2d / ',d{:});
str(end-2:end) = [];
if do_hide
str([1 2]) = '_';
end
end

更多回答(1 个)

Image Analyst
Image Analyst 2021-12-1
Wouldn't that be sprintf() or fprintf()?
  2 个评论
Colin Amicon
Colin Amicon 2021-12-1
No so in the beginning it deals, and then it needs to store the card but not show the value of the card until the end. Does that make sense?

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Card games 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by