Skip to main content

j-chess-lib

https://img.shields.io/github/license/RedRem95/j-chess-lib?style=for-the-badge https://img.shields.io/pypi/v/j_chess_lib.svg?style=for-the-badge 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

Server and Communication 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

$ 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

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

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

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

0.10.3 (2022-03-27)

  • Fixed bug in PGNPlayer with empty pgn

Release files for j-chess-lib 0.10.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for j-chess-lib 0.10.3
File Size Uploaded
j_chess_lib-0.10.3.tar.gz 38.3 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for j-chess-lib 0.10.3
File Interpreter ABI Platform
j_chess_lib-0.10.3-py2.py3-none-any.whl Python 2, Python 3 none any Details

Total release size: 75.4 kB

Release files / j_chess_lib-0.10.3.tar.gz

Download URL j_chess_lib-0.10.3.tar.gz
Size 38.3 kB
Tags Source
SHA-256 checksum
How to use checksums
fa687808baafce98c40208f4eef0ee51f62e1a953403d7d20323d14175212887
BLAKE2b-256 checksum
How to use checksums
6b528078902912d5f9fe1704886a4549c2d5727c4b9e27753781635f58ccea00
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.8.0 pkginfo/1.8.2 readme-renderer/34.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.9 tqdm/4.63.1 importlib-metadata/4.11.3 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.9.12

Release files / j_chess_lib-0.10.3-py2.py3-none-any.whl

Download URL j_chess_lib-0.10.3-py2.py3-none-any.whl
Size 37.2 kB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
4efdfc911904f28cf95780abdc7cf264ccf524841ac4eedc31a6bdd428509e88
BLAKE2b-256 checksum
How to use checksums
e9c46c25e9a48202892c4eb567cf9f7ddbf1d83d745ae549d47135877eaa823c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.8.0 pkginfo/1.8.2 readme-renderer/34.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.9 tqdm/4.63.1 importlib-metadata/4.11.3 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.9.12

Release history Release notifications | RSS feed

This release

0.10.3 This release

2 release files

0.10.2

2 release files

0.10.1

2 release files

0.9.1

2 release files

0.9.0

2 release files

0.8.0

2 release files

0.7.3

2 release files

0.7.2

2 release files

0.7.1

2 release files

0.6.1

2 release files

0.6.0

2 release files

0.5.0

2 release files

0.4.0

2 release files

0.3.1

2 release files

0.3.0

2 release files

0.2.5

2 release files

0.2.4

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page