I was recently rummaging around some old half-completed projects when I came across an idea for a chess-playing computer program that had been lying around for years. It hinged on a single hunch that I thought might be worth exploring, but before I can explain that I need to provide a bit of background on how chess-playing programs work.
The classic chess playing program (chess engine) relies on two basic ideas:
The Search. For any given position, the program examines all the legal moves available and, for each of these moves, looks at all the moves available to the opponent and, for each of these in turn, looks at each of the possible responses. As there might be around 30 moves to choose from at any one time, the number of possibilities rapidly grows to be in the millions so eventually you have to stop, at which point, we come to the second idea:
The Evaluation. For every possible outcome in this rapidly branching tree of moves and counter moves you work out a score for the position - high if the side whose move it is is winning, low if it is losing. All that remains is to choose which of the first moves is the one that leads to the position with the highest score.
Evaluation functions differ from one chess program to another but they all examine the layout of pieces and calculate a score based on a number of factors - the first being a simple totting up of pieces that remain on the board. Others factors typically involve looking at the placement of pawns (pawn structure), whether major pieces are in strong, central positions and so on. There are many variants and it is probably true to say that chess engines are primarily distinguished by their evaluation functions. Nevertheless, given the evaluation has to be repeated millions of times, it needs to be fairly succinct.
My own idea for a chess program proposed an extremely straightforward (and fast) evaluation function that simply counts the number of moves available to each side and calculates the difference. Of course, since capturing a piece immediately eliminates it from making any further moves, the hope was that my program would automatically try to make captures as a consequence of minimising the moves available to the opponent. The appeal of checkmate is even easier to understand, as that occurs when the losing side has absolutely no moves left.
So in mid-December I set about trying to write my engine which I had decided to call Moby on account of the fact that the evaluation function measures mobility.
I didn’t start from scratch but from a previous well-documented engine called Vice which I partly rewrote and adapted over the course of a few weeks. It took me longer than expected, as my programming skills have grown a bit rusty.
I embarked on this adventure in the drab, gloomy days following the election, possibly as a means of distracting my thoughts from the prospect of 5 more years of Conservative government. And so, as each dreary, rain-sodden day was followed by the next, through long nights when every line I wrote seemed riddled with errors, I began to question whether the project was less a genuine investigation and more an attempt to prove that I had still got it when it comes to programming (or coding as it is called these days). And each night, as tiredness took a grip, I would take myself to bed only to lie, raking through the code in my head, in search of what was going wrong.
But I did get it working eventually and what a strange game of chess it played. For example, when considering positions in which a rook happened to have no immediate moves available (as is often true near the start of a game) it was quite happy to sacrifice it in order to let another piece move into a slightly more open position. It wasn’t all hopeless however; it would occasionally make a clever move. I began to see that some of the more ridiculous mistakes could be avoided by combining mobility with a simple count of the pieces remaining on the board.
So have I gone ahead and made this improvement? Well no — but I probably will. But that’s not the point right now because here the story takes a different turn.
I thought it might be a good idea to share my investigations with the world or, more precisely, the chess programming forum on a website called TalkChess, and so I submitted a contribution describing my approach and invited people to make comments. I had a number of responses the majority of which could be characterised as:
“That’s interesting but it’s unlikely to get you very far.”
Another person wanted to know what it was that had drawn me to such an austere choice of evaluation function to which I responded that it was largely aesthetic, or the appeal of seeing complex behaviour emerge from a simple rule.
But it was one of the later responses that I found most enlightening. A respondent from Germany (Gerd Isenberg) wrote:
“Maybe you aware that programs like Barricelli’s Freedom and Marsland’s Wita used mobility as the evaluation term.”
I replied that I was not aware of these programs, to which he replied
“Yes, the idea of using mobility in evaluation is old. Also note Slater’s ‘Statistics for the Chess Computer and the Factor of Mobility’ and the discussion with Alan Turing.”
My interest was immediately sparked by mention of Alan Turing, widely considered to be ‘the mother and father’ of theoretical computer science and artificial intelligence. The discussion referred to was documented under an item on Eliot Slater who, as well as having an interest in a chess playing machine, was mainly known as a psychiatrist with some questionable views on eugenics. Slater, it appears, felt that mobility was a key indicator of the strength of a chess position and suggested that a chess playing machine programmed to maximise its advantage in mobility would play a strong game - just as I was speculating.
To this, Alan Turing replied:
“Although the immediate mobility is a useful measure of the relative advantage of the players in normal play it by no means follows that it is wise to direct one's play to maximising such a measure. To do so would be like taking a statistical analysis of the laundry of men in various positions and deciding, from the data collected, that an infallible method of getting ahead in life was to send a large number of shirts to the wash each week.”
So that’s that - done and dusted. I’m not inclined to argue with Alan Turing and in any case his laundry simile, despite being somewhat quaint by today’s norms, is pretty deflating.
But the startling fact is that the discussion between Slater and Alan Turing took place 70 years ago, in 1950, at a time when the number of computers in the world could be counted on the fingers of one hand! The whole episode felt like an immense cycle that had taken an unexpected turn and had transported me back to the time of my birth. And despite the fact that my speculations appeared to have been thoroughly dispensed with around the time I was learning to walk, I was left with a feeling of quiet contentment - happiness even.
Maybe it also had something to do with the fact that the sun had begun to shine again, bringing a lightness in the air and the first intimations of spring.
Tuesday, January 28, 2020
Monday, January 20, 2020
A souvenir of Venice
Whenever I go on holiday for more than a day or two I like to seek out a special object, delicacy or suchlike to bring back home with me. If I go up to Lancashire, for example, there’s a very good chance I’ll come back with a black pudding. On one occasion, having been seduced by the intoxicating delights of Stockport covered market, I brought some tripe back, in the belief that some deep Lancashire part of me would instinctively know how to go about eating it .... it didn’t
Thinking further afield - each destination offers its own unique and fascinating souvenirs.
In Hong Kong you can buy a bottle of wine with a dead snake coiled up inside it. At first it might seem an ideal souvenir — at least until you have the presence of mind to realise that, in some desperate or tormented state, you might be driven to drink it.
Venice presents its own peculiar difficulties in the souvenir department. To kick-off, there are those carnival masks, ranging from a number of variations on the pale courtesan theme to that other slightly sinister one with a long, drooping proboscis - or is a beak? But then what would you honestly want to do with a carnival mask?
“I could wear it at parties” you find yourself thinking. But then you know for sure that, when it comes to it, it would never feel quite right. And what else is there to do with a pair of carnival masks other than to mount them at a jaunty tilt on either side of the chimney breast ?
No - the carnival masks won’t do.
Glass, maybe. Since the thirteenth century Venice has produced a steady stream of exquisite glassware - most of which has since been accidentally broken. Today the descendents of those early glassmakers churn out a dazzling variety of objects — mainly ghastly, except for the chandeliers which — you may confidently have it from me — are gorgeous. I briefly tormented myself with the thought that I really owed it to myself to buy a chandelier, despite the fact that they can cost as much as a decent secondhand car. This is in Venice, of course. I have since seen the selfsame items on-line for a fraction of the Venice price. But hey, hang on: this is beginning to sound like one of those conversations overheard whilst in the queue for passport control. I’m meant to be thinking about souvenirs and whether glass might do … and no, it won’t.
There are nice paper-style goods in Venice. There’s that lovely wrapping paper printed with Rococo designs and if I were to buy some, I would take it home and I would squirrel it away carefully; and later, after my death, my children would discover it and recount to others: “There were drawers and drawers full of exquisite Venetian wrapping paper. I don’t know whether he planned to do anything with it or whether he just enjoyed it for its beauty. It broke our hearts to take it to the recycling.”
So that’s the paper out as well.
In the end it was a hat.
Right from the start of our holiday, on the waterbus that carries you across the lagoon from the airport, I had noted that our driver was wearing an interesting woolly hat that would have been a perfect fit had his head been the shape of a rugby ball. As it was a normal head, the empty, surplus bit of hat was left to droop backwards in a manner that invoked images of generations of lagoon-dwellers, netting wildfowl on damp, misty mornings; of renaissance merchants and even Bellini's famous portrait of Doge Leonardo Loredan (except in his case the spare bit is sticking up, suggesting there's a bit of cardboard inside it )
So the hat it had to be.
Finding it proved to be harder than I first imagined - the problem being, it wasn’t a tourist item. But then, having to track it down, scouring the outdoor markets and department stores that somehow manage to cling on to the less fashionable fringes of the city, lent the whole quest an extra level of romance. I found one at last, hanging outside a hardware store and costing a couple of euros and for the rest of our holiday enjoyed swaggering around the decks of vaporetti in the hope of being mistaken for a deckhand who had just finished his shift and was on his way home.
I still have it. It’s a nice hat.
Subscribe to:
Posts (Atom)