May 14, 2012

Analyzing Chess Positions Using Crafty

Playing chess with the Xboard GUIWhen you play or analyze games with crafty, you can visualize the board as well as crafty's output with Xboard.via the Xboard siteIf you want to raise your chess playing skills to a higher level, you need to analyze positions and chess games. Even on off-the-shelf computers, chess programs are stronger than most grandmasters, therefore what could be more useful in this respect than chess programs? One of the strongest chess programs is Crafty, which is being developed already for many years by Robert Hyatt, who works as an associate professor at the University of Alabama at Burmingham (UAB). Let's see how to install and use crafty.

You are interested in the world chess championship, which is currently going on in Moscow or you want to analyze your past matches that you played on-line, for example on ?

As I just stated, crafty is one of the best chess engines out there, furthermore it's free as in beer and as in speech. You can get it following instructions at its official page. In debian based linux (such as ubuntu) you can install it doing
apt-get install crafty

In ubuntu, this will also install the Xboard interface, which I highly recommend using. For windows, you'll also find executables from the crafty homepage and for the interface you will find ports from the xboard site.

Xboard also works with other engines, apart from crafty, such as dreamchess, fairymax, hoichess, sjeng, gnuchess, phalanx, fruit, glaurung, toga2, and stockfish. The last one is particularly strong, however doesn't support endgame tablebases (EGTB). I'll get back to stockfish later.

I should note here that you should not use a chess engine to cheat on games you're currently playing. If using a chess program constitutes cheating is controversial, but on some on-line playing sites computer assistance is frowned upon or prohibited (compare gameknot's policy on using computer programs and the rules in the German Correspondence Chess Federation). You should only use chess programs where you don't get an unfair advantage. Unproblematic is post-match analysis that gives clues on missed moves and helps you analyzing games. As an example, you might want to use crafty to annotate your game files or you can put it in analyze mode while you step through the moves and look for sudden jumps of evaluation. I find it also very interesting to compare well-known high-level matches and play less explored lines that seem appealing (referring to reference material should be unproblematic).

Expert players not only have a highly developed sense of positions and tactical combinations, but also a broad repertoire of openings and a deep knowledge of endgames. To get this knowledge into crafty, you can supply it with an opening book and endgame databases, respectively. I found the on-line explanations about databases a bit sketchy, so here they come at more detail.

For the opening database you need to download a file with matches, so crafty can build statistics out of that for each position. This file can be a pgn file or you can convert it to pgn (in linux you have the convert-pgn utility). The "enormous" opening book database (careful, big file) you can find at this address, others from the official crafty page. Apart from the files that you find with crafty, you can download other files, such as specialized pgn files for different openings, for example from here.

You need to compile the opening database first (see readme). In crafty, you type
book create filename 60

EGTBs you can find here or on other sites.

Crafty needs to find these files if you want to use them. On my linux system, I put these databases in /opt/crafty. Crafty's configuration file is called .craftrc in linux (in your home directory) and crafty.rc in windows (no idea where to locate it). My configuration file looks like the following:

mt=2
tbpath=/opt/crafty/
bookpath=/opt/crafty/
egtb !
hash=384M
hashp=128M
cache=32M
ponder=off
smpnice=1
log=off
show book
exit

If you want to dumb it down to beginner level, put the lines set ply 5 and ponder off.

If you want to use a graphical user interface (GUI), there's XBoard, which you can call like this:
xboard -fcp "crafty"

That's so much for crafty, but crafty does not give you statistics about moves, which is useful especially for choosing between opening lines. Scid comes with this functionality.

You can create opening books for scid, which uses a different format (the same that fruit and togaII use) in polyglot (e.g. polyglot make-book -pgn BDG2.PGN -bin poly.bin -max-ply 60. You have to copy the generated file to /usr/share/scid/books/).

However, this book format does not include win/loss statistics. If you want that you have to create a new database in scid, open a pgn file (for example enormous.pgn), and then you can use the opening report (ctrl+shift+o). The opening report includes among other things a section "Moves and Themes" with frequencies, scores, etc. for different moves and positional themes.

You can use stockfish and other engines in scid, over tools->analysis engine. Alternatively, for stockfish, use this command:
xboard -fcp stockfish -fUCI

Cheers! Please leave a comment below for questions and suggestions.

14 comments:

  1. I never understood chess! I am not good at it! my boyfriends tries to teach me, but he stands no chance :))

    ReplyDelete
  2. Baju Wanita OnlineAugust 30, 2012 at 3:43 PM

    Whoa Cools, this is great, thanks it very useful ! Busana Wanita Online

    ReplyDelete
  3. I was in a search for a software for analyzing chess positions and I find this post really helpful for my project on making a game. Thanks for sharing this great information.

    ReplyDelete
  4. I enjoy what you guys are usually up too. This type of clever work and coverage!
    Keep up the very good works guys I've incorporated you guys to blogroll.


    Also visit my blog - goji pro [http://www.imrealestates.com/]

    ReplyDelete
  5. Then the hands of the blue cheap uggs uk cheap uggs sale flash, cheap ugg boots sale there cheap ugg boots for men has been a pair of aqua blue ring, this ring was jade, crystal, each ring on the ring surface are carving of a fish pattern.

    Need adders. Surface pretending to be calm, the heart is rejoicing among the best musical instruments because there is a gap, which is definitely the best instruments used to ring in the top cheap uggs uk goods, cheap uggs sale is not ringing off the hook before Qingmang sword that can be ugg bailey button sale uk compared.

    Thank Shizu. No polite, one took it put it cheap ugg boots uk down, can not wait to bite the fingers will drop cheap ugg boots sale of semen drops of blood on uggs outlet uk it, I saw two large light blue circle instantly cheap kids ugg boots put.

    ReplyDelete
  6. and Lisa told her that she hadn��t been able to finish it. Simpson told her she would like the ending. Over the years Lisa had an on-and-off relationship with Simpson, but it would be closer in some ways than the one christian louboutin outlet she had with her father.

    ReplyDelete
  7. Most of the politicians like PMK leader Ramadoss expect the State Government should come forward to provide LKG & UKG education to all the rural students. Because, all the urban area students are going in the Ist standard after completing these courses. But most of the rural students are joined with out these courses. buy an essay online with a quality proof for all kind of papers writing and it is very essay from others any writing service providers.

    ReplyDelete