Welcome to PicoChess’s documentation !¶
Stand alone chess computer based on Stockfish and DGT board
Contents¶
Introduction¶
Presentation¶
The goal the this project is to create a dedicated chess computer based on tiny ARM computers with the DGT eboard and DGT XL Clock or DGT 3000 Clock We are proud to say that this sourcecode is now also part of the new DGT-Pi
Finally picohess can also interact with a Revelation II Even our focus is on an ARM system like a RaspberryPi you can also run the software on a normal desktop computer nomatter what operation system you prefer.
Features¶
Multiple chess engines are included that run on your ARM computer. Many different game settings and playing levels can be selected. The display guides you through the menu settings and informs you during the game, showing clock times, game moves and hints. Despite the DGT Clocks we also offer a dedicated web-server where you can see the game, analyse openings or master games (we provide a database with over 1.4 million games) just at your fingertips.
Picochess offers many different playing modes. Play against an engine or analyse your games. You can also play against a remote friend/tutor. Fischer Random Chess (Chess960) is also supported (only for the stockfish engine). If you want your games can also be eMailed to your postbox in pgn format.
Performance¶
The provided chess engines offers a wide range for playing styles and strengths. The strongest chess engine Stockfish can be set from 1000ELO to 2500ELO. So, we think you can have fun with PicoChess no matter what playing strength you have. We also provide an engine called Rodent II where y can setup different chess personalities like Attacker, Drunk, Capablanca and many more.
Status¶
Here are some videos from our beginning :-) Nowadays Picochess is alot more matured. Give it a try. You can see a video of PicoChess running on a standard PC, and running on a MK802 II ARM key :-) Also, here is a video of PicoChess running on MK802 II and a bluetooth DGT eboard.
Installation¶
Easy method : using image files¶
This is the easiest installation method, supported on the Raspberry Pi. Many other ARM boards can run picochess (like the powerful Odroid-XU4), but you will need to do a manual-install-label.
You will have to download and install the latest PicoChess image file from the PicoChess downloads and write it to an SD card or to a micro SD card.
You will need to unzip the image with 7zip and write it to a suitable SD card using the UNIX tool dd. Windows users should use Win32DiskImager. Mac OS X users should use ApplePi-Baker. Do not try to drag and drop or otherwise copy over the image without using dd or Win32DiskImager or ApplePi-Baker – it won’t work.
After booting from the new image, you might want to tinker with the machine (i.e. set defaults in the picochess.ini file or install alternative engines). This is done by connecting via ssh:
- On Raspberry Pi, the hostname on local network is ‘raspberrypi.local’, username:pi, pass:picochess.
- On Odroid, the hostname on local network is ‘odroid.local’, username:odroid, pass:odroid.
Copying the image to an SD Card on Windows¶
- Insert the SD card into your SD card reader and check what drive letter it was assigned. You can easily see the drive letter (for example G:) by looking in the left column of Windows Explorer. If the card is not new, you should format it; otherwise Win32DiskImager may hang.
- Download the Win32DiskImager utility.
- Extract the Win32DiskImager executable from the zip file. Note: the PicoChess file after extraction should end in .img. Prior to extraction, it ends in .xz.
- Run the Win32DiskImager utility. You may need to run the utility as Administrator.
- Select the Picochess-RaspberryPix-vx.xx.img image file you extracted earlier.
- Select the drive letter of the SD card in the device box. Be careful to select the correct drive; if you get the wrong one you can destroy your computer’s hard disk!
- Click Write and wait for the write to complete.
- Exit the imager and eject the SD card.
Copying the image to an SD Card on Linux¶
- The following commands should be executed as root. It’s popular to prefix the commands with ‘sudo’, but you can also become root apriori by using the command (may vary depending on distribution): sudo su
- Plug in your SD card and then use the following command to see which /dev/ node it’s located on (be sure of this!): fdisk -l
- Unmount the disk (using /dev/sba as example, verify with step 2): umount /dev/sba*
- Use the ‘dd’ command to copy the image file to the entire disk: dd if=picochess-MK802II-vx.x.img of=/dev/sba bs=16M
- After the previous step is complete, execute “sudo sync” to ensure that the data is fully written before you eject.
- Eject the card.
Copying the image to an SD Card on Mac OS X¶
- Insert the SD card into your SD card reader.
- Download the ApplePi-Baker utility.
- Start the ApplePi-Baker utility. You will be asked for your administrator password.
- Under “Pi-Crust”, select the SD card.
- Under “Pi-Ingredients”, select the Picochess-RaspberryPix-vx.xx.img file you extracted earlier (press the ”...” button to locate the image file).
- Press “Restore Backup” to start writing the PicoChess image file to the SD card. Wait for the write to complete.
- Exit ApplePi-Baker and eject the SD-card.
Alternatively, if you prefer working with Terminal commands, you can follow the following procedure.
- The following commands should be executed as root. It’s popular to prefix the commands with ‘sudo’, but you can also become root apriori by using the command: sudo su
- Plug in your SD card and then use the following command to see which /dev/ node it’s located on (be sure of this!): diskutil list
- Unmount the disk where “N” is the number of the disk taken from the above command: diskutil unmountDisk /dev/diskN If the above command was successful, you will see: Unmount of all volumes on diskN was successful
- Use the ‘dd’ command to copy the image file to the entire disk: dd if=picochess-MK802II-vx.x.img of=/dev/rdiskN bs=16m Note: rdiskN (raw disk) is far faster than diskN on Mac OS X. Alternatively pv picochess-MK802II-vx.x.img | dd of=/dev/rdiskN bs=100m allows one to see progress during the write.
- After the previous step is complete, execute “sudo sync” to ensure that the data is fully written before you eject.
- Eject the card.
Manual installation¶
- Prerequisites
PicoChess is mainly targetted for small devices like the Raspberry Pi, however it also runs on a desktop computer (Linux, Mac OS X, Windows). You will need to install this first:
- Python 3.4 or newer (also comes with pip) (on Mac OS X,
brew install python3
)- git (
sudo apt-get install git
, git executable has to be in the system PATH)- zeroconf (
sudo apt-get install avahi-daemon avahi-discover libnss-mdns
, included on Mac OS X)- espeak and festival (
sudo apt-get install espeak festival
) to enable voice for versions < 0.79- vorbis-tools (
sudo apt-get install vorbis-tools
) to enable voice for versions >= 0.79- sox (
sudo apt-get install sox
) to enable voice speed for versions >= 0.88- develop libraries (
sudo apt-get install python3-dev libffi-dev libssl-dev
)
- Get a copy of the source code
cd /opt
sudo git clone --branch master https://github.com/jromang/picochess.git
cd picochess
- Recommended step for developers: Install virtualenv
Virtualenv provides clean and isolated development environments for your Python projects (
pip3 install virtualenv
orapt-get install virtualenv
).Initialize a new environment:
virtualenv -p python3 venv
Activate the environment:
source venv/bin/activate
No need to use sudo to install Python packages now.
See The Hitchhiker’s Guide to Python for more information about virtual environments.
- Install dependencies
To install the dependencies, you need to use pip3. If you are using Raspbian Jessie, your pip3 installation is probably outdated, resulting in IncompleteRead errors. You can update pip3 as follows:
cd
curl -O https://bootstrap.pypa.io/get-pip.py
sudo python3 get-pip.py
rm get-pip.py
Once you have an up-to-date version of pip3 installed, you can continue to install the PicoChess dependencies:
cd /opt/picochess
sudo pip3 install --upgrade -r requirements.txt
- Build config files
Initialize the config files:
sudo python3 ./build/engines.py
sudo python3 ./build/books.py
sudo python3 ./build/voices.py
- Copy the dgtpi services into the correct place (ONLY needed if you have a DGTPi chess computer)
cd /opt/picochess/etc
sudo cp dgtpi.service /etc/systemd/system
sudo chmod a+x /etc/systemd/system/dgtpi.service
sudo systemctl enable dgtpi
sudo cp dgtpistandby.service /etc/systemd/system
sudo cp dgtpistandby.target /etc/systemd/system
sudo chmod a+x /etc/systemd/system/dgtpistandby.service
sudo systemctl enable dgtpistandby
- Copy the picochess services into the correct place (ONLY needed if you want picochess to startup automatically)
cd /opt/picochess/etc
sudo cp picochess.service /etc/systemd/system
sudo chmod a+x /etc/systemd/system/picochess.service
sudo systemctl enable picochess
sudo cp hciuart.service /lib/systemd/system
sudo reboot
- Run PicoChess: automatically or from the command line
If installed correctly, PicoChess will start automatically at boot (as a service see 6+7). You can also start PicoChess from the command line in standard mode or in console mode (use “console” flag for this).
PicoChess has a lot of options. Type
sudo python3 /opt/picochess/picochess.py -h
for a list.
Make picochess sound better¶
If your output from the RPi audio jack socket is quite low and buzzes a lot add the following line to /boot/config.txt
audio_pwm_mode=2
Afterwards type sudo reboot
.
To make the volume instantly louder (it will also be kept after the reboot) type amixer sset PCM,0 90%
Obviously the percentage can be set to any number, but 100% is too loud.
Bluetooth Connection¶
Bluetooth connection should work out of the box. If it does not, then you can try the following troubleshooting steps:
Install Bluetooth utilities and Bluetooth Manager (in Raspbian Wheezy: sudo apt-get install bluez-utils blueman).
Connect the Bluetooth dongle and restart the Pi.
Start the GUI:
startx
Go to Preferences/Bluetooth Manager.
Click Search to find your device, right click and connect.
For Revelation II use the prepared pin 1234, for DGT bluetooth eboard 0000.
Then click to connect as a serial device.
Back on the Bluetooth Manager right click on the device again and click trusted. Job done!
Open Terminal app and shut down the machine:
sudo shutdown -h -P now
Restart the Pi without the keyboard and monitor and tada! the connection should work.
For more information check this forum post.
Initial Settings¶
At start PicoChess looks at the file
/opt/picochess/picochess.ini
... and sets itself up accordingly. Here is a list of some available options:
- disable-revelation-leds = true
- log-level = debug
- log-file = /opt/picochess/picochess.log
- user-voice = en:al
- computer-voice = en:christina
- disable-confirm-message
To set a particular setting, simply include the appropriate line in the picochess.ini file. For example, to the disable default confirmation message, include this line in picochess.ini:
disable-confirm-message
To remove a setting, delete the appropriate line or comment it out using the hash character (#) or set the option to false. For example, to turn OFF the LED’s on the Revelation II chessbot, this line will do:
disable-revelation-leds = true
UCI engine options can be set in the engines.uci configuration file which you will find in the /opt/picochess/engines/<your_plattform> folder. To set the option, use the uci-option flag.
An example .ini file can be found at /opt/picochess/picochess.ini.example. Uncomment the appropriate options and rename the file to picochess.ini.
Please keep in mind that your picochess.ini file must suit the version of picochess. Old picochess.ini versions might not work with newer versions of picochess (picochess.ini.example is always valid). If you update picochess by hand or by providing the “enable-update” flag please take a look for changed settings and update picochess.ini accordingly.
Usage¶
Setup the starting position¶
Place the pieces in starting position. It doesn’t matter if you have the white or black pieces in front of you. Both ways will work. Keep in mind that with black pieces in front of you the (printed) coordinates of your dgt-board also reversed. You can now start a game by moving a piece or press the lever to let picochess start as white.
Its also possible to play a chess960 (Fischer Random Chess) game. Just set up your chess960 position. Please choose “Stockfish” as your engine, cause the other engines dont support chess960 mode. Before or during your game you can also change your settings like book, time, engine, and many more (see details below). These settings are safed and reloaded, so you start with your old settings first. Settings can be changed by placing the white & black queen at the fields a4-h6 (you must be in the starting position) or by using the clock buttons (no matter the board position). With the queen placing you can change some default values, whereas the clock buttons offers the complete options.
Playing/Training Modes¶
When using these modes, please be patient and don’t rush moves. Allow a few seconds for the scores and moves to appear. If you see any bug when rushing moves, let us know on the mailing list.
- Game mode (enabled by white queen on A5). This is the default mode. You can play against the computer. The clock displays the remaining thinking time for both sides. Press the second button to show the position evaluation, expressed in centipawns. Press again to show a hint (“ponder move”).
- Brain mode (enabled by white queen on B5). This is same as Game mode but the computer is using the permanent brain to think ahead on your thinking time.
- Analysis mode (enabled by white queen on C5): the computer is watching the game, it does not play itself. The clock continually displays the best move for the side to play.
- Kibitz mode (enabled by white queen on D5): the computer is watching the game, it does not play itself. The clock continually displays the position score (right aligned) with the search depth (left aligned).
- Observe mode (enabled by white queen on E5): the computer is watching the game, it does not play itself. The clock displays the remaining thinking time for both sides. Press the second button once to show the position evaluation, twice to show a hint.
- Ponder mode (enabled by white queen on F5): the computer is watching the game, it does not play itself. The clock displays the best move for the side to play in a 2 secs rotation with the position score together with the depth. So, this mode is a combination of “Analysis” & “Kibitz”
- Remote mode (enabled by white queen on H5): this mode will allow you to play against someone over internet. The remote player using the webserver whereas the other player using the pieces as normal to enter moves. A detailed documentation will be provided lateron.
Game mode is the regular mode. If you used one of the other modes, you can return back to game mode by putting the extra white queen on A5. You can also press the fourth button to enter the menu (afterwards choose the Mode submenu) to toggle over the modes (Qa5-Qf5,Qh5 only working in the starting position) see below.
The position score will always be displayed in centipawns from White’s perspective. A negative score means black is ahead. If you have a DGT XL clock (or a Revelation II) the maximum score displayed it +/- 9.99
Choosing skill level¶
Put the extra black queen on the 5th rank of your DGT board to select skill level. The skill range of the currently selected engine is devided by 8 meaning a5 (easiest level) towards h5 (strongest level). Some engines support ELO level or even personalities instead of skill levels. If no skill level is selected, PicoChess uses the highest level if nothing choosen before or your last selected level by default. (Remove the extra white queen if it is still on the board). Please notice that not all chess engines support levels.
In case of “stockfish7” engine:
- Level 3 estimates about 1000 Elo (Absolute beginner)
- Level 9 estimates about 1750 Elo (Mediate club player )
- Level 20 estimates about 3100 Elo (Advanced tournament player)
Another way to choose the skill level is by entering the “engine” menu with the clock buttons. Detailed explanation is below.
Choosing opening books¶
Opening books are set with the extra black queen. (Remove the extra white queen if it is still on the board)
- A3 - No book
- B3 - ECO A - Flank
- C3 - ECO B - Semiopen
- D3 - ECO C - Open
- E3 - ECO D - Closed
- F3 - ECO E - Indian
- G3 - Fun
- H3 - Varied (Default)
- A4 - GM_1950 (> 2500 ELO GM games from 1950 till 2013)
- B4 - Performance
- C4 - Stockfish optimized book v 2.11 by Salvo Spitaleri
- D4 - Anand
- E4 - Korchnoi
- F4 - Larsen
- G4 - Pro
- H4 - GM 2001
Another way to choose the opening book is by entering the “Book” menu with the clock buttons. Detailed explanation is below.
Choosing the engine¶
engines are set with the extra black queen. (Remove the extra white queen if it is still on the board)
- A6 - Stockfish 8
- B6 - Texel 1.07
- C6 - Arasan 20.3
- D6 - Rodent III
- E6 - Zurichess neuchatel
- F6 - WyldChess 10062017
- G6 - Galjoen 0.36
- H6 - Sayuri 2017.09.29
Setting up time controls¶
Picochess supports 3 variants of different time controls (Move, Game, Fischer). You can choose them by placing the extra white queen. (Remove the extra black queen if it is still on the board). Another way to choose the time control is by entering the “Time” menu with the clock buttons. Detailed explanation is below.
Move Time¶
Fixed time controls are set with the extra white queen. Especially in brain mode the engine might move quicker. (Remove the extra black queen if it is still on the board)
- A6 - 1 second per move
- B6 - 3 seconds per move
- C6 - 5 seconds per move
- D6 - 10 seconds per move
- E6 - 15 seconds per move
- F6 - 30 seconds per move
- G6 - 60 seconds per move
- H6 - 90 seconds per move
Game Time¶
Blitz time controls are set with the extra white queen. (Remove the extra black queen if it is still on the board)
- A4 - 1 minute game
- B4 - 3 minute game
- C4 - 5 minute game (Default)
- D4 - 10 minute game
- E4 - 15 minute game
- F4 - 30 minute game
- G4 - 60 minute game
- H4 - 90 minute game
Fischer Time¶
Fischer time controls are set with the extra white queen. (Remove the extra black queen if it is still on the board)
- A3 - 1 minute game with 1 second Fischer increment
- B3 - 3 minute game with 2 second Fischer increment
- C3 - 5 minute game with 3 second Fischer increment
- D3 - 10 minute game with 5 second Fischer increment
- E3 - 15 minute game with 10 second Fischer increment
- F3 - 30 minute game with 15 second Fischer increment
- G3 - 60 minute game with 20 second Fischer increment
- H3 - 90 minute game with 30 second Fischer increment
Clock button support (general)¶
There are now 2 states (one is the “game-playing” state, where you see the clock time or a move) and the other is the “menu” state. Entering the menu state can be done by pressing “>”. Leaving it with “<”. Entering the menu offers the last choosen top-level in menu (for example “Mode”)
If you are not inside the menu (clock showing moves, times), the function is as follows:
- (<) button - showing the last move
- (-) button - showing the last score (right aligned) together with the search depth (left aligned)
- (=) button - start/stop the clock (user turn) or abort the search (engine thinking) or calculate an alternative move (engine showing its move)
- (+) button - showing a hint move (user turn) or the current best move (engine thinking)
- (>) button - Entering the menu
- lever - switch sides If its users turn the engine will begin to calculate its move, otherwise the search is aborted (engine calculating) or the shown move is canceled (engine shows its move). In these cases its your turn.
If you already inside the menu (clock showing you menu or value items) the function is as follows:
- (<) button - moving up a level inside the menu tree. If you already at top exists the menu
- (-) button - showing the previous value inside the menu tree
- (=) button - no function
- (+) button - showing the next value inside the menu tree
- (>) button - moving down a level inside the menu tree. If there is none, it accepts the choosen value and exists the menu
The next chapters decribe each top-level menu items in greater detail.
System shutdown¶
From the start position, replace the white king with the extra white queen; this will shut down the machine (takes a few seconds until the light turns off). You can also do it with only the two white queens on the board (on e1,d1).
System reboot¶
From the start position, replace the black king with the extra black queen; this will reboot the machine (takes a few seconds until the light turns off). You can also do it with only the two black queens on the board (on e8,d8).
PGN file support¶
All moves of the played game along with engine are stored at the end of the game. Every game played with picochess is stored in the /opt/picochess/games folder as “games.pgn” (name can be changed by ini). If you want to end it before and write out the pgn file including the correct result, you can do as following: Placing the two kings on opposite centre squares will signal a resignation: - If both kings on white, the result is white wins and the game recorded 1-0 - If both kings on black, the result is black wins and the game recorded 0-1
Placing the kings on adjacent centre squares on the same rank signals a draw and the game recorded 1/2-1/2. The 4 and 5 rank must be clear of other pieces - only kings.
Community¶
Forum¶
You are encouraged to join the PicoChess group.
Help needed¶
If you would like to be part of this great project feel free to join. We are always looking for people who test our software or help to develop it further. The code is mainly in python3 (with some javascript). You might also help with testing or on the documention ;-)
Free Software¶
Project licence and philosophy¶
This project is Free Software (GPLv3), it means that is if free and that source code is available for modification or enhancement by anyone. PicoChess is and will always remain Free Software. We are working on this program because we like doing so, because we enjoy seeing people use the program.
More than just a toy or an experimental sandbox, we want to create a robust and high-end dedicated chess computer, directly usable by chess players, with the tools and features they need. We hope PicoChess will be more than just a piece of software, but also a human adventure in creating positive chess and friendship exchanges.
Thanks to other projects¶
- PicoChess uses python-chess to handle chess rules, opening books, and PGN files.
- Without a chess engine, PicoChess would be useless : thanks to the Stockfish team !
Get the sources¶
You can get the sources on Github.