PyChess – A chess program for your Rasp Pi

Lead Image © LI TZU CHIEN, 123RF.com

Checkmate

Powerful and flexible chess programs have been scarce on the Raspberry Pi, but PyChess even checkmates programs available on other platforms.

The game of chess is one of the oldest strategic board games known to humankind. Despite its centuries-old history, chess has lost none of its fascination, and the advent of computer technology in recent decades has not stopped the game of kings. Computers with multicore processors effortlessly beat most human chess players. The market for chess programs is overrun by countless more-or-less sophisticated competitors that spoil users for choice.

Linux did not play a major role as a platform for chess programs for a long time. Although all major desktops have had graphical chess programs for many years, they have been unable to assert themselves because of functional deficits, poor performance of the chess engines, and a lack of compatibility with the commercial offerings from the Windows world. It was only with the publication of the Java-based chess program Shredder [1], available for Linux for the first time in 2006, that the tide began to turn. Shredder is now regarded as one of the most powerful commercial chess programs in the game, but free applications under Linux have also made significant progress.

Most of the current crop of chess programs on Linux are made up of two components: The graphical user interface (GUI) defines the gaming experience, and above all, supports additional features for advanced users, such as game analysis or replaying matches for training purposes. Underneath the interface, the brain – the actual chess program – interacts with the user. These engines do not have a graphical interface but simply compute the moves.

For many years, free chess engines were unable to keep up with their commercial competitors, but this has now changed. When Stockfish [2] appeared on the Swedish ranking list of the strongest chess engines in 2015, this meant that two free chess programs had made it into the top 10 [3]. Crafty [4], another free engine, has made the headlines on several occasions through its outstanding achievements.

The GUI and the chess program in these solutions communicate via standardized protocols. The quasi standards are the Chess Engine Communication Protocol (CECP), also known as the Xboard protocol due to the GUI of the same name, and the more-recent Universal Chess Interface (UCI).

PyChess

PyChess, a recent development among graphical interfaces for chess programs, supports both CECP and UCI. Originally designed for the Gnome desktop, the Python chess client is based on the Gtk libraries. However, the current version 0.12 "Anderssen" also runs perfectly on Linux desktops that do not rely on Gtk components. The software can now be found in the Raspbian repository; also, the project offers precompiled binaries and the source code on its website [5]. To install PyChess on your Raspberry Pi, open the package manager (Preferences | Add/Remove Software) and search for PyChess, or open a terminal and enter:

sudo apt-get install pychess

After installation, check out the Games submenu for a PyChess entry. When the program first opens, you'll see a nondescript window in which PyChess identifies the chess engine to use. PyChess comes with its own engine called PyChess.py, which is used by default when you launch the software. Below the selection box, you can adjust the skill level of the program.

You can add other engines without much effort: Search in the package manager for packages such as crafty, fairymax, gnuchess, phalanx, sjeng, and stockfish. Once installed, the engine will show up in the Opponent list (Figure 1) after restarting the program. Additionally, the developers of PyChess provide multiple chess engines for download [6].

Figure 1: Online or not online – that is the question. Notice that after the phalanx chess program and the stockfish chess engine are installed, these engines become available for use in PyChess.

In the lower part of the window, you have the option to sign in to the Free Internet Chess Server (FICS) [7], where you can then play live games by entering your username and password. You can enable the desired function by pressing the Start game button to play a game locally or pressing Connect to FICS to start an online match.

Settings

After you click Start game, the program screen appears. Below the menubar at the top, the screen is divided into the two-dimensional chessboard on the left side and several display panels on the right. In the lower section, you will also find a display area with two tabs: Tips and Engines.

All the display areas are empty at the beginning of a new game, but they fill with data as the game progresses so that you can follow every game later on without any problems. Before the first game, it makes sense to configure the software to suit your own needs in Edit | Preferences.

The corresponding dialog lets you add various options to the program window in the General tab arranged on the left. Among other things, you can display levels and ranks around the edge of the chessboard (Show cords) and the captured pieces.

You can also display the move times and evaluations within the program window. In the second tab, Hints, you can set the opening move and select an engine for the analysis function. The selection boxes automatically list all the available engines.

In the middle Sidepanels tab (Figure 2), you can then define which basic information is displayed in the program window: Turning off unnecessary functions removes the clutter from the interface. Then, from the list of active display areas, you can select one or more areas and disable them, pressing the Active button below the settings window.

Figure 2: You can configure the information you want to display in the PyChess Preferences window.

The two rightmost tabs, Themes and Sounds, are used to tune the visuals and sound of the software. For example, you can tell the program to change the chessboard design or to notify you of program messages with acoustic feedback; PyChess features more than three dozen view options.

Buy this article as PDF

Express-Checkout as PDF

Pages: 6

Price $2.95
(incl. VAT)

Buy Raspberry Pi Geek

SINGLE ISSUES
 
SUBSCRIPTIONS
 
TABLET & SMARTPHONE APPS
Get it on Google Play

US / Canada

Get it on Google Play

UK / Australia

Related content

  • Welcome

    We are living with an embarrassment of choice. Small-board computers (SBCs) are getting smaller and faster, with many inexpensive options for the hobbyist and problem-solvers and more powerful, usually pricier, options for inventors, innovators, and CPU-guzzling consumers. New SBCs are entering the market continuously, it seems.

  • Emulating game console classics on the Raspberry Pi

    The Raspberry Pi is particularly well suited for playing classic games, and a pair of promising Rasp Pi distros come preconfigured with several built-in game emulators.

  • Use Scratch's senses to design a game

    To create a game with action and consequences, you need a tool that can sense information in real time. We show how to do this using the Scratch programming environment.

  • Creating a high score leaderboard

    Learn how to save and track player high scores from one game to the next using lists and variables.

  • Synchronizing with broadcasts

    This article draws inspiration from the popular Pokémon Go app to recreate a sprite hunting game in Scratch. The project explores synchronization and randomness as the player explores various backdrops in search of sprites.