Metadata-Version: 2.1
Name: j_chess_lib
Version: 0.10.2
Summary: Python library for a j-chess bot. Beep Boop
Home-page: https://github.com/RedRem95/j_chess_lib
Author: RedRem95
License: GNU General Public License v3
Keywords: j_chess_lib
Platform: UNKNOWN
Classifier: Development Status :: 2 - Pre-Alpha
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: GNU General Public License v3 (GPLv3)
Classifier: Natural Language :: English
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.6
Classifier: Programming Language :: Python :: 3.7
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Requires-Python: >=3.6
License-File: LICENSE
License-File: AUTHORS.rst

===========
j-chess-lib
===========

.. image:: https://img.shields.io/github/license/RedRem95/j-chess-lib?style=for-the-badge
        :target: https://github.com/RedRem95/j-chess-lib

.. image:: https://img.shields.io/pypi/v/j_chess_lib.svg?style=for-the-badge
        :target: https://pypi.python.org/pypi/j_chess_lib

.. image:: https://readthedocs.org/projects/j-chess-lib/badge/?version=latest&style=for-the-badge
        :target: https://j-chess-lib.readthedocs.io/en/latest/?version=latest
        :alt: Documentation Status


Python library for a j-chess bot.
This library provides an interface to connect to a j-chess-server_ and play some games with a self written bot.
To see the currently supported j-chess-xsd_ please see Documentation_


* Free software: GNU General Public License v3
* Documentation: https://j-chess-lib.readthedocs.io.

Server and Communication xsd

* Server:
    * .. image:: https://img.shields.io/github/license/JoKrus/j-chess-server?style=for-the-badge
    * See: https://github.com/JoKrus/j-chess-server/
    * Documentation: https://github.com/JoKrus/j-chess-server/wiki
* Communication protocol:
    * .. image:: https://img.shields.io/github/license/JoKrus/j-chess-xsd?style=for-the-badge
    * See: https://github.com/JoKrus/j-chess-xsd/
    * Reference: https://github.com/JoKrus/j-chess-xsd


Features
--------

* Easy connection to server
* Interface to write a bot to play chess
    * Provides different interfaces with different complexity levels
* Pre-implemented bot to play random moves
* Basic generation for legal moves

Install
-------

PyPi package is comeing soon. Until then installation is done via

.. code-block::

    $ pip install j-chess-lib


See Installation_ for detailed instructions

Usage
-----

See here some examples to use this library.
For more detailed explanation see Usage_

Start
#####

See below for an example to start the client with your ai

.. code-block:: python

    from j_chess_lib.communication import Connection
    from j_chess_lib.client import Client
    from j_chess_lib.ai.Sample import SampleAI

    with Connection(server_address, server_port) as connection:
        ai = SampleAI()
        tournament_code = # Your optional UUID tournament code
        client = Client(connection=connection, ai=your_ai, tournament_code=tournament_code)
        client.start()
        client.join()

This example shows how to setup the connection and the client.
The tournament code is optional and does not have to be passed. If None is passed none will be send to the server.
The client is its own thread so you could for example start multiple clients parallel or do some other stuff. Like a gui...

AI
##

See below for an example to implement a very easy AI.
It uses the base-class that automatically stores match and game data when started so you can query it in the move generation when needed

.. code-block:: python

    from uuid import UUID
    from j_chess_lib.ai import StoreAI
    from j_chess_lib.ai.Container import GameState
    from j_chess_lib.communication import MoveData

    class SampleAI(StoreAI):
        def __init__(self):
            super(SampleAI, self).__init__(name=f"Unique Name of your very good AI")

        def get_move(self, game_id: UUID, match_id: UUID, game_state: GameState) -> MoveData:
            enemy, match_data = self.get_match(match_id=match_id)
            white_player = self.get_game(game_id=game_id, match_id=match_id)

            # Your super intelligent code to generate the best chess move ever generated

            move_data = # result of your code
            return move_data

This example initializes a SampleAI

ToDo
----

* Error fallbacks
* Some features

Credits
-------

* Idea and server generated by the nice JoKrus_
* xml library used to generate classes and serialize data xsdata_
* This package was created with Cookiecutter_ and the `audreyr/cookiecutter-pypackage`_ project template.

.. _Cookiecutter: https://github.com/audreyr/cookiecutter
.. _`audreyr/cookiecutter-pypackage`: https://github.com/audreyr/cookiecutter-pypackage
.. _j-chess-server: https://github.com/JoKrus/j-chess-server
.. _server-LICENSE: https://github.com/JoKrus/j-chess-server/blob/master/LICENSE
.. _j-chess-xsd: https://github.com/JoKrus/j-chess-xsd
.. _xsd-LICENSE: https://github.com/JoKrus/j-chess-xsd/blob/master/LICENSE
.. _JoKrus: https://github.com/JoKrus
.. _xsdata: https://github.com/tefra/xsdata
.. _Installation: https://j-chess-lib.readthedocs.io/en/latest/?version=latest
.. _Usage: https://j-chess-lib.readthedocs.io/en/latest/?version=latest
.. _Documentation: https://j-chess-lib.readthedocs.io/en/latest/?version=latest


=======
History
=======

0.0.1 (2022-01-23)
------------------

* Engage in Project

0.1.0 (2022-01-24)
------------------

* Implemented basic api. Still some features to do

0.2.0 (2022-01-24)
------------------

* Added more docu
* Added readthedocs build config

0.2.4 (2022-01-24)
------------------

* Fixed setup.py so it automatically loads xsd and installs classes based on them

0.7.0 (2022-03-10)
------------------

* Added tournament code to client

0.7.3 (2022-03-20)
------------------

* Implemented error messages on not supported messages
* Fixed client not loading completed message when delay between packages is too big

0.8.0 (2022-03-20)
------------------

* Added method to check if move results in the new board you beeing in chess

0.9.0 (2022-03-21)
------------------

* Implemented Example AI that replays a loaded PGN. Automatically selects "path" from pgn matching player color

0.9.1 (2022-03-26)
------------------

* Is promotion Method now returns False on non valid moves

0.10.0 (2022-03-26)
-------------------

* Added methods to predict boards and create fen notation from boards

0.10.2 (2022-03-26)
-------------------

* Fixed pgn analysis when white moved last

