May 17, 2012

Ubuntu for Research

Every so often it's time to upgrade to a newer release of your operating system of choice. If you are using linux and you are working in research, this might be an article just for you. Here are some instructions about the installation of Precise Pangolin 12.04, the ubuntu long-term support (LTS) release which has just come out and is to be supported until 2017. See my newer article on the topic that includes some updates.

I wrote two posts before, which were dedicated to installing software for research in ubuntu. This is an update for Ubuntu Precise Pangolin (12.04) a long-term support release. Installation should be extremely easy and basically a one-line command. You just have to love package managers.

If you want to install from scratch, download the new release from the ubuntu site. Otherwise, if you want to upgrade press alt-f2 (or open the terminal) and type
update-manager -d

Once you are done with the basic installation or upgrade, you are ready for more. This means more software repository sources, more software, more libraries. Below comes a basic list, Please feel free to suggest other programs in the comment section.


  • The ssh server.
  • Google Chromium (Chrome) - because it's very fast and now supports smart bookmarks (at least in linux versions)
  • Dropbox - great for synchronizing files across computers and between users. Works with different operating systems.


Statistical tools

Article writing and reference management



Get a new and comprehensive ubuntu sources list from the ubuntu sources list generator. Choose your country, your ubuntu release (12.04) and all the software sources that you think could be useful. I chose for example the canonical partner, restricted, etc, and google linux repository among others. After pressing generate sources, you'll get a file that you should put as /etc/apt/sources.list (don't forget to backup the old one). On the same internet page, you find how to add the repository keys, which you should do before updating your sources (apt-get update).

For mendeley repositories do (you might want to check that 11.04 is still the latest release they officially provide packages for) sudo sh -c 'echo "deb /" >> /etc/apt/sources.list'

For the Adobe Reader repository do sudo apt-add-repository "deb $(lsb_release -sc) partner"

Download the latest package information. sudo apt-get update

I put all the software mentioned above and some more in a single command, so you have everything installed in one wash. No need to search or to sit around and try to fix things.

sudo apt-get install aptitude openssh-server build-essential gcc gcc-doc apt-file gsl-bin gsl-doc-pdf gsl-ref-html libgsl0-dev gsl-bin gsl-doc-pdf libgsl0-dbg libgsl0ldbl glibc-doc libblas-dev maxima maxima-share subversion subversion-tools git screen $(aptitude search R| grep -v ^i | awk '{print $2}' | grep ^r-) octave $(aptitude search texlive | grep -v ^i | awk '{print $2}') untex luatex perl fontforge context-nonfree context-doc-nonfree dvipng imagemagick graphviz gnuplot-x11 gnuplot-doc gnuplot libatlas3gf-base kdevelop kate kile vim-gtk vim vim-addon-manager vim-common vim-doc vim-latexsuite latex2html latex-beamer xpdf writer2latex jabref bibutils hevea hevea-doc wordnet cups-pdf djvulibre-bin djvulibre-plugin pdfedit inkscape scribus pdf2djvu pdf2svg pdftk python-gdbm ipython python3-dev python3-all python-scipy unrar tofrodos epiphany-browser epiphany-extensions scribes lyx claws-mail claws-mail-i18n claws-mail-doc claws-mail-tools libqt4-core libqt4-gui ubuntu-restricted-extras regionset soundconverter gxine libxine1-ffmpeg libstdc++5 libmms0 vim aptitude zim mendeleydesktop -y --force-yes icedtea-plugin sun-javadb-client gimp acroread wine colordiff moreutils libreoffice-writer2latex libreoffice-wiki-publisher libreoffice-pdfimport libreoffice-grammarcheck libreoffice-calc libreoffice-draw libreoffice

This will take a while...

For google chrome I posted instructions earlier. This time I followed instructions other instructions, which are as follows:

wget -q -O - | sudo apt-key add -
sudo sh -c 'echo "deb stable main" >> /etc/apt/sources.list.d/google.list'
apt-get install google-chrome-stable

Linux is an international effort translated into many languages. Depending on the "locale" you choose, your week may start with a Sunday, Saturday, or Monday. Say, you are not a Christian or Jew? You might want to change the first weekday in your calendar to Monday. Here's how.

What I found had difficulty to find at first was how to add applications to the launcher sidebar. Press the windows key, search for "Main Menu." You might have to install it first (you will get prompted). That's the application for editing the application menu that pops up on pressing the windows key and from this menu you can drag and drop items to the launcher sidebar.

You might want to see other of my articles for more tips, such as (for a short selection) smart bookmarks for faster web searches, how to synchronize web browser bookmarks on different work stations, personalize the vim editor, set up a revision control repository, and automatically synchronize data.
You can also see the UbuntuScience community page for some additional information.
Enjoy. Please leave a comment below for questions and suggestions.

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:

egtb !
show book

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.