hi freinds,
Plz help me how to set the value of ace in Blackjack game.

Recommended Answers

All 3 Replies

Wouldn't you just set the value to one higher then King e.g. King = 13, Ace = 14.

No, because in BlackJack (21) 10 - King are all 10 and an Ace is either 1 or 11.

I would say, when an Ace shows up, total the rest of the cards, then decide how much to assign to the Ace depending on the difference between the current total and 21.

Remove any Aces from your hand, sum up whats left and if that total is less than 11 then you can make the Ace worth 11 without busting.

if sum(cards-Ace) < 11
    Ace = 11 
else
    Ace = 1
endif
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.