fsmosca / chess-artist

A python script that can annotate chess games in pgn file with static evaluation or search score of an engine, can annotate an epd file with acd, acs, bm, and ce opcodes, can test engine with epd test suite and can generate chess puzzles.
GNU General Public License v3.0
70 stars 18 forks source link

Enhancement? w/ fix: Linux Doesn't Need Engine in same folder #37

Closed kalegood closed 7 years ago

kalegood commented 7 years ago

Sorry, only the second time I've used Git in a number of years, so I'm posting this one-line fix here.

Adding sys.platform check at line 85 allows use of system installation of engine on linux. Not sure if this will create other issues:

    # engine file is missing. Excluding Linux
    if not sys.platform.startswith('linux'): 
        if not os.path.isfile(engfn):
            print('Error! %s is missing' %(engfn))
            sys.exit(1)
fsmosca commented 7 years ago

I am not so familiar with linux and I don't clearly understand what is this

system installation of engine

In windows one can specify an engine or an engine with a path like,

-eng C:\chess\engines\nobook\BrainFish\BrainFish_170106_x64_modern.exe

So the engine in this case does not necessarily be in the same dir with the chess-artist script.

kalegood commented 7 years ago

In Linux, almost everything is installed via a package manager. As long as this is done (which is what people will do for something as readily available as stockfish), the package can be called from any directory simply by name (no extension needed).

So whether I am in /downloads or /turtlepictures/lastsunday/onthebeach/, endering "stockfish", I can simply type "stockfish" and it will start. No need to specify install directory. (i.e. have the same effect as typing C:\chess\engines\nobook\BrainFish\BrainFish_170106_x64_modern.exe)

(linux, and I think OSX, use / instead of ).

fsmosca commented 7 years ago

I can also do that in windows if I set some environment variables. Just type stockfish in console and it will run.

So what really is the issue here. Can you not run chess artist in linux?

kalegood commented 7 years ago

Just an enhancement, not really a bug.

An installation of the engine in the same folder as the script is not necessary to run the script in linux (to test it, I just deleted that block of code). The fact that that block of code kills the script if it doesn't find a local-directory executable creates unnecessary complexity for linux users. (of course, it complicates the code a bit).

An alternative solution: README should say that either a local install or the full path should be used (if memory serves, it just says local install). For linux, an example would be /usr/bin/bash (no C:\ or anything.).

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/fsmosca/chess-artist/issues/37#issuecomment-288412294, or mute the thread https://github.com/notifications/unsubscribe-auth/ADYODiK-qCVAZ6_5v5qma8tUlCx4FC9xks5roS1xgaJpZM4MkC3y.

fsmosca commented 7 years ago

The fact that that block of code kills the script if it doesn't find a local-directory executable creates unnecessary complexity for linux users.

That is the code is designed for, it should know where the engine is located.

I generally don't like using paths, I like the user, to just copy the engine to the dir where the script is located. Or copy the script to the location of the engine.

I will update the readme later.

Can you provide a description for linux user?

I will revise the readme for windows user too.

Thanks for mentioning this case to my attention.

kalegood commented 7 years ago

Sure. For clarification:

The readme says "Location or directory of input pgn file, engine file, and this script (chess-artist.py) should be the same"

This is a little unclear. I originally read it "should" as "must". However, after speaking with you, I think you might mean

"The developer advises that this script, the engine file, and the pgn file all reside in the same directory."

Because clearly they don't need to be. One could use a full path name (as well as relative path names; I checked in linux (not sure if there is such a thing in Windows)).

For example:

chess-artist -inputfile /home/kale/somewhereelse.pgn -eng /anotherplace/stockfish etc

works.

Let me know and I can retype that section so it is more clear. I was thinking along the lines of:

"The developer advises that this script, the engine file, and the pgn file all reside in the same directory. However, path names can be specified to both the pgn file and the engine."

Which should be enough for any Linux user who also knows how to use google. Just in case they didn't, you could add:

"Linux users can find the path to their engine using the "which" command."

Is that helpful?

Best, Kale


