Monthly Archives: May 2009

Using Cake’s Endgame Database…

I’ve been having a bit of difficulty with the Chinook endgame database, so I thought that since Martin Fierz was kind enough to release his endgame database as well as the code for accessing it, I thought I’d give it a try by making the necessary adapters to make it work for Milhouse. Martin’s code is pretty good, but included a few extra Windows dependences that I didn’t like, so it took me about an hour to get it to the point where it compiles, links, and initializes the database. We’ll see how it works. Eventually, I’ll replace it with my own implementation, probably including a DTC database when I do so, but it’s obvious to me that I still have some problems with the core program, so this will serve as an interim measure. The bonus from this is that I also end up with 8 piece databases, instead of just 6 pieces.

“Everyone is edited by circumstance.”

Pardon me for this diversion from usual topics.

While commuting in with my wife this morning, I was listening to a talk show discussing a reality TV show (specifically, the truly horrendous Real Housewives of New York, a show which obviously stretches the meaning of the words “real” and “housewives”). In it, one of the radio hosts expressed the idea that so-called “reality television” didn’t really give you a fair view of the people on the show, because they could be edited in anyway they like, and made to look like either a sinner or a saint at the whim of the editor.

Here’s the thing that struck me: in the real “real world”, we don’t even need to have an editor do that. If someone sees you just in one meeting a year, they are seeing a very edited version of who you are. If they see you only at work, they see a very edited version of who you are. If people only know you through the Internet, they are seeing a very edited version of who you are. Even if they only see you in public with friends, you might be very different in your own home with your family.

Everyone is edited by circumstance. (That’s my new phrase, and I’m applying for trademark protection.)

What does this mean? It means that perhaps we shouldn’t be quick to judge other people. What we are seeing of them is probably only the slimmest version of what they are really like, and we should exercise a little restraint we either condemn or praise them.

Milhouse fairs pretty well against Simple Checkers at 5 seconds/move

[Event "More Sparring"]
[Date "2009-05-12"]
[Black "Simple Checkers"]
[White "Milhouse"]
[Result "0-1"]
1. 11-15 22-17 2. 9-13 17-14 3. 10x17 21x14 4. 7-10 14x7 5. 3x10 26-22 6. 6-9 23-18 7. 
10-14 18x11 8. 8x15 27-23 9. 4-8 23-18 10. 14x23 22-17 11. 13x22 25x4 12. 2-7 31-26 13. 1-6 
26x19 14. 7-11 4-8 15. 11-16 19-15 16. 9-13 8-11 17. 16-19 15-10 18. 6x15 11x18 19. 13-17 
24x15 20. 5-9 29-25 21. 17-21 28-24 22. 9-13 18-22 23. 12-16 15-10 24. 16-20 32-27 25. 
13-17 22x13 *

Using the Chinook WLD database…

So, for the past couple of days, I’ve been working on fixing the WLD database lookup code in Milhouse, in an attempt to get it to handle endgame positions properly. There is a tiny bit of subtlety which I haven’t seen explained anywhere else, so I think I’ll take a moment here to explain it.

The Chinook database that I am using contains WLD for all positions with six pieces or less. But that’s not actually true: it actually doesn’t include information for any positions which are captures. Why? To shrink the size of the database. Roughly half of the positions (if I recall) are capture positions. Chinook works better if we look those up in the smaller database that results after the jump, rather than here. That’s all very well and good. We could just do a quiescence sort of search: jump out your own captures, and see what the resulting positions are.

But there is a further wrinkle: Chinook deletes not only positions where not only the moving side has no captures, but the other side has none either. Again, this deletes about half the remaining positions from the database, so it’s good, but now you really need to be somewhat clever.

Basically, you end up writing a little minimax search engine, but instead of running the evaluation function at the leaves, you do database lookups. You have to keep recursing down until both the moving side and the non moving side have no captures, then you can do the lookup. If any of your children are a loss for the other side, then you return a win. If all of your children are wins for the other side, then you’ve loss. Otherwise, you are drawn. (Implement that logic carefully, I botched it once, which led to an evening of debugging.) The algorithm always terminates because one or both sides is removing at least once checker for each pair of plies.

And, it appears to be working!

Frankly, using a WLD for only six pieces seems kind of odd. If we stored a “distance-to-conversion” or perfect play database, we’d take up more space, but it woud be trivial to get the program to play out difficult endgames, effectively adding dozens of ply to the search engine with relatively little complication. I think that’s next on my list. I’ve begun trying to decipher Appendix B in Schaeffer’s “Solving Large Retrograde Problems” paper, but the calculation of MaxWP is confusing, to say the least. I’ll have to work through it myself.

