Thursday, January 08, 2004
JacksOrBetter
JacksOrBetter is a video poker game I wrote for Palm OS. After spending a couple of hours playing KDE's KPoker one night, I decided I wanted to be able to play it on my PDA.
I developed JacksOrBetter using Quartus Forth. This was my first "real program" written in Forth. When I look at the code now, there are a lot of things I'd like to redo. But the code has been stable for over three years now, so why mess with a good thing?
Obviously, a video poker game isn't rocket science. The most challenging aspect of it was developing the scoring algorithm, to determine whether the hand contains a pair, a full house, a flush, or whatever. I wanted to design an algorithm that was simple. What I came up with was this:
- Initialize a thirteen-element array of "rank counts" to zero.
- Initialize a four-element array of "suit counts" to zero.
- For each card in the hand, increment the associated rank count and suit count.
- Use the rank counts and suit counts to determine the hand score. For example, if any suit count is 5, then you have a flush; if any rank count is 4, then you have four of a kind; if the rank counts contain a 2 and a 3, you have a full house; and so on.
I originally released it under the name "Videopoker". A couple of days after releasing it, I discovered there was another commercial game for Palm OS with that same name, so I renamed it. Luckily, nobody complained or sued me.
I released the code for free, under the GPL. It has had tens of thousands of downloads from PalmGear, Handango, and other outets. It was rated pretty highly. I often wonder how much money I could have made by charging $5 for it, but it is nice to know that a lot of people are enjoying it.
Update: Now available: JacksOrBetter for iPhone.


