Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Few Alterations and Enhancments #2

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

Juni-crypto
Copy link

Project Files

bot-upgrade.py

This script allows you to upgrade a regular Lichess account into a bot account. The upgrade_to_bot_account function sends a POST request to the Lichess API to convert the account to a bot.

  • Functions:
    • upgrade_to_bot_account(api_token: str): Upgrades a Lichess account to a bot account using the provided API token.

Source file: bot-upgrade.py


create_chess_video.py

This script generates a video replay of a chess game based on a PGN file. It uses Pygame to create frames of the chessboard, saving each as an image, and then uses ffmpeg to compile these images into a video.

  • Features:
    • Visualize a chess game from PGN and save each frame as an image.
    • Compile saved images into an MP4 video using ffmpeg.

Source file: create_chess_video.py


decode.py

This script decodes a file that has been encoded into PGN-formatted chess games. The decode function reads a PGN string, decodes the binary data from chess moves, and reconstructs the original file.

  • Functions:
    • decode(pgn_string: str, output_file_path: str): Decodes a file from a PGN string and writes it to the output file path.
    • run_decoder(): CLI interface for decoding PGN games to files.

Source file: decode.py


encode.py

This script encodes a file into a series of chess games stored in PGN format. It reads the binary data from a file, converts it into chess moves, and stores the moves as PGN games.

  • Functions:
    • encode(file_path: str): Encodes a file into chess games in PGN format.
    • run_encoder(): CLI interface for encoding files to PGN format.

Source file: encode.py


api.py

This script automates chess matches between two Lichess bot accounts. It includes functions for challenging a bot, accepting a challenge, and playing a sequence of predefined PGN moves between two bots.

  • Features:
    • Automates bot-to-bot chess matches.
    • Uses the Lichess API to create and accept challenges.
    • Executes predefined PGN moves.

Source file: api.py


Special Thanks


- Update test.txt to change the content from "subscribe" to "JUST KILLING IT".
- Update .gitignore to include the .env file.
This commit refactors the game playing logic in the `main` function of `api.py` to improve readability and maintainability. It also adds a new feature to allow one of the bots to resign the game after all moves are played. The `resign_game` function is implemented to handle the resignation process. Additionally, the commit includes the creation of a game link and the optional export of the PGN (Portable Game Notation) of the completed game.
@Amirhan-Taipovjan-Greatest-I
Copy link

Amirhan-Taipovjan-Greatest-I commented Nov 1, 2024

Hello!
It can be ve-e-ery off-topic, but due to such bad Python knowledge I have something to say:

I want to use Your Fork, but as Python newbie I've faced with some problems like:

  1. Somewhy when I'm importing all files they are acting as working programs instead being libs:
    For example when I'm putting in My .py file import decode or import encode. all code from My .py file gets ignored and decode.py or encode.py files' code gets used.

  2. Somewhy I can not use create_chess_video.py, here's Log:

[PRIVATEPATH]*>python create_chess_video.py test\pop.pgn
pygame 2.6.1 (SDL 2.28.4, Python 3.11.0)
Hello from the pygame community. https://www.pygame.org/contribute.html
Traceback (most recent call last):
File "[PRIVATEPATH]\create_chess_video.py", line 111, in <module>       main()
File "[PRIVATEPATH]\create_chess_video.py", line 66, in main            load_piece_images()
File "[PRIVATEPATH]\create_chess_video.py", line 25, in load_piece_images
image = pygame.image.load(os.path.join('images', piece + '.png'))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
FileNotFoundError: No file 'images\wp.png' found in working directory '[PRIVATEPATH]'.

*[PRIVATEPATH] has Unicode Characters, if that information can help.

More than 75% that I just don't know how to proper search things... but may be You will help Me. I'll be glad to that.

almost two full days after
P. S. I've figured out that image = pygame.image.load(os.path.join('images', piece + '.png')) wanted from Me all piece pictures... the Standart Piece Style for lichess and Chess is cburnett. Just need to create by Myself images Directory and put those .png files in there.
But about those imported libs I still can't figure out...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants