Wednesday, August 22, 2007

Housekeeping

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!

Sunday, February 18, 2007

64-bit versions of CheckerBoard and Cake

Linux users could already benefit from the new powerful 64-bit processors for quite some time, while M$'s win64 never really got out of its beta phase. With the release of Windows Vista, this has changed, and 64-bit computing is now also available to the masses. I run neither Linux nor Vista, but I do have a compiler capable of producing 64-bit executables. I wonder whether they will run under 64-bit Vista? If you happen to own a 64-bit Vista, you can try it by downloading CB_64.zip (264KB), and installing it in your CheckerBoard directory. To do this, you need to extract checkerboard64.exe to the CheckerBoard directory, and CakeM64.dll to your engines directory. Run checkerboard64.exe and choose CakeM64.dll as your engine. Let me know what happens!

Friday, February 09, 2007

Wow! CheckerBoard runs under Vista

I haven't been doing any checkers-related stuff lately. I'm all the more pleased to hear that CheckerBoard and Cake run under M$ newest OS - that means I don't have to do any checkers-related stuff in the near future :-)
And no, of course I didn't try this myself: I'm going to avoid Vista for as long as possible!

Tuesday, December 19, 2006

Computer power consumption

In a previous post, I promised to measure the power consumption of my PCs. I finally did this, and got the following results:


Computer off, power supply off: ......... 0 Watt
Computer off: ........................... 7 Watt
Windows idle after startup: ............ 64 Watt
Book generator running: ............... 112 Watt
Monitor (Flatscreen) alone: ............ 36 Watt


This result was slightly surprising for me. I would have expected my PC to use more power than 112 Watt when running Cake - after all, it is using the CPU fully and also using the harddisk quite a bit. What are all these 350 Watt power supplies for, I wonder? The result also changes my checkers programming economics post: My book generator now "only" uses 2.7kWh per day, or 0.35$ a day. Since I have been computing opening books for about 4 years now, that puts the worth of the opening book at 500$.
On the other hand, 112 Watt is still a lot, given that we should be moving towards the 2000-Watt-Society - I am using over 5% of my power consumption for something rather useless like checkers book building....

I also measured the power consumption of my other PCs. Unsurprisingly, my other desktop PC is quite similar to the book generator PC, while my old laptop with a 1.4GHz Centrino processor uses only 23.5 Watt idle and 39 Watt when running Cake. Turning off the LCD screen saves another 6 Watt. Here's an interesting thing: on my desktop PC (with a AMD 64 3400+), running Cake costs about 50 Watt more compared to the idle state of the PC for nearly 2000 kN/s. On my laptop, running Cake at about 70% of that speed costs only 15 Watt, or about 3 times less. That means that my laptop is producing about twice as many nodes/second with the same amount of energy. Unfortunately, I measured these numbers before I got my new Core Duo machine, so I have no figures for that.

Monday, December 18, 2006

Core Duo!

It's been a long time since I last bought a new computer (21 months, to be exact, a record for me in the last 10 years!) - but I just did it again: I got myself a new laptop with an Intel Core Duo CPU - unfortunately not one of the even better Core 2 Duos. However, even this machine is absolutely great! Cake runs about as fast on my Core Duo at 2GHz as on my Athlon 64 at 2GHz. But the cool thing is that I can run two instances of Cake at the same speed, if I want to. Not that this really helps me in any way... it just shows why these dual core machines are so cool. The days of single core CPUs are numbered (as far as PCs go, anyway), and the first quad-cores for consumers are already on the market. Which gives me a bit of a headache, because it means that I should try to rewrite Cake so that it can use these new CPUs with multiple cores! All good chess programs have this capability, but the only checkers program that I know of that could use multiple processors was Chinook. However, the speedup from multiple processors there was quite lousy compared to what is reported for chess programs. For chess, it's something like 1.9x faster for dual cores and 3.5x faster for quad-cores, for Chinook it was approximately 3x faster on 16 CPUs [1]. It's not quite clear to me whether checkers is inherently tougher to parallelize than chess or whether the implementation in Chinook was poor. Any opinions?

Friday, December 01, 2006

Usage Statistics for November

Since November 2006, the full 8-piece checkers endgame database is available for download on my website. I checked the usage statistics for my server, and found the following:

Month 2006 traffic
August 7.8 GB
September 67.3 GB
October 93.4 GB
November 142 GB

This means that the 8-piece database is responsible for about a 20-fold increase in data traffic from my website! It also means that the database was downloaded about 60 times. In the same month, CheckerBoard was downloaded 2'500 times, and the opening book 200 times. 60 downloads in one month is not that much, but it still makes me think about something like checkers@home...
For comparison, my 4 in a row program was downloaded 500 times, while Sudoku Champion didn't make it to the top 30 files which I can view.

Monday, November 06, 2006

Cake Manchester 1.09d - KingsRow 1.16: +20-17=251

