Android Example 5 Card Poker Scoring

Discussion in 'Tutorials & Examples' started by JakeBullet70, Oct 1, 2013.

  1. JakeBullet70

    JakeBullet70 Well-Known Member Licensed User

    Hi all.

    Here is a BAS module to do 5 card poker scoring. Its some ugly code but it works.

    I have promised myself I was going to re-write this code for over a year but cannot seem to find the motivation as it works. Included is a sample project of how to call it.

    Hope this helps someone out there.

    poker_scoring.zip = sample project and BAS module
    cards.zip = includes card graphics that are FREE to use

    V0.91 - fixed bug in CheckStraightFlush and CheckRoyalFlush on what cards where used for scoring. Was: arrScoreCards = Array As Int(1,1,1,0,1) and needed to be arrScoreCards = Array As Int(1,1,1,1,1)

    V0.92 - fixed bug in CheckStraight, It was not considering that an ACE was a legal card.
     

    Attached Files:

    Last edited: Dec 6, 2013
  2. JakeBullet70

    JakeBullet70 Well-Known Member Licensed User

    bump - fix to what cards where used for scoring. See 1st post
     
  3. JakeBullet70

    JakeBullet70 Well-Known Member Licensed User

    bump - fixed bug in straight code. See 1st post
     
  4. JTmartins

    JTmartins Active Member Licensed User

    Interesting. I will try this later.

    I have a personal project for a poker game. Most of it is working, shuffle, dealing, displaying the flop, turn and river. The RNG was actualy an interesting learning project, and after several different approaches it seems to be very close to real thing, althoug I still intend to add some extra crazyness as using some sensor values (what can be more random that that ?) to help in the RNG algorithm.

    Missing was precisely the score. I've found some Java libs for that, but never tryed to convert a java lib to be used in B4A, so as it's is a personal project not related to my work, I put it aside for when I have some extra time and patience to dig in.

    I was thinking in either make it a hand replayer or going deeper and make something where people can join over Wi-fi and play against each other (with one device acting as server)...it's an ongoing thing to learn a little bit more.

    I will come back here with some feedback as soon as I put some time aside for testing this.

    Many thanks for sharing.
     
  5. JakeBullet70

    JakeBullet70 Well-Known Member Licensed User

    No worries, let me know what you think.
     
  6. merlin2049er

    merlin2049er Well-Known Member Licensed User

    Great, I'm messing around with a video poker game.
     
  7. ac9ts

    ac9ts Active Member Licensed User

    I just finished something similar. I see you sort the cards when looking for straights. I would recommend always sorting the hand. It made the detection easier for pairs, 3-of-a-kind, etc. where you just have to look for adjacent elements to have the same value rather then comparing 1 element to the remaining 4.
     
  8. JakeBullet70

    JakeBullet70 Well-Known Member Licensed User

    WOW, something I wrote when I 1st started B4A. Glad to see it is useful. :)
     
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice