JavaScript programmers...

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • GFED
    Confirmed User
    • May 2002
    • 8121

    #1

    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
    https://www.flow.page/savethechildren
  • Vendzilla
    Biker Gnome
    • Mar 2004
    • 23200

    #2
    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
    Carbon is not the problem, it makes up 0.041% of our atmosphere , 95% of that is from Volcanos and decomposing plants and stuff. So people in the US are responsible for 13% of the carbon in the atmosphere which 95% is not from Humans, like cars and trucks and stuff and they want to spend trillions to fix it while Solar Panel plants are powered by coal plants
    think about that

    Comment

    • blackmonsters
      Making PHP work
      • Nov 2002
      • 20964

      #3
      Originally posted by GFED
      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.

      Free Open Source Live Aggregated Cams Script (FOSLACS)

      Comment

      • GFED
        Confirmed User
        • May 2002
        • 8121

        #4
        Originally posted by blackmonsters
        Googling poker hands and their value would be a normal thought process.

        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?
        https://www.flow.page/savethechildren

        Comment

        • blackmonsters
          Making PHP work
          • Nov 2002
          • 20964

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

          Free Open Source Live Aggregated Cams Script (FOSLACS)

          Comment

          • GFED
            Confirmed User
            • May 2002
            • 8121

            #6
            Originally posted by blackmonsters
            Programming is not about the language you use; it's about figuring out how to do this stuff on your own.

            Thanks Yoda.
            https://www.flow.page/savethechildren

            Comment

            • blackmonsters
              Making PHP work
              • Nov 2002
              • 20964

              #7
              Originally posted by GFED
              Thanks Yoda.
              Yo mamma!

              Free Open Source Live Aggregated Cams Script (FOSLACS)

              Comment

              • ghjghj
                So Fucking Banned
                • Jun 2005
                • 3770

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

                Comment

                • just a punk
                  So fuckin' bored
                  • Jun 2003
                  • 32393

                  #9
                  Originally posted by blackmonsters
                  Googling poker hands and their value would be a normal thought process.
                  Indeed. He all you need to know as a coder:



                  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.
                  Obey the Cowgod

                  Comment

                  • VRPdommy
                    Too lazy to set a custom title
                    • Oct 2014
                    • 13000

                    #10
                    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.

                    Comment

                    • ghjghj
                      So Fucking Banned
                      • Jun 2005
                      • 3770

                      #11
                      Originally posted by CyberSEO
                      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.

                      Comment

                      Working...