Now, a year or two after writing that algorithm, I realized that most poker games out there really involve choosing the best five card poker hand from a hand containing seven cards. Texas Hold'Em. Seven Card Stud. These games all consist of selecting five cards from a pool of seven that yield the best poker hand possible. With my older algorithm, I had to loop over all 21 possible ways to choose five cards from seven, saving the best hand as the one to keep. This took way too much compute time, and I decided that there had to be a better way to evaluate seven card hands.
So, I totally rewrote my algorithm from scratch. I worked out another clever algorithm for evaluating seven card hands, mainly involving massive lookup tables and clever bit manipulations. When I was finished (after about four months work on and off), I had a new algorithm that blew my initial code right out of the water. I was quite happy with it, and used it in my simulator code to work out statistical info and playing strategies for the betterment of my own game play. However, due to the lengthiness of the code (and my own personal laziness), I never put this new algorithm and code on my website.
Well, over the past years, I occasionally get emails from people showing interest in my five card evalautor. Some are college students, some are math and poker geeks, some are people trying to write their own evaluator. I try to answer their questions, and explain how my algorithm works. I will also get people asking me if I ever wrote a seven card evaluator, and I tell them "yes", but I've just never put it on my website, and that it is a lot more complicated than the five card version.
Fast forward to November 2005. I look in my inbox one day, and there is an email from a programmer that works for a Canadian company called Poker Academy that makes poker software. Their flagship product is a tool/simulator called Poker Academy Pro. Turns out they found my website, and wanted to know how fast my poker simulator was. They also wanted to know if I had written a seven card evaluator as well. When I let them know the whole story, they then asked if I would mind letting them test my evaluator against theirs, so see if mine was faster. Theirs was written in Java, but mine was written in 'C'. However, they felt confident they could port it to Java quickly in order to test it. Now, I hadn't looked at my code in quite a while, and I felt it certainly wasn't ready for "public viewing" by another coder (my code comments were few and far between). Nevertheless, I found my code and sent to him as a giant tarball. The very next day he emails me back saying they ported the code and it benchmarked about three times faster than theirs. Not too shabby!
They then asked if I would be interested in licensing my algorithm to them. They put me in touch with their manager, and we worked out an arrangement with them. I got two nice Poker Academy shirts, three copies of their current software, a copy of the new version that incorporates my algorithm (when it releases), my name in the manual and the software credits, and a thousand bucks. Pretty nifty for some moldy code I wrote years ago that I never thought would see the light of day :)
-- Cactus Kev