Package: j-chess-lib
j-chess-libPython library for a j-chess bot.
This library provides an interface to connect to aj-chess-serverand play some games with a self written bot.
To see the currently supportedj-chess-xsdplease seeDocumentationFree software: GNU General Public License v3Documentation:https://j-chess-lib.readthedocs.io.Server and Communication xsdServer:See:https://github.com/JoKrus/j-chess-server/Documentation:https://github.com/JoKrus/j-chess-server/wikiCommunication protocol:See:https://github.com/JoKrus/j-chess-xsd/Reference:https://github.com/JoKrus/j-chess-xsdFeaturesEasy connection to serverInterface to write a bot to play chessProvides different interfaces with different complexity levelsPre-implemented bot to play random movesBasic generation for legal movesInstallPyPi package is comeing soon. Until then installation is done via$ pip install j-chess-libSeeInstallationfor detailed instructionsUsageSee here some examples to use this library.
For more detailed explanation seeUsageStartSee below for an example to start the client with your aifromj_chess_lib.communicationimportConnectionfromj_chess_lib.clientimportClientfromj_chess_lib.ai.SampleimportSampleAIwithConnection(server_address,server_port)asconnection:ai=SampleAI()tournament_code=# Your optional UUID tournament codeclient=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…AISee 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 neededfromuuidimportUUIDfromj_chess_lib.aiimportStoreAIfromj_chess_lib.ai.ContainerimportGameStatefromj_chess_lib.communicationimportMoveDataclassSampleAI(StoreAI):def__init__(self):super(SampleAI,self).__init__(name=f"Unique Name of your very good AI")defget_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 generatedmove_data=# result of your codereturnmove_dataThis example initializes a SampleAIToDoError fallbacksSome featuresCreditsIdea and server generated by the niceJoKrusxml library used to generate classes and serialize dataxsdataThis package was created withCookiecutterand theaudreyr/cookiecutter-pypackageproject template.History0.0.1 (2022-01-23)Engage in Project0.1.0 (2022-01-24)Implemented basic api. Still some features to do0.2.0 (2022-01-24)Added more docuAdded readthedocs build config0.2.4 (2022-01-24)Fixed setup.py so it automatically loads xsd and installs classes based on them0.7.0 (2022-03-10)Added tournament code to client0.7.3 (2022-03-20)Implemented error messages on not supported messagesFixed client not loading completed message when delay between packages is too big0.8.0 (2022-03-20)Added method to check if move results in the new board you beeing in chess0.9.0 (2022-03-21)Implemented Example AI that replays a loaded PGN. Automatically selects “path” from pgn matching player color0.9.1 (2022-03-26)Is promotion Method now returns False on non valid moves0.10.0 (2022-03-26)Added methods to predict boards and create fen notation from boards0.10.2 (2022-03-26)Fixed pgn analysis when white moved last0.10.3 (2022-03-27)Fixed bug in PGNPlayer with empty pgn