Thursday, May 31, 2007

chess program, methodology, inefficiencies (part 1)

I haven't spent much time planning in the process of writing the chess computer, but rather have been working by creating increasingly more well structured (and efficient) prototypes. As against extensive planning to get everything right the first time you get around to coding. It's not as chaotic as it sounds, I do make decisions regarding structure along the way, just that I do it when it comes naturally, rather than trying to force it. And I try to adhere to design principles such as low coupling och high cohesion. But still, as soon as planning isn't easy or obvious I start to code until my insight into the program is such that I'm ready to for new decisions regarding structure (which often means some degree of refactoring needs to be done).

As a result of this, my chess program has gone through some stages when my code was very different (in some ways) from what it is now, and less efficient and less well structured (not that it's particularly efficient now, but everything is relative and all that). I just thought I'd document some of these inefficiencies for future reference. Starting in my next post (I can't keep my plan to post three times a week if I write those long posts every time...)

(Is there any way to always be logged in at blogger? It annoys me having to log in every time, even if it only takes a click.)

Tuesday, May 29, 2007

Positional elements and what to do

It is not entirely obvious what various positional elements mean in terms of actions. Not to be me anyway. It is quite possible to be able to assess a position, see who's got the space, the well places pieces and so on, yet not know what to do, neither in terms of goals nor next move. (And I'm not speaking of breakthrough positions... in an general, positional way you do know what to do in those, achieving the breakthrough.)

One of my goals, one that I think is of crucial importance in playing chess, is to always have some grasp of what to do in position. So when I blitz, as I think I've explained, I'm always on the lookout for positions in which I'm clueless, and after the game I think about what I should have done (in terms of positional goals, usually not specific moves). I also think about what my opponent does, especially in cases when my opponent is in a position that I don't know what I would have done in. More than once I've learned something about what to do just by observing what they did, and their ensuing success.

This and tactics is the way to improve, I think.

Much of this is tightly related to things I've already written about, but it's not exactly the same.

Here's a list of very general plans and goals related to a certain positional elements: (in all cases it is also desirable to prevent the opponent from achieving these things, but I write primarily from the perspective of what to do yourself with your position).

Opening: develop pieces, control center

Endgame: promote pawns

Weak (enemy) pawns: attack it

Weak (enemy) square: put a piece on it.

Pawn majority: push them forward

Space advantage generally: use it to manoeuvre pieces (attacking something, I suppose.)

Space advantage on kings side (normal castling): attack the king (if enough pieces left)

Badly placed piece: activate it

(I'm not too happy with these examples, there should be more tricky ones. Maybe I'll add to the list as soon as I've come up with more.)
---

The general point is to always to able to translate static qualities into what it means in terms of action. Needless to say, most positions have several of these at once, and just because you have a badly placed pieces doesn't mean your immediate goal should be to activate it. Maybe something else more important at that moment. Still, when you see that piece your mind should automatically make the connection that it would be nice to have it more active. That's an obvious example, but it's not always that obvious. We all have 'blind spots', and for me one particular blind spot is pawn majority. I've been in blitzes not knowing what to do and afterward found it obvious that I should have pushed those pawns. The solution is to keep repeating that connection until I see it without effort.

"Every is implies an ought" (Ayn Rand)

Friday, May 25, 2007

Positional elements, analysis and integration of

First a short announcement: I've finally created a link list. Look to the left and you shall find. If someone linking to me isn't added, let me know and I'll consider including you (which I most likely will, unless you write really wicked stuff).

Okay, it's time to go mendelejev again, this time to identify groups of positional factors (not to be confused with the semi-positional elements in the tactical inventory, that I've written about else).

What I once learned and retained is the following, these four groups:

1. Safety of the king
2. lines and diagonals (lines includes rows)
3. squares and pawns (including weak pawns/squares, pawn-formation, etc)
4. Placement of the pieces.

Edit: actually, I haven't retained it correctly after all, since "space" must be, and was, included. Yet I'm sure there were exactly four groups. Maybe space belongs with "placement of the pieces"? No... um. Whatever, let's add a fifth category until further notice:

5. Space

(Edit 2: and what about the center, shouldn't that be mentioned? Uhmm.)

Does that cover it all?

I thought I had got it from "The Art of the Middlegame" (Keres/Kotov), but I've searching in that book and can't find it. Perhaps it was from "Thinking like a Grandmaster". Anyone know? Or maybe I just compiled the list myself, using these works. Don't remember, although I do remember Keres (or Kotov) specifically saying something about the value of extracting the various elements, specifically comparing the activity to creating the periodic system.

Ayn Rand identified four elements in fiction: plot, characterization, style and theme. She pointed out that these parts are not separate in the fiction itself, it's just in our mind that we can pick out the parts and analyze them by themselves. For example, through the character's actions we learn both about the character himself (characterization) and it also drives (or should do) the plot forward, and it's also part of the theme and expressed in a certain style, and so on.

Likewise in chess. Having weak squares around the castled king both falls under "safety of the king" and "squares and pawns", and possibly under "placement of the pieces" (you would like a black knight on h3, wouldn't you?) as well as lines and diagonals (like that killer bishop on b7 that is just about to shoot the white king in the head). These things are picked apart intellectually only, in reality they are connected (and they should be connected in our minds too, part of the process of analysis is to discover these connections. So analysis has a close relation to integration and 'holism', actually. Or should have.)

To be continued. I've already written the next part (actually I haven't, but I thought I would by the time I published this, but I will), which is about connecting positional analysis with goals. What exactly do we *do* with these positional elements after they've been identified? In GTD terms, what's out purpose and what's the next action?

(I like the phrasal verb to "go mendelejev", and I think I'll make "mendelejevism" its own category/label. Good thing about not having english as your first language; you get to say anything, including making up your own words and phrases. : ))

(And btw, I've now seen the first season, and 1/3 of the second, of Babylon 5, and I like it a lot. I'll have more to say about that.)

Thursday, May 17, 2007

Chess -- chess computer, some info and a game

I've recorded another game played between me and my chess computer, this time it's thinking four plies (half-moves) ahead so it plays a little better tactics-wise, but overall still pretty badly. But eventually it will start beating me so I should relish these winning days 'cause they won't be here again.

Actually I haven't tried to make it any stronger since last time (except that I now have the Alphabeta search algorithm, and Negascout is on its way). It's the same algorithms and evaluators. What I've spent my time doing is adding things and re-structuring the code. I've now (mostly) implemented it using the MVC design pattern. It has some nice advantages I might be writing about some time. Also, I've added graphics (or maybe I've already said that?). Earlier I had a board with labels showing numbers, like this:




Now it looks like this: (I still have plenty to do, but there's a difference.)



As you may notice, I've used the graphical depiction used on CTS (using screen shots). I contacted them twice about this, asking for permission. They didn't respond. Perhaps any reader knows whether it would be a copyright violation to use this board and these pieces. I mean, chess pieces are really trivial graphics (especially these pieces -- they are the 'standard' pieces), so it's almost like asking for permission to use a black background, but if there is a problem I'll create my own or get some other.

Here's the game:





It unexpectedly won a pawn in a quiet position, but other than that it really needs to read (and study!) Keres, Euwe and the others. But you know how they are, today's chess computers. It's all about beer, chicks and crappy TV shows. Back in the days...

Monday, May 14, 2007

GTD, chess and Objectivism

There are some parallels between these. Ayn Rand considers the three cardinal values in life to be reason, purpose and self-esteem. In GTD the the two big questions are what you want to achieve (or in other words, what's your purpose?) and what's the next action. So purpose plays a big part in both these. Also true in chess, except that 'goal' is a more commonly used term, and in chess there's also a correspondence to GTD's 'next action', which of course in chess simply is 'next move'. Objectivism doesn't have a direct correspondence to 'next action', but then it's a philosophy and that would be too narrow a concern. That's why Objectivism and GTD work so well together -- Objectivism identifies broad principles (including that productivity is a virtue) and GTD is a system that applies parts of Objectivism (such as being more productive) to your dialy life. That's how I see it anyway, and I know GTD is somewhat popular among Objectivists (and would be more so if people knew about it).

As for chess. I think of chess as a magnifier of these and other principles, perhaps especially purpose and causality. Living is often ambiguous and bewildering. You don't know what you want, or how do get it, or what follows, or the identity of certain objects. Chess is much more manageable. Much of what makes life bewildering and complex is removed, yet those really important principles in life remain in chess, writ large. You still want things in chess, and things follow, and things have identity. Chess creates a sense of order and clarity, a much needed feeling.

Friday, May 11, 2007

Chess -- Another breakthrough position

Here's another breakthrough position, one that I got from Susan Polgar's blog (a blog every chess player should read, but then I guess most already do) the other day:



Notice the elements making it a 'before the breakthrough'-position: white has the superior position, all pieces are well placed (any positional move seems to just make the position worse), the king is safe. It's an open position, so making pawn moves are out of the question. And you can't have a positional goal such "making a piece more active" either, because all pieces are already fully active. Vintage pre-breakthrough; something radical is required.

In this position the solution happens to be purely tactical (nice tactics, find it out), which in a way is the least interesting type of breakthrough, since tactics isn't as ambiguous as other ways to continue, like sacrifices or 'making threats and switching targets'. (I need a better name for the last one.)

Monday, May 07, 2007

This just in: crazy game by computer

Okay, here's a game my chess computer just played (both sides). It's thinking only two plies (half-moves) ahead, less than 0.5 s per move. It evaluates a position according to three criteria: material worth (of course), center squares, and a secret criteria. It knows no opening theory, of course, and there is no randomizer, so it plays this game every time (given two half-moves. It would play better looking ahead more moves, but I'll wait until I've implemented the alphabeta pruning algorithm before I play through any longer games, as well as some other changes.)

I've now added a nice looking board and some real pieces (earlier I just had board with numbers representing pieces). And I've increased the search speed to at least 6000 positions per second. Still haven't put any real effort in speed increasing, so I expect to gain more later. Anyway, the game:




I actually don't understand why it plays some of the moves, but then my third criteria is difficult to calculate as a human (and it probably makes it play some bad moves, but I had to throw in something quickly in order to make it stop playing a3 and then Ra1-Ra2 back and forth...)

.

Saturday, May 05, 2007

TV shows, top 8

Update: a more current (but to a large degree similar) TV show top list has been published here. Aside from being more current it also contains a couple of nice pictures and a link to info on every show.

Being a great fan of TV shows I thought I'd try to compile a list of my favorite shows. Kind of a recent interest actually, for years I foolishly lived without a TV. Then I changed. It all began with Buffy the Vampire Slayer...

In order:

1. Buffy the Vampire Slayer
2. Angel
3. Here it is starting to get tricky. I let these shows share the third spot, without order:

House M.D.
Veronica Mars
Firefly

4. Battlestar Galactica

5. No order:

Star Trek: the Next Generation
Lost

There are other good TV shows, but not good enough to mention. Next show to explore is Babylon 5. I recently bought season 1-3 and The Gathering.

Thursday, May 03, 2007

Chess -- positional play and pawn structure

One of the most important factors to consider when deciding upon a positional goal is pawn structure. And I've found the best ever site to explain what that's all about. This one. Apparently based on a book by Euwe and Kramer, currently out of print.

.
 
Locations of visitors to this page