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 https://img.shields.io/pypi/v/j_chess_lib.svg 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

Features

  • Easy connection to server

  • Interface to write a bot to play chess
    • Provides different interfaces with different complexity levels

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()
    client = Client(connection=connection, ai=your_ai)
    client.start()
    client.join()

This example shows how to setup the connection and the client. 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

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.5.0.tar.gz (20.8 kB view details)

Uploaded Source

Built Distribution

j_chess_lib-0.5.0-py2.py3-none-any.whl (19.3 kB view details)

Uploaded Python 2 Python 3

File details

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

File metadata

  • Download URL: j_chess_lib-0.5.0.tar.gz
  • Upload date:
  • Size: 20.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.7.1 importlib_metadata/4.10.1 pkginfo/1.8.2 requests/2.27.1 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.10

File hashes

Hashes for j_chess_lib-0.5.0.tar.gz
Algorithm Hash digest
SHA256 1a0e2c893d80c0dc07478bda9cac278acc7290efbf26987228a7db8c577722c5
MD5 434527b65e2df37544d62f02d838829d
BLAKE2b-256 13cddbba1d655e93c5a57360681482111b71fe813b11def7dad52b3d9b273227

See more details on using hashes here.

File details

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

File metadata

  • Download URL: j_chess_lib-0.5.0-py2.py3-none-any.whl
  • Upload date:
  • Size: 19.3 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.7.1 importlib_metadata/4.10.1 pkginfo/1.8.2 requests/2.27.1 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.10

File hashes

Hashes for j_chess_lib-0.5.0-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 f2cc336f96fec1888b73d874e7d4b007248877868795e535f8eba4f22049d70b
MD5 e57547e45cb3efed12f2d93fa79ce192
BLAKE2b-256 dd77aa9328fd8bd5fe1b31acc976052b65f96ef5db01c428567c9621ec489889

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