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.
Questions tagged [blackjack]
464 questions
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,518
- 14
- 25
3
votes
4 answers
Creating an AI for BlackJack
I am trying to make a Blackjack game! I am successful with player interaction! However, I decided to step it up and do some AI so I can play against AI, and have more of a battle, so to speak.
My main issue though, is I've sat here for about an…

Twister1002
- 559
- 1
- 9
- 26
3
votes
1 answer
how to I get rid of undefined(s) and the other problems in my code?
I've tried this a thousand different ways in a thousand different times and my JS code won't come out the way I want it. When I run it in the Mozilla scratchpad, I get "userHand is undefined" and the second printHand shows as undefined, too. Could…

kizlink
- 165
- 1
- 6
2
votes
3 answers
Why is user_score and computer_score not being added to? (i think)
So I'm, coding a blackJack game,and I made a list called user_score and computer_score. I used the random module to choose a random int from a list called cards. But when I use .append() to add the random choice from cards, it doesn't appear to be…

SmallComputer12
- 47
- 7
2
votes
0 answers
object has no attribute 'to_components'
I'm trying to make a blackjack command for my Discord Bot in python, I'm making small codes and little by little testing and improving, see below:
import discord
from discord.ext import commands
from discord import app_commands
import random, json,…

Luca
- 21
- 3
2
votes
0 answers
Change parameter of one object in array based on user's choice in React
I'm trying to write a simple app that will simulate a hand in blackjack (previous question here that will let the user decide if they want to get 1 or 11 points if they get an ace.
Now, because I have an array of cards where I set the values of the…

01nowicj
- 67
- 5
2
votes
1 answer
ValueError Versus TypeError, Why?
The Error output: "ValueError: invalid literal for int() with base 10: 'yes'"
I know it is obvious that I AM WRONG, but I do not understand why. When I try to convert a string to an int, I expected to get a TypeError, not a ValueError.
Please…

Infinite Grasp
- 44
- 7
2
votes
3 answers
BlackJack Algorithm
What is the general alogirthm for a BlackJack game ?
I'm writing one in c++ and end up having WAY too many if statements which ruin the whole thing.
The project is a win32 GUI application, and Im posting the message loop as well as the part of the…

viraj
- 1,784
- 4
- 35
- 52
2
votes
1 answer
How can I print my ascii cards side by side?
I made a simple blackjack game using python. I made the rest of the game but i am struggling to put in the ascii cards, so this is just a fraction of the code. I have tried putting * len(phand) at the end of the append lines. While this does give me…

ORKUN CIRAK
- 21
- 4
2
votes
2 answers
Drawing unique cards from a deck for a game of BlackJack in Python
I'm making a multi-player game of blackjack and having been encountering issues getting the code (in python) to deal unique cards to multiple players. The code below has been dealing the same set of cards to all players.
An example of the results…

Shez
- 21
- 1
2
votes
2 answers
"Variable" not accessed
I'm working on a Blackjack program and everything works fine except my PlayAgain() function. In this function, im supposed to reset my variables but when i do so, the variables are discolored in a darker blue and when hovered over, it says…

xXBoss TurtleXx
- 23
- 1
- 1
- 4
2
votes
2 answers
Sum of a predefined List F#
I am a beginner F# learner, currently trying some Lists actions within a BlackJack F# implementation.
I am trying to sum the elements of a list which I created as follows:
let cardsvalue (k: Cards): List =
match k with
|Ace -> [1;11]
…

Billy Fitt
- 89
- 6
2
votes
2 answers
Moving a specific value to the end of a randomly populated array
I am creating a blackjack scoring method and I'm trying to move the Ace(s) to the end of the array in order to count it last. How would I do this? Because this is not working
if hand.include?("Ace")
hand.map{ |card| hand.last(card) if card ==…

Taylor Tompkins
- 71
- 2
2
votes
1 answer
Issue assigning variable in blackjack 'hit or stay' function. Looping incorrectly?
I'm new to programming. I'm trying to create a 'hit or stay' function in a simple blackjack game taking user input in a try/except/else statement, which is also nested inside a while loop checking to make sure the user input is either 'h' or 's'.…

Joe Connor
- 62
- 1
- 6
2
votes
1 answer
What would be your recommendation for dealing a black jack hand?
I am a beginner and have been tasked (as part of a course) to build a black jack game.
My initial code can be found below. The part I am stuck with is when I get to the Deck class and have to create the Deal method. What I am struggling with is how…

vince
- 27
- 5