LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

OO Based program to play 1 Player Blackjack

Hey, 

 

At our user group we had a challenge to create a program to play a game of Blackjack. I knocked this up quite quickly so might not be perfect and doesn't fulfil all of the points but thought it might be worth sharing.

 

P.S If I've posted it in the wrong part of the new forums I apologise, I just have no idea where/how to post example programs and things that might be of interest. 

 

Challenge: Blackjack
Create a VI to simulate a game of Blackjack/twenty-one.
When play is started two cards are dealt at random. The cards can be A, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, J, Q, K and each is equally likely (to keep it simple you do not need to worry about suits or the same card being dealt twice). The player then has the option to stick or twist. If they twist another card is dealt. The aim of the game is to get as close to 21 as possible without exceeding it. The VI should count the number of wins, losses and blackjacks achieved by the player. Other rules to note:
- Ace can be 1 or 11 points
- Face cards are all counted as 10 points.
- All other cards are counted as the numeric value shown on the card.
- “Blackjack” is getting 21 with the first two cards.
- Scoring higher than 21 results in a loss.
- A player must twist until the cards total 17 or more.

 

Daniel Harryman MEng
CLA, CPI
Download All
Message 1 of 10
(4,517 Views)

Hey, 

 

At our user group we had a challenge to create a program to play a game of Blackjack. I knocked this up quite quickly so might not be perfect and doesn't fulfil all of the points but thought it might be worth sharing.

 

P.S If I've posted it in the wrong part of the new forums I apologise, I just have no idea where/how to post example programs and things that might be of interest. 

 

Challenge: Blackjack
Create a VI to simulate a game of Blackjack/twenty-one.
When play is started two cards are dealt at random. The cards can be A, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, J, Q, K and each is equally likely (to keep it simple you do not need to worry about suits or the same card being dealt twice). The player then has the option to stick or twist. If they twist another card is dealt. The aim of the game is to get as close to 21 as possible without exceeding it. The VI should count the number of wins, losses and blackjacks achieved by the player. Other rules to note:
- Ace can be 1 or 11 points
- Face cards are all counted as 10 points.
- All other cards are counted as the numeric value shown on the card.
- “Blackjack” is getting 21 with the first two cards.
- Scoring higher than 21 results in a loss.
- A player must twist until the cards total 17 or more.

 

Daniel Harryman MEng
CLA, CPI
0 Kudos
Message 2 of 10
(4,487 Views)

The last rule only applies to the dealer, a player can stop at any time. At least in the real game. 🙂

/Y

 

G# - Award winning reference based OOP for LV, for free! - Qestit VIPM GitHub

Qestit Systems
Certified-LabVIEW-Developer
0 Kudos
Message 3 of 10
(4,512 Views)

I guess it's good I didn't get around to implementing that feature then 😛 

Daniel Harryman MEng
CLA, CPI
Message 4 of 10
(4,507 Views)

"Twist"  ???

 

Never heard that one before.  I've only heard it as "hit".

Message 5 of 10
(4,486 Views)

@RavensFan wrote:

"Twist"  ???

 

Never heard that one before.  I've only heard it as "hit".


Can be dangerous around drunk people when you say "hit me!" 😄

/Y

G# - Award winning reference based OOP for LV, for free! - Qestit VIPM GitHub

Qestit Systems
Certified-LabVIEW-Developer
Message 6 of 10
(4,480 Views)

Hello,

I'm really interested to see the interface you have created by only run LabVIEW 2014. Could you please save and upload the file as in a 2014 version??

 

Thanks and kudos on the program!!

0 Kudos
Message 7 of 10
(4,332 Views)

Hi Kokos,

 

I've uploaded the 2012 version. This should work for you. 

 

Many thanks,

 

Dan

Daniel Harryman MEng
CLA, CPI
0 Kudos
Message 8 of 10
(4,325 Views)

Many thanks,

 

and well done this works perfectly!

0 Kudos
Message 9 of 10
(4,312 Views)

@Yamaeda wrote:

@RavensFan wrote:

"Twist"  ???

 

Never heard that one before.  I've only heard it as "hit".


Can be dangerous around drunk people when you say "hit me!" 😄

/Y


Not as dangerous as "Knocking Up Quickly"

 

Time to pull out the old riffle.vi  Some of the provisos in the challenge are easy to account for anyhow.  Sling that to you LUG!21 shoe.png


"Should be" isn't "Is" -Jay
Message 10 of 10
(4,307 Views)