Kale Good Guitar Studio ♫ phillyguitarlessons.com http://phillyguitarlessons.com phone: (215)260-5383

Google+ https://plus.google.com/b/105422331794047992190/ Facebook http://facebook.com/KaleGoodGuitarStudio Read my article "The Seven Secrets to Six String Success http://www.guitarnoise.com/lesson/seven-secrets-to-six-string-success/" at GuitarNoise.com http://guitarnoise.com Leading the Journey from No-Skills-Guitarist to Talented Musician!

On 03/22/2017 09:17 PM, fsmosca wrote:

The fact that that block of code kills the script if it
doesn't find a local-directory executable creates unnecessary
complexity
for linux users.

That is the code is designed for, it should know where the engine is located.

I generally don't like using paths, I like the user, to just copy the engine to the dir where the script is located. Or copy the script to the location of the engine.

I will update the readme later.

Can you provide a description for linux user?

I will revise the readme for windows user too.

Thanks for mentioning this case to my attention.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/fsmosca/chess-artist/issues/37#issuecomment-288588589, or mute the thread https://github.com/notifications/unsubscribe-auth/ADYODmvm5tp8PcZA3P1xU6AJevMaiVzlks5rocgwgaJpZM4MkC3y.

fsmosca commented 7 years ago

That readme indeed needs to be updated. I did not use the word 'must' because there can be other ways to do it.

Before Chess Artist I have Game Analyzer and people can use an engine with path and without path. So I did not bother detailing on what to write in the option value in this readme.

In windows you can also specify absolute and relative path.

The following can be included in readme G.3.

"The developer advises that this script, the engine file, and the pgn
file all reside in the same directory. However, path names can be
specified to both the pgn file and the engine."

I need to revise also some parts of the readme. I hope to a get a good readme on release 1.0.

kalegood commented 7 years ago

