Coder Social home page Coder Social logo

python-chessx's Introduction

python-chessx

A chess XAI program

Tests PyPI - Python Version PyPI GitHub last commit PyPI - Implementation PyPI - Wheel

  1. Introduction
  2. Dependencies
  3. Features
  4. Tests

1. Introduction

python-chessx is an explainable chess AI that generates commentary for positions/moves in a game of chess.

2. Dependencies

  • Python3 - Download and Install Python3. You can also use your system's package manager to install the latest stable version of python3.
  • For dev work, run the following commands (preferrably in a virtual environment):
pip install -e .

3. Features

  • Provides a utility to generate explanations from a FEN representation of a chess position.
    1. Piece Square Tables
    import chessx.heuristic as heuristic
    import chess
    
    psqt_fen = 'rn2kb1r/pp2qppp/2p2n2/4p1B1/2B1P3/1QN5/PPP2PPP/R3K2R b KQkq - 1 9'
    psqt_util=heuristic.PSQT(psqt_fen)
    
    # generate list of explanations
    exp_list=psqt_util.get_explanations()
    
    # print explanations
    print('PSQT Explanations:')
    for exp in exp_list:
        print(exp)
    1. Trapped Pieces
    tp_fen='r5k1/p4p1p/2p3pb/2N1n2n/1p2PP2/1B2B1PP/PP4K1/3R4 b - - 0 24'
    tp_util=heuristic.TrappedPieces(tp_fen)
    
    # generate list of explanations
    exp_list=tp_util.get_explanations()
    
    # print explanations
    print('Trapped Pieces Explanations:')
    for exp in exp_list:
        print(exp)
    1. Pinned Pieces
    pin_fen='1rk5/8/4n3/5B2/1N6/8/8/1Q1K4 b - - 0 1'
    pin_util=heuristic.PinnedPieces(pin_fen)
    
    # generate list of explanations
    exp_list = pin_util.get_explanations()
    
    # print explanations
    print('PinnedPieces Explanations:')
    for ex in exp_list:
        print(ex)  
    print()

3. Tests

The following command to runs unit tests on the project:

pytest

python-chessx's People

Contributors

abhinav7sinha avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar

Forkers

mykl271

python-chessx's Issues

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.