Git Product home page Git Product logo

j-chess-lib's Introduction

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

j-chess-lib's People

Contributors

redrem95 avatar

Stargazers

Jonas avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.