Skip to main content

Python library for a j-chess bot. Beep Boop

Project description

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

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

j_chess_lib-0.7.2.tar.gz (34.2 kB view details)

Uploaded Source

Built Distribution

j_chess_lib-0.7.2-py2.py3-none-any.whl (32.8 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file j_chess_lib-0.7.2.tar.gz.

File metadata

  • Download URL: j_chess_lib-0.7.2.tar.gz
  • Upload date:
  • Size: 34.2 kB
  • Tags: Source
  • Uploaded using 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.8 tqdm/4.63.0 importlib-metadata/4.11.2 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.9.10

File hashes

Hashes for j_chess_lib-0.7.2.tar.gz
Algorithm Hash digest
SHA256 f76a47f885f6f6e3014dcef128e592e85b0dca13106bd74ddfeda3c513513c97
MD5 a207d5d70debd0f9bde1e97b87bf19d2
BLAKE2b-256 779143f068e26af8f7256d2db0edf564bf99f231da79c816890482ee0be92490

See more details on using hashes here.

File details

Details for the file j_chess_lib-0.7.2-py2.py3-none-any.whl.

File metadata

  • Download URL: j_chess_lib-0.7.2-py2.py3-none-any.whl
  • Upload date:
  • Size: 32.8 kB
  • Tags: Python 2, Python 3
  • Uploaded using 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.8 tqdm/4.63.0 importlib-metadata/4.11.2 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.9.10

File hashes

Hashes for j_chess_lib-0.7.2-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 6daa818974f8f54cf30284001635c5e97fb2ddb2e27dae804f0218197f39d770
MD5 e0f55af126825eb3f752289635ec1fc1
BLAKE2b-256 0797daa43c43d7023745d551be518ba2e3dc2a2714e7ca7844cd56e8ace460d6

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page