Addendum: Actually, it’s interesting to note that three quarters of the entire database are locations which are captures. It seems like that can’t possibly be true in actual play (actual captures are quite rare in end games). Is this an exploitable feature? Martin Fierz hints that it might be in his “Stepping Stone” project suggestion. I’ll have to think about it some more.

Addendum2: Sigh. There is an infinite loop condition which appears not to be caught. Not sure what the deal is with that yet. I’ll have to think about it more. I think it is because you don’t make any headway if the opposing side has a capture, so you play a move which removes the capture, then he plays a move which restores the capture, and so on… Not sure how to catch that. If we play two non-capture moves in a row, does that mean that we are drawn? Perchance.

Milhouse misses a win…

White to move and win...

White to move and win...

I was playing a sparring match between Milhouse and Cake, and Milhouse arrived at the position on the right as White with White to move. Inexplicably, it played 27-23, squandering away the win by avoiding the obvious 2 for one shot into the forced win by playing 19-16 and forcing the exchange.

Oddly, when I extracted this position from the log and replayed it, I got the right move:

milhouse: id
         1:  [-3]
... researching after failing high.
         3: 19-16 12x19 [137]
         5: 19-16 12x19 23x7  26-31 [134]
         7: 19-16 12x19 23x7   6-10  7-2  26-31 [137]
         9: 19-16 12x19 23x7   6-9   7-2  26-31  2-6  31-27 [137]
        11: 19-16 12x19 23x7   6-9   7-2  26-31  2-6  31-27 20-16 27-32 [132]
        13: 19-16 12x19 23x7   6-10  7-2  26-31  2-6  10-15  6-10 15-19 10-15 19-23 ... [144]
        15: 19-16 12x19 23x7   6-10  7-2  26-31 20-16 31-27  2-6  10-15 16-11 27-32 11-8  [145]
        17: 19-16 12x19 23x7   6-10 20-16 26-31  7-2  10-15 16-11 15-19  2-6  19-23 11-7  [129]
        19: 19-16 12x19 23x7   6-10 20-16 26-31 25-22 10-15  7-2  31-27 16-11 15-19  2-6  [128]
        21: 19-16 12x19 23x7   6-10 20-16 10-15  7-2  15-19 16-11 26-31 25-22 31-27 21-17 [128]
... researching after failing high.
        23: 19-16 12x19 23x7   6-10 25-22 10-15  7-2  26-30  2-7  15-19  7-11 19-23 11-15 [7420]
        25: 19-16 12x19 23x7   6-10 25-22 10-15  7-2  15-19  2-7  26-30  7-11 19-23 11-15 [7428]
... researching after failing high.
        27: 19-16 12x19 23x7   6-10 25-22 10-15  7-2  15-19  2-7  26-30  7-11 19-24 11-15 [7512]
        29: 19-16 12x19 23x7   6-9  25-22  9-14 20-16 26-31  7-2  31-27 16-11 27-32  2-6  [7516]
final score = 7516
175.253 seconds elapsed.
... 47783648 nodes searched, 24123999 nodes evaluated
... avg branching factor 1.80
... 388604 nodes ordered
... 3684106 pv hits, 2544492 pv misses (59.15%)
transposition tables
... 23596225 gets (2540472 tier0 / 6252127 tier1 / 14803626 failed)
... 9901700 puts (1812362 tier0 / 8089338 tier1) (2856247 alpha, 139002, 6906451 beta)
... 20062999 chinook database accesses.

I don’t know what went wrong during the game. Very odd.

Addendum: Okay, I’m confused. Perhaps I’m reading the analysis Cake did of the game incorrectly, because 27-23 wasn’t a valid choice here. I’ll try to decipher what’s up later.

Additional progress has been made on milhouse though: thanks to some thoughtful hints from Ed Trice (thanks Ed) I think I finally resolved the problem with Chinook DB access once we hit the endgame. I have added a quiescence search to resolve capture positions properly, and it seems to past nearly all of the tests it used to fail. I say nearly all, because I have discovered a single test which still fails, shifting back from a loss to a draw, and back to a loss as iterative deepening occurs. Not sure what that’s about yet.

Ionisation Chamber Radiation Detector from VK2ZAY

Alan, VK2ZAY, has a really nice blog with all sorts of interesting experiments. Today’s fun installment was a radiation detector that’s just about as simple as can be imagined, ao aimple and inexpensive that I am pondering the possibility of using a similar circuit as part of a sensor for a balloon launch. Very cool:

