Saturday 23 February 2013

A real life project: Poker Game

I was recently involved in a discussion about how an implementation of a poker game might work out and I've decided to run with the idea. I've never created anything useful in my spare time before, I prefer to read and tinker with ideas, so this is a big undertaking for me. Trying to find the time to see it through will be a challenge because I have a) a day job and b) a life outside of development, but, the more I think about this project the more interesting it sounds so, yeah, let's give it a go.

There's a chance that I'll tinker with this idea for a while and then move onto something else, so I need some motivation:
  • I'm a fan of the GOOS book and I've been thinking about building the project they work on. There's lot of similarities between the two project so it's a good chance to follow through on that
  • My day job limits me to stuff that is necessary to there, so this is a chance to work with technologies that I wouldn't normally
  • Blogging it gives me a something I've never had before, a start to finish record of a project.

So there's the idea and the motivation, all that's left is to go ahead and do it, but first the sales pitch.


Sales Pitch

It's a poker game with developers in mind. Developers will be able to write a poker player in any language that they choose and have their algorithm compete against other developers algorithms in a poker game.

It's going to look something like this


The dealer will handle all of the usual dealer tasks, like dealing the cards, managing the pot and telling the players when it's their turn. Once there is a common language defined (in this case poker terms like Bet, Raise etc.) the dealer and the players can interact.

Some Initial Analysis

I don't think this is going to be a trivial project, which is one of the things that attracts me to it. There will have to be communication between the dealer and the players and allowing different software components to communicate like this is a new area for me. Another big area is the poker logic.

The communication between the players and the dealer

There's two challenges in this area. Firstly the communication will have to be two way so all components will need to both listen and send messages at the same time. Keeping the dealer and all the players synchronised should be a bit of work. I'll have to work to avoid things like one waiting indefinitely for another. 

Secondly, there will need to be some privacy in the communication when the dealer deals the initial hands; each player should only see their own hand. The simplest type of communication would be for everyone to poll a database table, but that would allow all the players to see all the hands. In the GOOS book they use the XMPP protocol to handle messaging; using XMPP would allow me to send direct messages and would (I think) give me a nice messaging setup. I haven't done anything like this before so I need to do some swotting up on messaging in general first.

Whatever I end up using is going to have to meet these two requirement:

  • Two way communication 
  • Private communication


Poker logic

Dealing from the deck of cards, keeping track  of the pot, keeping track of the game and figuring out who's hand has won. A quick look around the web tells me that none of this stuff is as easy as I would first think (nothing ever is on software, is it?) I'm already comfortable with the rules of Texas Hold 'em so knowing the business area is a bonus to me. There's lots of stuff to do here, more than I would like really so hopefully other people will have developed something similar before and there will be bits and pieces of code I can re-use out there.


So there it is, lots of work ahead but I think I'm going to like it.

No comments:

Post a Comment