Coder Social home page Coder Social logo

destaq / chess-graph Goto Github PK

View Code? Open in Web Editor NEW
53.0 3.0 13.0 6.14 MB

A program that will produce a graphical sunburst chart of chess openings from the PGN that is provided to it

Python 100.00%
python chess chess-analysis chess-openings sunburst-chart chess-graph

chess-graph's People

Contributors

ddugovic avatar dependabot[bot] avatar destaq avatar kraymer avatar mrpiada avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

chess-graph's Issues

Custom Branching Analysis forms unusual sunburst

When you input a custom way to analyze the data (from a certain position, that is) - the first two positions show up as well.

E.g. if we want to analyze the data from d4 d5, then we will also see d4 d5, but they will be rings that are 100% big.

image

Print (best/worst) line for each move

First of all GREAT WORK ! Amazing tool ;)

I kindly ask you the possibility to print (at least on terminal or on a .txt file) the best (W/B ratio) and worst line for each level.
Something like:

Move Best (W/B, ngames) Worst (W/B, ngames)
1 1.e4 (0.6, 10) 1.d4 (0.4, 12)
2 1.e4 e5 (0.5, 8) 1.d4 Nf6 (0.3, 9)
and so on....

I'm available to help you doing this (just send me an email)

ModuleNotFoundError: No module named 'pgn'

tested on google colab

pip install -U chess-graph 
import chess_graph

result

---------------------------------------------------------------------------
ModuleNotFoundError                       Traceback (most recent call last)
[<ipython-input-4-af3db3b3152d>](https://localhost:8080/#) in <cell line: 1>()
----> 1 import chess_graph

2 frames
[/usr/local/lib/python3.10/dist-packages/chess_graph/new_parser.py](https://localhost:8080/#) in <module>
----> 1 import pgn
      2 
      3 
      4 def parse_games(database, depth, custom_branching, color, name):
      5     database = open(database)

ModuleNotFoundError: No module named 'pgn'

---------------------------------------------------------------------------
NOTE: If your import is failing due to a missing package, you can
manually install dependencies using either !pip or !apt.

To view examples of installing some common dependencies, click the
"Open Examples" button below.
---------------------------------------------------------------------------

Prevent Annoying Lighter Shade

The outermost ring is lighter then the rest. Need to make it the same color to prevent confusion and aesthetic interference.

Graph Traversal Without Brute Force

Currently, this tool can analyze games up to any depth. However, the time it takes to do so is exponentially correlated to depth. This is because it is traversing the PGN using brute force.

To put it into perspective, a depth of 5 takes 30 seconds, a depth of 8 about two minutes.

This is low-priority, as it is unlikely people will want to make graphs to such depths, but if there is any way to improve the execution of the code, that would be great.

Pruning small slices doesn't remove first level

With the new updates to the code, you can now edit the file and remove any slices that are too small, to prevent the fragmentation look.

This works perfectly well - except for the first level!. On the innermost circle, even if you have a move that is played only once - e.g. a4, with a percentage of 0.1% let's say - it still shows up!

image

Here is the code for those interested:
`del_list = []
for i in range(len(percentage_holder)):
if percentage_holder[i] <= 5 and parents[i] != '':
del_list.append(i)

for i in range(len(parents)): # loop through all parents
    if i in del_list: # if that parent is in the bin
        death = ids[i] # find that parent's ID so we can locate children
        for x in range(len(parents)): # loop through parents again to find children
            if parents[x] == death: # if child's parent is equal to death
                del_list.append(x) # mark child for death as well


percentage_holder = [percentage_holder[i] for i in range(len(percentage_holder)) if i not in del_list]
ids = [ids[i] for i in range(len(ids)) if i not in del_list]
labels = [labels[i] for i in range(len(labels)) if i not in del_list]
parents = [parents[i] for i in range(len(parents)) if i not in del_list]
values = [values[i] for i in range(len(values)) if i not in del_list]`

PGN with clock data

Is there a command line argument for the code to ignore the clock data in the pgn? From what I understand, PGN's can have clock data. So when I try it with clock data, the graph looks very strange:
image

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.