Questions tagged [blackjack]

Card Game – Where the aim is to get your cards closer to 21 than the dealer, while not going over. J, Q, K are worth 10. A are either 11 or 1.

Further Information

394 questions
96
votes
4 answers

Convert an array into an ArrayList

I'm having a lot of trouble turning an array into an ArrayList in Java. This is my array right now: Card[] hand = new Card[2]; "hand" holds an array of "Cards". How this would look like as an ArrayList?
Saatana
  • 1,107
  • 2
  • 8
  • 7
48
votes
4 answers

Deleting Last Item from Array of String

I'm working on a simple blackjack game project. Firstly I create the array of cards: string[] deck = { "2", "3", "4", "5", "6", "7", "8", "9", "10", "J", "Q", "K", "A", }; than I multiply it 4 and given deckNumber: newDeck = Enumerable.Repeat(deck,…
JayGatsby
  • 1,331
  • 4
  • 18
  • 36
15
votes
7 answers

Is there an elegant way to deal with the Ace in Blackjack?

My kiddo had a homework assignment to write Blackjack in Java. I helped him a little but for the most part he did it all himself and it actually plays pretty well. He even caught an error I didn't see in how it was calculating hand values. However,…
John Munsch
  • 19,481
  • 8
  • 40
  • 72
6
votes
1 answer

How do I break out of 2 loops? (Python)

There has to be a better way to do this... Any ideas? This is a basic blackjack game for CS1. 2 main things bugging me: How do I break out of the loop twice? Ex. The dealer wins, and and then it asks "stay or hit?", because it's still on the…
maria
  • 81
  • 6
6
votes
2 answers

initializer-string for array of chars is too long error

I am working on a BlackJack Game using C++, and I have the following piece of code within it where I am getting an error typedef struct { int value; char suit[8]; char name[8]; }Deck; Deck Cards[52] = {{ 1,"Ace","Hearts"},{ 2,…
Praveen Gowda I V
  • 8,920
  • 4
  • 39
  • 49
5
votes
5 answers

Calculating hand values in Blackjack

I am implementing a little Black Jack game in C# and I have the following problem calculating the player's hand value. Aces may have a value of 1 or 11 based on the player's hand. If the player has three cards and one ace, then if the sum of the…
GigaPr
  • 4,788
  • 14
  • 55
  • 76
5
votes
2 answers

Javascript blackjack game

I'm working on a JavaScript blackjack game for a class of mine. So far I have a method to create stacks for the deck, the player and the dealer. Another creates the deck, one creates each card as an object. Another shuffles, one deals out cards from…
5
votes
1 answer

Creating a multiplayer blackjack game

I'm very new to python and have been trying to make a multiplayer blackjack game on python for a while now. I've been running into lots and lots of problems and was wondering if you guys could help me with them. import random def total(hand): …
user1561751
  • 67
  • 1
  • 2
4
votes
1 answer

Why is my code not counting my held cards correctly?

Hey so i am coding for an assesment and it is due very soon, i made a piece of code that is suppose to add up the value of my held cards, i am using unity and i have put all the sprites in a certain order(I put all of the aces first, then the 2's…
OGXirvin
  • 41
  • 3
4
votes
1 answer

What does spaces.Discrete mean in OpenAI Gym

I try to learn MC- Monte Carlo Method applied in blackjack using openAI Gym. And I do not understand these lines: def __init__(self, natural=False): self.action_space = spaces.Discrete(2) self.observation_space = spaces.Tuple(( …
doob
  • 49
  • 1
  • 4
4
votes
3 answers

Alternate use of switch function

I'm writing a program to simulate the game of blackjack, and I've been using switch to go through menus. It's been working nicely, but I'm wondering if you can extend switch to involve multiple cases. For example, there are lots of outcomes to each…
Brian
  • 167
  • 1
  • 9
3
votes
3 answers

Calculating Probability of Dealer Busting S17 in Blackjack

I'm writing a java project for the university where am I exploring blackjack from the math point of view. Right now I've stumbled upon the probability of dealer busting (depending on the up card) for 8 decks in a shoe. So I got those results…
Aether
  • 31
  • 3
3
votes
1 answer

Dealing One Card to Each Player Before Dealing a Second Card - Blackjack Game in Python

I have made the following code in Python. Where deck = deck_of_cards(). My question is how to I fix the second function so that it must deal a first card to each player before dealing a second card. The way it is right now seems to deal two cards to…
user9042207
  • 101
  • 1
  • 8
3
votes
3 answers

How to find the number of ways to get 21 in Blackjack?

Some assumptions: One deck of 52 cards is used Picture cards count as 10 Aces count as 1 or 11 The order is not important (ie. Ace + Queen is the same as Queen + Ace) I thought I would then just sequentially try all the possible combinations and…
user5597655
3
votes
1 answer

C++ random_shuffle() not behaving properly

I have a Blackjack program that uses a vector full of integers to simulate a card deck: vector deck; and have populated it with 1-10: for (int i=0; i<=4; ++i) // Populate the deck with 1-10 { for (int c=1; c<=10;++c) { …
built1n
  • 1,428
  • 14
  • 24
1
2 3
26 27