Wednesday, August 22, 2007


I recently inherited the house of my grandfather, and now have a lot more housekeeping to do than earlier. Somehow, this might have helped me in my decision to do some housekeeping with Cake. Those of you who have programmed probably know the feeling: even if you started out with a more or less clean concept (I certainly didn't with Cake), things eventually get out of hand. You add an idea here, put in a quick fix there, and before you know it, your code is unreadable and unmaintainable. That's about the state that Cake was in before my summer holidays in the Austrian mountains. There, besides reading the Harry Potter finale and climbing some mountains, I cleaned up Cake's source code during two whole weeks. That much time is necessary, since you really have to stand back, and get an overview over your whole program to decide exactly how you want to do your cleaning up. You can't just do it on a single day, or fix it by programming one evening per month - until you get back to programming, you will have forgotten everything again (at least that's what would happen to me, but then I turned 36 recently!).
The result of two weeks of hard programming is that there are no global variables left in Cake, that Cake can be switched to thread-safe mode (at a small speed penalty), and that much of Cake's code is now much clearer and cleaner than before. It doesn't play any better at all though - but now that I have (nearly) finished the housekeeping part, I might be more inclined to work on it again!


Mark said...

What is thread safe mode? Does that mean that multi-threaded play is possible now? An easy way to implement this would be enable ponder and in engine-engine matches it will use two cores constantly.

Mark said...

tried your checkers x64 in vista x64 ultimate. Had to run as administrator. It locks up every once in awhile. It seems to be whenever I try to force a move. Here is benchmark comparison:
27/36 41.59 4867.1 kn/s from start
25.23s search win from all 4 filled

27/36 37.04 5465.5 kn/s from start
27.63s search from all 4 filled

Mark said...

you know, I didnt mean checkers I meant connect 4 v.4.01

Martin Fierz said...

Hi Mark,

thread safe means that two threads can execute a search in parallel. This doesn't mean, however, that Cake can use two (or more) core CPUs - it can't! However, making the code thread safe is the first step toward a parallel version of Cake. I don't really know whether that will ever happen, but I do hope to eventually rewrite my book builder for my totally awesome quad core machine :-)