Android Example 5 Card Poker Scoring

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.
 

Attachments

  • cards.zip
    37.4 KB · Views: 705
  • poker scoring v0.91.zip
    10.2 KB · Views: 448
  • poker scoring v0.92.zip
    10.2 KB · Views: 560
Last edited:

JTmartins

Active Member
Licensed User
Longtime 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.
 

ac9ts

Active Member
Licensed User
Longtime 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.
 
Top