========================
Database for chess games
========================

.. contents::


Description
===========

This package provides a database for chess games.

When playing through a game a list of all games containing the current position is displayed.

Repertoire games can be defined.  When playing through a repertoire game a list of all games containing the current position is displayed.  Repertoire games are not included in this list.

Chess engines can be used to analyse positions while playing through games or repertoire games.  The analysis can be played through like the game score.  The analysis can be saved on the database for later reference.

Partial positions can be defined and a list of all games containing a position matching the partial position is displayed.

Games can be typed, or imported from files, in PGN `Import Format`_.

Games are indexed by the `seven standard tags`_ defined by the PGN standard.

Games can be edited or deleted.

Games can be output to PGN files in `Export Format`_, `Reduced Export Format`_, or an import format excluding comments and glyphs.


Installation Instructions
=========================

Install the package by typing

   python setup.py install

at the command prompt with setup.py in the current directory.

You may need to give the path and version of Python depending on your system's configuration:

   <path to python>/python<version> setup.py install

   For example

      C:\\Python36\\python setup.py install

         on Microsoft Windows or

      python3.6 setup.py install

         on Unix-like systems.

Use `Python`_ 3.6 or later.


Chess Engines
=============

Chess engines which support the `Universal Chess Interface`_ (UCI) can be used to analyse positions.  Wikipedia `UCI entry`_ links to the specification too.


Database Interfaces
===================

The default database interface is the sqlite3 module distributed with Python.

The `apsw`_ interface, if installed, to Sqlite 3 is used instead of the sqlite3 interface.

New databases are accessed using these alternative interfaces if installed.

* `bsddb3`_
* `dptdb`_ (Microsoft Windows only)

If both alternatives are installed, chesstab will use dptdb.

If bsddb3 is used, a version of `Berkeley DB`_ supported by bsddb3 must be installed.


Fonts
=====

The chesstab package incudes the Chess Merida, Chess Cases, Chess Motif, and Chess Lucena fonts by Armando H Marroquin.

These are available from `www.enpassant.dk/chess/fonteng.htm`_ and the relevant files have been included in this package for convenience.

Install at least one of these fonts using the tool(s) available on your platform.


Run
===

The command to run this package is:

   python -m chesstab.chessgames

You may need to give the path and version of Python depending on your system's configuration:

   <path to python>/python<version> -m chesstab.chessgames

   For example

      C:\\Python36\\python -m chesstab.chessgames

         on Microsoft Windows or

      python3.6 -m chesstab.chessgames

         on Unix-like systems.

Or use the facilities of your desktop (Microsoft Windows, GNOME, KDE, ...) to set up a convenient way of starting chessgames. 

At least one database engine supported by the `solentware-base`_ package must be installed.


Notes
=====

A database of about 1.5 million games will occupy between 10 and 15 Gbytes.

Importing 1.5 million games will take at least a few hours.  For example about 12 hours on a 1.8GHz CPU with 2Gb 667MHz DDR2 SDRAM, and about 30 hours on a 1.7GHz CPU with 1Gb DDR266 RAM.

These figures were obtained using the Enormous database from:

`ftp://ftp.cis.uab.edu/pub/hyatt/pgn`_.

Partial position searches are always much quicker using the `dptdb`_ database interface.

When using the sqlite3, apsw, or `bsddb3`_ database interfaces, you may notice better response times on partial position searches if the `bitarray`_ module is installed.

The sqlite3 and apsw database interfaces are equivalent, but all other pairings are incompatible.


.. _`Import Format`: http://www6.chessclub/help/PGN-spec
.. _`seven standard tags`: http://www6.chessclub/help/PGN-spec
.. _`Export Format`: http://www6.chessclub/help/PGN-spec
.. _`Reduced Export Format`: http://www6.chessclub/help/PGN-spec
.. _`Python`: https://python.org
.. _`www.enpassant.dk/chess/fonteng.htm`: http://enpassant.dk/chess/fonteng.htm
.. _`ftp://ftp.cis.uab.edu/pub/hyatt/pgn`: ftp://ftp.cis.uab.edu/pub/hyatt/pgn
.. _`bitarray`: https://pypi.python.org/pypi/bitarray
.. _`bsddb3`: https://pypi.python.org/pypi/bsddb3
.. _`dptdb`: http://solentware.co.uk/download.html
.. _`Berkeley DB`: http://oracle.com
.. _`Universal Chess Interface`: http://www.shredderchess.com/div/uci.zip
.. _`UCI entry`: https://en.wikipedia.org/wiki/Universal_Chess_Interface
.. _`apsw`: https://github.com/rogerbinns/apsw
.. _`solentware-base`: http://solentware.co.uk/components.html
