LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Poker simulator

my program will deal 5 random cards from a deck of 52 cards and display them on the interface(each card includes information about its suit and numbers,and no card can be repeated)

sufferring issue in I use HEX so card number is 1-9,A,B,C,D 

how to transform card numbers to A,2,3,4,5,6,7,8,9,10,J,Q,K

0 Kudos
Message 1 of 11
(612 Views)

Hi iron,

 


@ironaaron wrote:

sufferring issue in I use HEX so card number is 1-9,A,B,C,D 

how to transform card numbers to A,2,3,4,5,6,7,8,9,10,J,Q,K


You can "transform" by using a lookup table...

 

Why do you use "HEX" instead of ordinary integer datatype? (Posting from mobile, so no access to your VI.)

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 2 of 11
(603 Views)

Hi iron,

 

suggestion to improve your VI:

Use LUTs (LookUp Tables)!

 

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 3 of 11
(561 Views)

@ironaaron wrote:

my program will deal 5 random cards from a deck of 52 cards and display them on the interface(each card includes information about its suit and numbers,and no card can be repeated)

sufferring issue in I use HEX so card number is 1-9,A,B,C,D 

how to transform card numbers to A,2,3,4,5,6,7,8,9,10,J,Q,K


You can make it more fun by adding some images. Generating the hand is the easy part, scoring multiple hands is a more fun code challenge : ) 

Jay14159265_0-1737229469304.png

poker.png

 

PS: Let me know if you want to do Roulette, that is my favorite. 

 

______________________________________________________________
Have a pleasant day and be sure to learn Python for success and prosperity.
0 Kudos
Message 4 of 11
(547 Views)

I would cache the LUT once at the start of the program. This will be so fast that measure timing is pointless.

 

altenbach_1-1737230061483.png

 

 

  • You can replace the format with a bundle if you wan the old cluster output.
  • As has been mentioned, cards are not hexadecimals, because a 10 would turn into a A, to be confused with an Ace.
  • Often suits are ordered with the Ace last (see e.g. the first picture here), simplifying the code.
  • Cards are integers and there should be very little orange anywhere (except for the dice if you need it)
  • There is no need to maximize the diagram to the screen.
  • Of course this code is incomplete. You might want to shuffle the deck once, then keep drawing cards as needed, simulating a real game.
  • This is more like a programming skill exercise. It might be much nicer (and simpler!) to use a picture ring with 52 card images. I have seen them, so search the web. (EDIT: Jay just posted an example while I was writing, so see post above!)
0 Kudos
Message 5 of 11
(545 Views)

Partial deck how to create image, need to use picture ring vi.?(unfortune don't has this vi)

Index array how to connect none double data in n-dimension array

tks your reply

0 Kudos
Message 6 of 11
(500 Views)

Learned look up table form tks

0 Kudos
Message 7 of 11
(497 Views)

your conclusion really helpful for me tks a lots!

 

0 Kudos
Message 8 of 11
(494 Views)

@ironaaron wrote:

Index array how to connect none double data in n-dimension array


What does that mean? (e.g. what is "none double data"?)

 

You posted three different replies, but we don't know what post you are replying to. It helps to quote parts of the relevant post.

 

altenbach_0-1737307554176.png

 

0 Kudos
Message 9 of 11
(467 Views)

@ironaaron wrote:

Partial deck how to create image, need to use picture ring vi.?(unfortune don't has this vi)

Index array how to connect none double data in n-dimension array

tks your reply


1) This is a way to load a png file to a LabVIEW picture object. There are many ways to programmatically modify the image once it is loaded. Once you load a picture you can make it constant and save it with the VI. 

snip.png

2) Not sure what you are asking, maybe this helps? 

 

2.png

______________________________________________________________
Have a pleasant day and be sure to learn Python for success and prosperity.
0 Kudos
Message 10 of 11
(429 Views)