Get the closest number
- by user183089
Hi,
i am implementing a little Black Jack game in C# and i have the following problem calculating the player's hand value.
the problem is
Ace may have value of 1 or 11
so if the players has three cards and one Ace if the sum of the cards is <= 10 Ace will have value of 11(Sorry for who doesn't know the scope of the game is to reach 21 with the sum of the cards)
Other way value of 1
Up to here is easy
Now lets assume i do not know how many Aces the player has got and the game is implemented giving the possibility to the dealer to use more than one deck of cards. the user may have in one hand even 5,6,7,8 ... aces.
What is the best way(possibly using Linq) to evaluate all the aces the player has got to get the closest combination to 21 (in addition tot he other cards)?
I hope i have been clear thanks for your help.