Donation

Forgot to mention: I got my first non-anonymous donation to the FreeGuide project – Steve Fuller sent in a donation along with a request (but with no implication of linkage ;). Thanks Steve! It never ceases to amaze me how Americans will donate to projects like this. My feeling about British people (certainly myself) is that I would always think if I were going to donate to something I’d make it something “important” like Christian Aid, but actually I do think Free Software is important too (actually in order to achieve some of the same goals that Christian Aid have…). The idea of mixing philanthropy with self-interest, which seems to be natural to Americans, can feel a little dirty to us Europeans, but actually that is stupid.

Anyway, enough philosophy: Steve, your donation will be used to buy myself something nice (e.g. a GameCube game or some online poker money) and it has significantly encouraged me to get stuck back into FreeGuide development (see the previous post … guilt is rising). You never know, it might even subconsciously encourage me to get to your specific feature request sooner ;).

(The feature request was allowing favourites to match on programme descriptions and other, more specialised fields. I am wondering about how to keep the UI simple for this, but it should be do-able given some time to implement it.)

FreeGuide update

I have very little time for FreeGuide at the moment. Part of the problem is that there are lots of boring bugs to fix instead of interesting new features, and it’s hard to motivate myself to get into it. I am really keen on making it Just Work every time, but since other people have been working on the code and quite a lot of it is unfamiliar, it’s a lot of work to work out where to look to fix a problem.

Hopefully when I’ve purged this poker thing from my system I will find time to get into the latest TODO list. At the moment all my FreeGuide time is going into trying to keep up with helping people on the mailing lists. Joe Blow is doing a fantastic job of providing an initial response to lots of mails, but often people are encountering weird bugs that need a developer to get involved. It would be great if some of the other people involved in development were able to help out, but it’s quite a thankless task, and takes away time from developing…

It’s frustrating when quite a few of the bugs we have are things I fixed in a previous version that have crept in with new implementations of existing functionality. It’s taken ages to get FreeGuide stable, and recently it seems to have taken some steps backwards. My feeling is that the percentage of people who are able to install it with no problems and download listings straight away has gone down considerably. I _really_ want to fix this.

That’s why the TODO list for 0.10.4 is pure bugs. We need to make it _work_ before we make it do new stuff. Otherwise people are just going to walk away.

Saying that, the addition of a new experimental vertical listings view by Christian is really exciting. I haven’t even found time to try it out yet: I must examine my priorities. FreeGuide has always been my “main” project but I have been neglecting it as time presses in.

The Boy (as I call him) is doing well and has slept well the last 2 nights, giving us a break from the all-over-body pain of extended tiredness. If this is part of a trend towards more sleep, I may get more time to make FreeGuide better.

Faster Poker Analysis

Forgot to mention that I also have one other optimisation up my sleeve: instead of fully analysing each hand I could only do that when I need it i.e. when the hand type is the same, so I could just return “flush” and only if your opponent also has a flush would I need to say “flush ace high” or whatever. This provision of the detail is actually quite time-consuming, so it may be a significant improvement to avoid it in most cases.

Current timings (without the above optimisation) on a P4 2.4GHz machine:

[andy@andy-p4-linux src]$ time ./poker 5		# Analyse all possible 5-card hands
Straight flush:  0.001539%
Four of a kind:  0.024010%
Full house:      0.144058%
Flush:           0.196540%
Straight:        0.392465%
Three of a kind: 2.112845%
Pair of pairs:   4.753902%
Pair:            42.256903%
High card:       50.117739%

real    0m4.058s
user    0m3.805s
sys     0m0.002s
[andy@andy-p4-linux src]$ time ./poker 7		# Analyse all possible 7-card hands
Straight flush:  0.016811%
Four of a kind:  0.168067%
Full house:      2.555057%
Flush:           3.039766%
Straight:        4.475084%
Three of a kind: 4.873941%
Pair of pairs:   23.512489%
Pair:            43.946865%
High card:       17.411920%

real    3m43.479s
user    3m42.963s
sys     0m0.047s

This is nice, because there are 51 times as many 7-card hands as 5-card ones, and the analysis only takes 55 times as long even though it’s more complex to analyse larger hands, so it means my analysis scales pretty well with the number of cards.

Poker Analysis

I’ve just requested sourceforge space for my latest mini-project: Poker Analysis. I’ve been a big fan of poker for years, and am pleased to see everyone is catching up with me finally with the boom of Internet poker. I’ve started playing a little online, and it set me thinking about the algorithmic aspects of analysing the game. Obviously, the real skills of poker are about predicting people’s actions, but before you can do that you need to be able to see what hand you’ve got and what possibilities are out there, and that stuff is entirely deterministic.

I like small, self-contained challenges, so I set about writing a program to play every two-person game of Texas Hold ‘Em poker that could ever happen, and ranks the two-card hands you can have in order of how many games they win. Obviously most people have a pretty good idea of which hands are good or bad, but I bet there would be some interesting results to see the full ranking.

