GoFuckYourself.com - Adult Webmaster Forum

GoFuckYourself.com - Adult Webmaster Forum (https://gfy.com/index.php)
-   Fucking Around & Business Discussion (https://gfy.com/forumdisplay.php?f=26)
-   -   JavaScript programmers... (https://gfy.com/showthread.php?t=1315614)

GFED 07-12-2019 09:19 AM

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

Vendzilla 07-12-2019 09:51 AM

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

blackmonsters 07-12-2019 10:29 AM

Quote:

Originally Posted by GFED (Post 22500145)
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?


Googling poker hands and their value would be a normal thought process.

:2 cents:

GFED 07-12-2019 11:06 AM

Quote:

Originally Posted by blackmonsters (Post 22500192)
Googling poker hands and their value would be a normal thought process.

:2 cents:

I would think I'd have to split everything up. For instance let's say they players hand is "3C 4D 3S TC KD".

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?

blackmonsters 07-12-2019 12:51 PM

Programming is not about the language you use; it's about figuring out how to do this stuff on your own.

:2 cents:

GFED 07-12-2019 01:35 PM

Quote:

Originally Posted by blackmonsters (Post 22500266)
Programming is not about the language you use; it's about figuring out how to do this stuff on your own.

:2 cents:

Thanks Yoda.

blackmonsters 07-12-2019 02:57 PM

Quote:

Originally Posted by GFED (Post 22500286)
Thanks Yoda.

Yo mamma!

:1orglaugh

ghjghj 07-12-2019 03:04 PM

http://www.mathcs.emory.edu/~cheung/...okerCheck.html

just a punk 07-12-2019 08:13 PM

Quote:

Originally Posted by blackmonsters (Post 22500192)
Googling poker hands and their value would be a normal thought process.

Indeed. He all you need to know as a coder:

https://previews.123rf.com/images/ju...ion-vector.jpg

Quote:

Originally Posted by ghjghj (Post 22500344)

Wow, must be written by some Einstein :) The code can be reduced in about 10x times... When I was a kid, I was writing games for programmable calculators because I wasn't able to a4d a computer (hello CurrentlySobber ;)) So I wrote a 40-50 byte code to emulate a landing of space module to non-atmospheric space bodies like Moon. The program was controlling such parameters as time, speed, gravitation, the oxygen reserve, the mass of remaining fuel, the mass of the space ship, the trust vector and even the specific impulse of the rocket engine (everything straightly to physical formulas - the same ones that were used by Luna-9 or Apollo-11 modules). And all that, including the game component which allowed you to pilot the space ship was fitted in a 40-50 byte program :) In those times we have counted every single bit of code.

VRPdommy 07-13-2019 11:17 AM

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.

ghjghj 07-13-2019 11:57 AM

Quote:

Originally Posted by CyberSEO (Post 22500441)
Wow, must be written by some Einstein :)

I use this for Poker dev, poker-eval. Very fast from c. Saves a lot of effort. Can recommend.


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