The match between my "old" Cake Manchester 1.09d and KingsRow 1.16 finished with a narrow win for Cake - 20 wins vs 17 losses and 251 draws (naturally this is with books off - else it would be draws all around - or very nearly so). I also repeated the match with learning disabled in Cake, with the result that not much changed: +22-19=247. So to stay in line with my last post, that would mean that I could leave Cake alone somewhat longer - but the result is too close for comfort, and so I decided to start tuning Cake a bit. When I try to improve Cake, there are many different ways to do it. One of the things I sometimes try is to tune the evaluation function, i.e. to change weights of different terms in the evaluation (as opposed to adding new terms to the evaluation). When an engine has been a sitting duck for years, as Cake Manchester has, then it is quite well possible that the opponent (KingsRow in this case) is just well-tuned to beat Cake. Changing the playing style a bit might make quite a difference in such a case. So to start, I am trying to just tune Cake a bit to avoid Ed's last two years worth of tuning of KingsRow - of course, I don't just mindlessly change the evaluation weights; instead, I checked the games that Cake lost in this match. Then I also have some ideas left on how I might improve the evaluation function with new terms, and a new idea for the search which I already tested but which didn't work well in the first implementation. Nevertheless, it also didn't work too bad, and perhaps with some refinement it will work. If all runs smoothly, I will have a new version of Cake ready for Christmas!

Wednesday, November 01, 2006

KingsRow 1.16

Checkers programming is going slow for me these days, and I don't seem to be the only one: It took Ed Gilbert over half a year to release a new version of KingsRow (1.16) which is now available for download on his webpage. We both seem to have used our time for other projects (For me, writing a suicide checkers engine, for Ed, more sensibly, writing a 10x10 international checkers engine).

I am running a match with KingsRow 1.16 against Cake Manchester 1.09d right now, and it's looking good for KingsRow: after 200 of 288 games, KingsRow is in the lead with 12-11 wins. If KingsRow wins the match, it would be the first time ever since 2004 that I see Cake losing a match - which brings me back to the introduction of this post: One of the reasons that I didn't do very much since my initial Cake Manchester release in 2004 is that it consistently beat KingsRow since then, and that I wasn't motivated to work on Cake because it was (IMO of course) still the world's most powerful checkers engine. It looks like I might have to shake the dust off Cake's source code soon!

Sunday, September 17, 2006

Checkers programming economics

I received a rare donation for CheckerBoard the other day, so today I thought I could try to calculate the economic aspects of CheckerBoard. Here's what I came up with: At the end of november 2005 (10 months ago) I redesigned my checkers webpages and added Google ads to them. I also added that infamous donate button. On the negative side, I have a computer running 24/7 working on CHOB. In Zürich, electricity costs 0.16 Swiss Francs per kWh (that's about 0.13$/kWh). I'll try to measure the power consumption of my PCs soon, for now I'll assume that such a PC needs about 200W, which makes about 5kWh/day or 65 cents per day. So that gives me a daily budget of

Income from Google Ads:....+0.45$
Income from donations:.....+0.25$
Electricity bill:..........-0.65$

which leaves me with an income of 5 cents a day - not exactly much. Nevertheless, I shouldn't complain: Ed Gilbert has no Google ads, and no donations, and he's running 5 (!) machines simultaneously...

As a PS, it is no wonder that Murray Cash gave up on Nemesis!

Tuesday, September 05, 2006

Book update

I released a new version of Cake's Huge Opening Book (CHOB) recently. The new version is now based on about 2.35 million positions that were analyzed by Cake, the previous version (released in mid-April) was based on about 2.2 million positions. The new book would be approximately one ply deeper in the shallower main lines than the old book; however, I also threw out all positions which are in the leaf of my book tree - i.e. those positions where no successors have been searched. The reason I threw out those positions is that they are based on a 90-second book-generating search on a fast computer (AMD Athlon 64 3400+ with 2GB ram), which is good, but perhaps not good enough. The book-generating search produces evaluations for all moves in a given position, and takes longer than the regular search to reach a specified search depth. Therefore, it is approximately equivalent to a 30-second regular search on a fast machine. That means that if you set Cake to search for more than 30 seconds on a fast machine (and if you have the 8-piece database), then you might get a better move than what is in the book. This alone is enough to throw out the leaf positions, but there is more: Ed Gilbert actually found a losing book move in my first release of CHOB, and it was just such a leaf node. Now, this move is no longer in the book, and if you give Cake enough time, it won't make this losing move. Looking at the data from the opening book generator, it seems that it will have to run for another 2-3 months until it will expand that position with the losing move further.
Having found (or been told about, rather) one error in CHOB 1.0, I have to assume that there were more errors. After all, Even in a 288-game-match only about 288x10 = ~3000 book moves are actually played by Cake. Now that I know that one of these was a loser, I could extrapolate and say that 1 of 3000 moves is bad, and that therefore there are approximately 1000 losing moves in the book. I don't think it's this bad at all though, but there is no way to really know.