emacs-chess icon indicating copy to clipboard operation
emacs-chess copied to clipboard

Engine Analysis?

Open epeld opened this issue 7 years ago • 5 comments

Hi! I just discovered that I can read pgn games with emacs-chess, which is very nice.

Is there a way to have an engine analyze the game while I am viewing it?

epeld avatar Mar 31 '17 14:03 epeld

That was always planned, but is not implemented yet as far as I remember.

mlang avatar Mar 31 '17 14:03 mlang

Indeed. I always used ChessDB for this myself.

jwiegley avatar Mar 31 '17 16:03 jwiegley

OK I would like to try to make it work for me. It doesn't have to be pretty, just a command I could bind to a key to analyze a position for, say 1 second, would be enough.

I've seen there are already functions for sending a position to a running UCI engine. So I figure if I can just find a command to get the FEN for the current position I would be halfway there.

The other half of the problem would be to enumerate all available running engine processes so I can send a command to one of them. The chess-engine module seems promising, but I can't figure out what the 'engine' parameter should be that most functions expect as an argument. Is it the buffer, the process or something else?

Greatful for any help!

epeld avatar Mar 31 '17 18:03 epeld

Progress! (chess-pos-to-fen (chess-game-pos chess-module-game)) gives me a FEN-string (although I didn't know that the move numbers could be omitted, as in: 4r/p4pk//2p4p/P1P/1p/q4PP/6K w - - .)

Now all I need to do is to launch a stockfish process, send it "uci\n" followed by "position fen" followed by "go infinite" and put its process-buffer in a split frame next to the chessboard.

epeld avatar Mar 31 '17 21:03 epeld

Hi again! I made it work :) Not sure if it is of any use to anyone else but it works quite well for quick analyses.

I used this script: https://github.com/epeld/chess-engine.lisp/blob/master/analysis.el

Then I ran e.g (local-set-key (kbd "C-c C-e") 'chess-analysis-analyse) (local-set-key (kbd "C-c C-g") 'uci-stop) from inside the chessboard-buffer and now I get a 'bestmove' suggestion everytime I press C-c C-e :)

epeld avatar Apr 01 '17 14:04 epeld