Of course, I’m sure lots of people have done this before, but I want to do it too! Also, of course, it doesn’t matter how good your hand is in the grand scheme of things, just whether it beats the other hands out there, but bear with me: I’m interested in the results.

The major challenge is getting it to run fast enough, and that is what I’m finding interesting. I’ve already changed my algorithm several times and made huge improvements in execution time, but to run through all the trillion or so (I think) hands would still take several years to execute on my home machine, so I’ve got some work still to do.

There are 2 major parts to the algorithm: enumerating all the hands you could get, which sounds easy but is in fact slightly tricky, and difficult to do perfectly if you want to avoid repeating redundant analyses, and finding out what hand you have (e.g. pair, flush). I’m pretty happy with my current implementation of the second, but I’ve got quite a lot of work to do on the first.

To analyse what hand you’ve got I’m taking an approach where all the real work is done when you sort the hand, and then looking for pairs or straights is easy since the cards are already next to each other. I then re-sort the cards so that the same suits are next to each other, and that makes it easy to find flushes. The part I’m really happy with is that the way I choose hands to analyse means they are already sorted, and when I transform them into the sorted-by-suit instead of by number order, I have very little work to do the way I’ve done it. (Some slight extra complication is added by the need for aces to be either high or low in straights.) This means that deciding what hand you’ve got is pretty quick, and I am able to enumerate and analyse every 5-card poker hand (2.6 million hands) in 4 seconds on my home machine.

I believe I might be able to speed up the analysis a little by changing my encoding of cards which at the moment is just consecutive integers (e.g. 0=2c, 1=3c, 2=4c, …, 12=Ac, 13=2d, …) but might be better to have each suit starting at a power of two to allow the use of the shift operator instead of %13 or something, but I’m happy for the moment. Where I need to improve is in writing the code that enumerates all the hands. As I have it at the moment, it plays every 2-card hand against every other 2-card hand for every 5-card set of community cards (but obviously preventing repeats of the same card) but this is hugely redundant (something like 24x?) since the suits are symmetrical. Exactly how much redundancy I can squeeze out of it is what I am thinking about now.

Anyway, hopefully soon the code will be in sourceforge CVS, and when I’ve achieved my goal of examining all games I’ll make a release. Hopefully in the future I’ll make it accept as arguments the current situation in a game and output the probabilities of each player winning.

Podcasts I listen to

I use a modestly-modified BashPodder to download my podcasts (Internet radio shows) automatically every night, and sort them into different directories. If anyone is interested in my modifications, do ask and I can send them to you. I haven’t sent them to Linc since there seem to be a million modifications, which probably do everything mine do, but better. The only modestly interesting thing I added was the ability to convert from m4a format to mp3 automatically, and that doesn’t seem to work, and the Adam Curry PodFinder show is so bad that I realised I didn’t want to be able to do it anyway (note no link since it’s really not worth it).

Anyway, that brings me on to my main point, which is that I have subscribed to a lot of podcasts, and unsubscribed to a lot too. I have now honed my list to ones that I really like, so why not share?

  • LugRadio – excellent Linux show that even my wife enjoys (she is not in the least interested in Linux) because the four (British) presenters are really funny.
  • Poker Diagram – two British guys playing online poker and talking about it. I’ve learnt a lot about poker from this, and really enjoy listening to it. Of no interest to someone who doesn’t know Texas Hold’Em poker pretty well, as it’s tricky to follow just by audio description.
  • The Linux Link Tech Show – US Linux show that is broadcast live, and then podcast unedited. Not in the least professional, but entertaining if you are interested in Linux and/or like listening to the ramblings of some totally ordinary Americans. It’s not so often that you get to hear from real people in America, instead of TV stereotypes, and I like that aspect of it as well as some interviews with interesting people.
  • Mark Kermode – really funny film reviews originally broadcast on the UK’s Radio 5 (which I would never listen to, since all my radios are permanently tuned to Radio 4). I really trust his opinions, and I love to hear him destroy bad films. It’s remarkable that a true horror fan has managed to get himself a show on national radio, and not just reviewing horror films, but all films. He, as he is the first to admit, is always right.
  • From Our Own Correspondent – fascinating “personal reflections” by BBC correspondents who are living in all kinds of interesting places. Journalists, who often have to hold back poetic thoughts to be impartial, are allowed to do whatever they like on this programme, and the results are often very moving, and almost always the kind of thing you talk to people at work about the next day.
  • Mashup Town – because I am in with the kids. Occasionally has a really good song e.g. the mashup of Eminem with The White Stripes that was amazing and I accidentally deleted. Email it to me if you’ve got it.

Basically everything else I’ve listened to is almost completely not worth it.

Look out this year for loads of corporate AdvertCasts and avoid them.