Yeah, let me know if you want any help on the readme. The program is way, way more complex than my python skills allow me to help with (I have very little python knowledge) (I'm going to try to have a friend look over it with me).

I like the idea of outputting FEN; it would be super-easy to programatically create a book of chess problems from any PGN file using LaTex. Hopefully I can figure it out.

Best,

Kale


Kale Good Guitar Studio ♫ phillyguitarlessons.com http://phillyguitarlessons.com phone: (215)260-5383

Google+ https://plus.google.com/b/105422331794047992190/ Facebook http://facebook.com/KaleGoodGuitarStudio Read my article "The Seven Secrets to Six String Success http://www.guitarnoise.com/lesson/seven-secrets-to-six-string-success/" at GuitarNoise.com http://guitarnoise.com Leading the Journey from No-Skills-Guitarist to Talented Musician!

On 03/23/2017 01:41 AM, fsmosca wrote:

That readme indeed needs to be updated I did not use the word 'must' because there can be other ways to do it.

Before Chess Artist I have Game Analyzer and people can use an engine with path and without path. So I did not bother detailing on what to write in the option value in this readme.

In windows you can also specify absolute and relative path.

The following can be in included in readme G.3.

|"The developer advises that this script, the engine file, and the pgn file all reside in the same directory. However, path names can be specified to both the pgn file and the engine." |

I need to revise also some parts of the readme. I hope to a get a good readme on release 1.0.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/fsmosca/chess-artist/issues/37#issuecomment-288622824, or mute the thread https://github.com/notifications/unsubscribe-auth/ADYODl8vfn-VwFpTFhC3KdR6kLSdQgnwks5rogYYgaJpZM4MkC3y.

fsmosca commented 7 years ago

Sure.

Parsing notations of a pgn file and outputing the fen after a specific move in the game ca be done thru the use of python-chess modules.

http://python-chess.readthedocs.io/en/v0.17.0/

I am not familiar with latex, I just read it now and it looks cool. Converting a fen into a diagram would be a challenge. Parsing a pgn file, analyzing positions with the engine, and if interesting output the fen would be easy.

There is SVG rendering in python-chess.

http://python-chess.readthedocs.io/en/v0.17.0/svg.html

But I have not tried it yet. It seems like it can convert a fen into a diagram.

kalegood commented 7 years ago

LaTex can process the FEN diagrams and create the images itself. This is nice because then your LaTex input file isn't full of a ton of links to images; rather, it only has FEN strings which are converted to images when the LaTex file is processed.

So all that needs to be done is to find a LaTex template that works (or create one) and have python-chess dump FEN diagrams into that template (we'll call it template.lyx). Then you just run template.lyx through LaTex and you've got your book.

I think a lot of people would be interested in that. However, I'm more interested in using the FEN output with Anki, a memorization application. (https://www.ankiapp.com/). For that, all I need to do is to be able to dump output into a CSV file (which I can then import into Anki). Of course, the difference between these two things is rather trivial; one dumps to CSV, the other dumps to a LaTex file.

Maybe the easiest way to get what I'm looking for is just to use chess-artist to analyze my games and have python-chess go through and look for annotations.

Best, Kale


Kale Good Guitar Studio ♫ phillyguitarlessons.com http://phillyguitarlessons.com phone: (215)260-5383

Google+ https://plus.google.com/b/105422331794047992190/ Facebook http://facebook.com/KaleGoodGuitarStudio Read my article "The Seven Secrets to Six String Success http://www.guitarnoise.com/lesson/seven-secrets-to-six-string-success/" at GuitarNoise.com http://guitarnoise.com Leading the Journey from No-Skills-Guitarist to Talented Musician!

On 03/23/2017 10:31 AM, fsmosca wrote:

Sure.

Parsing notations of a pgn file and outputing the fen after a specific move in the game ca be done thru the use of python-chess modules.

http://python-chess.readthedocs.io/en/v0.17.0/

I am not familiar with latex, I just read it now and it looks cool. Converting a fen into a diagram would be a challenge. Parsing a pgn file, analyzing positions with the engine, and if interesting output the fen would be easy.

There is SVG rendering in python-chess.

http://python-chess.readthedocs.io/en/v0.17.0/svg.html

But I have not explored it yet. It seems like it can convert a fen into a diagram.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/fsmosca/chess-artist/issues/37#issuecomment-288737419, or mute the thread https://github.com/notifications/unsubscribe-auth/ADYODi9QWZ9jvWCC0zPz79ZnNnlu0kZ-ks5rooJHgaJpZM4MkC3y.

kalegood commented 7 years ago

LaTex also has this package (haven't looked at it much myself yet)

http://python-chess.readthedocs.io/en/v0.17.0/


Kale Good Guitar Studio ♫ phillyguitarlessons.com http://phillyguitarlessons.com phone: (215)260-5383

Google+ https://plus.google.com/b/105422331794047992190/ Facebook http://facebook.com/KaleGoodGuitarStudio Read my article "The Seven Secrets to Six String Success http://www.guitarnoise.com/lesson/seven-secrets-to-six-string-success/" at GuitarNoise.com http://guitarnoise.com Leading the Journey from No-Skills-Guitarist to Talented Musician!

On 03/23/2017 10:31 AM, fsmosca wrote:

Sure.

Parsing notations of a pgn file and outputing the fen after a specific move in the game ca be done thru the use of python-chess modules.

http://python-chess.readthedocs.io/en/v0.17.0/

I am not familiar with latex, I just read it now and it looks cool. Converting a fen into a diagram would be a challenge. Parsing a pgn file, analyzing positions with the engine, and if interesting output the fen would be easy.

There is SVG rendering in python-chess.

http://python-chess.readthedocs.io/en/v0.17.0/svg.html

But I have not explored it yet. It seems like it can convert a fen into a diagram.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/fsmosca/chess-artist/issues/37#issuecomment-288737419, or mute the thread https://github.com/notifications/unsubscribe-auth/ADYODi9QWZ9jvWCC0zPz79ZnNnlu0kZ-ks5rooJHgaJpZM4MkC3y.

fsmosca commented 7 years ago

If latex is capable of converting fen to diagram that would be great.

I am closing this issue, just updated the readme.

If you need some help on parsing pgn or others you may post at, http://talkchess.com/forum/index.php