Alan Yates’ Laboratory – Ionisation Chamber Radiation Detector

It also made me realize that I didn’t understand how a common smoke detector (which I know includes Americium, but little else) actually worked. Wikipedia of course comes to the rescue, and tells me the basic idea.

Listening to WSPR activity

Over the past few days, I finally got a windows box up and running so I could run the official WSPR executable from WSJT. In the short time I’ve been listening, I’ve gotten quite a few spots from stations who haven’t been able to hear me. I made a quick map of all the sites I’ve heard:

Stations I've heard using WSPR

Stations I've heard using WSPR

I’ve deleted a couple of bogus spots that also got “decoded”, both of which were stations which were in the middle of the ocean, and which no one else heard before.

Apologies to all those who have been using my grabber, I will soon return it to operation by tapping audio and feeding it to both setups in the near future.

Some new, and relatively challenging checker puzzles

I was surfing over at Bob Newell’s “Checker Maven” website, and found this awesme collection of PDN files for download. I have a table of challenging positions compiled into milhouse, which I use for debugging and testing, so I decided to hack a simple parser to input some of the positions into Milhouse. The “Gem Problems” file contain 162 positions, some all of which are quite challenging. Consider this one:

Red to move and win.

Red to move and win.

It takes around a 55 ply search to find the winning line, but a reasonably skilled checker player would be expected to play this line out without mistakes. Milhouse still finds some positions like this challenging, since it typically maxes out around 40 ply or so before grinding to a halt. I suspect this reveals a deep flaw in my move ordering, and I think it might be difficult to fix it. But I’ll think about it some more.

Milhouse wins against Cake!

Okay, before I get too excited, I’ll disclose that Cake was set to a time limit of around 1 second, which limited it to just a few ply (maybe 9 typically) and I was letting MIlhouse think a little harder (still taking less than 10 seconds typically). Still, it’s good: it means that sparring matches between milhouse and cake can be tuned to make them challenging. I need to figure out how I can build milhouse as an engine for CheckerBoard so this can be automated.

Perhaps I could use mingw to build an appropriate dll.

[Event "Morning Match"]
[Date "2009-05-04"]
[Black "Cake, 1sec per move"]
[White "Milhouse, 19 ply search"]
[Result "0-1"]
1. 9-13 23-19 2. 6-9 27-23 3. 11-15 23-18 4. 8-11 26-23 5. 4-8 30-26 6. 9-14 18x9 7. 5x14 
22-18 8. 15x22 25x9 9. 11-16 9-6 10. 2x9 24-20 11. 8-11 26-22 12. 10-15 19x10 13. 7x14 
29-25 14. 16-19 23x7 15. 3x10 28-24 16. 10-15 32-28 17. 14-18 24-19 18. 15x24 22x15 19. 
9-14 28x19 20. 14-18 15-10 21. 12-16 19x12 22. 13-17 21x14 23. 18-22 25x18 24. 1-5 31-27 
25. 5-9 14x5 0-1

Gutenberg Gem: Pioneers Of Science, by Oliver Lodge.

fig66Glancing through the recent additions to Project Gutenberg, I encountered this nice little book which details some of the pioneering scientists in the field of astronomy. It even has some nice illustrations which might be useful, such as the one on the right of Newton’s first reflecting telescope.

The Project Gutenberg eBook of Pioneers Of Science, by Oliver Lodge.

3D printing goes back to the Stone Age

I’ve been interested in 3D printing for quite some time. It’s a technology that seems poised for a break through. One of the things that it really needs is an inexpensive medium to create objects from. I’ve seen printers which use sugar which is carmelized by hot air, corn starch which is glued together, and various plastics. This link on the Make blog links to an article which includes a recipe (awesome) for a ceramic medium for 3D printing, which is very inexpensive. I have no immediate use for this information, but who knows what the future may be.

Make: Online : 3D printing goes back to the Stone Age.

K450 PVC Rocket Engine Design & Construction

K450 PVC Rocket Engine Design & Construction

In just a few hours, anyone can build a powerful K450 engine that will send a rocket soaring over 5000 feet! Easy to follow step by step instructions and 137 color illustrations demonstrate the exceptionally simple construction process. Best of all, only common materials are used and no special tools are required.

I’d order your copy before the DHS gets wind of this publication.

Addendum: I wish I still had my copy of this book. I had one years ago, but seem to have misplaced it in the various moves since then. The zinc/sulfur formulation that it recommends has fallen from favor in recent years, but it was still an awesome book to have on the shelf.