![]() |
JavaScript programmers...
I've finished my very first JavaScript program for my final exam. It's very basic and I would like to continue on it farther. Right now all it does is shuffle and deal a deck of cards. The next step I would like to do is for it to recognize poker hands. Could anyone give me the thought process for doing so?
I think it will be very complex. For each card I would have to split it into a value and suit. I would also have to separate the players hand with a variable for each card to be able to compare. Thoughts? https://drive.google.com/open?id=1qz...kuCfTgBsB7vUfk |
I remember learning Java, we did some weird programming just to say we could do it. Wish I could help. I learned enough to change existing programs to do what I wanted to. Maybe find a JavaScript poker program and open it for inspiration, just don't copy it
|
Quote:
Googling poker hands and their value would be a normal thought process. :2 cents: |
Quote:
I would have then have to break down each card into value and suit. I'd also have to break down each card in the players hand. Xn1 = 3 ; Xs1 = C Xn2 = 4 ; Xs2 = D Xn3 = 3 ; Xs3 = S Xn4 = T ; Xs4 = C Xn5 = K ; Xs5 = D Then I'd have to compare Xn1 to Xn2,3,4,5. Xn2 to Xn3,4,5. Xn3 to Xn4,5. Xn4 to Xn5. For each Xn that matches another variable, N, would increment telling the # "of a kind". Likewise a flush would be easy to tell if comparing all the Xs and S = 5. This seems easy enough but more complicated when I try to think through for a straight or full house or two pair. Also what do you mean by googling poker hands and their value? |
Programming is not about the language you use; it's about figuring out how to do this stuff on your own.
:2 cents: |
Quote:
|
Quote:
:1orglaugh |
|
Quote:
https://previews.123rf.com/images/ju...ion-vector.jpg Quote:
|
Give all winning poker hands a numeric value starting with 999 for a royal flush downward to 50 for a pair. Keeping a original numeric value for the card itself... 1-14, remembering aces are high and low card depending on application. (ace high straight beats a king high straight)
Then you can also evaluate high card on a draw. You will have a bunch of math evaluations on/for condition, especially the ace. Java is probably the right choice for this stuff because of it's flexibility and minimal code. |
Quote:
|
All times are GMT -7. The time now is 05:54 AM. |
Powered by vBulletin® Version 3.8.8
Copyright ©2000 - 2025, vBulletin Solutions, Inc.
©2000-, AI Media Network Inc123