zefresk / deep-position-analysis Goto Github PK
View Code? Open in Web Editor NEWTo analyse a chess position in depth using powerfull engines
License: MIT License
To analyse a chess position in depth using powerfull engines
License: MIT License
Hi
It appears that --appending flag does nothing.
Also in a multgame pgn file, iterating process seems to freeze due to faulty nps evals (or cache?)
If I recreate .cache-db after each iter completes, process continues as it should...
Can you please take a look?
Thank you
M.N.
Using python3 and installed the dependencies.
Launched liike this:
python3 dpa.py -p ~/soft/git/Stockfish/src/stockfish --pv=4 --depth 3 --ply-depth 5 two_knights_traxler.txt
The analysis seems to work fine, but when it tries to save the results it gives this error message:
Saving result.
Traceback (most recent call last):
File "dpa.py", line 100, in <module>
asyncio.run(main())
File "/usr/lib/python3.8/asyncio/runners.py", line 43, in run
return loop.run_until_complete(main)
File "/usr/lib/python3.8/asyncio/base_events.py", line 616, in run_until_complete
return future.result()
File "dpa.py", line 79, in main
game = new_default_game(board, engine.name, args) # Create a gaame with the correct headers
File "/home/emilio/soft/git/deep-position-analysis/files.py", line 67, in new_default_game
stopping = (format_nodes(args.nodes,"{:1.0f}") +" nodes") if (args.nodes != None) else format_time(args.msec)
File "/home/emilio/soft/git/deep-position-analysis/misc.py", line 33, in format_time
if msec < 10**3: #ms
TypeError: '<' not supported between instances of 'NoneType' and 'int'
Hi,
This is a bug that I got when I tried to run the script.
D:\Chess\deep-position-analysis> python dpa.py --engine "stockfish2206.exe" --depth 2 'French Poisoned Pawn_Schwarz_2022.pgn' --appending --threshold 1.00 --cutoff 0.50 --nodes 10000000
D:\Chess\deep-position-analysis\dpa.py:5: DeprecationWarning: The chess.uci module is deprecated in favor of
chess.engine https://python-chess.readthedocs.io/en/latest/engine.html.
Please consider updating and open an issue
https://github.com/niklasf/python-chess/issues/new if your use case
is not covered by the new API.
import chess.uci
Setting-up engine
PGN input detected we will only analyze from last position(s) reached.
Traceback (most recent call last):
File "D:\Chess\deep-position-analysis\dpa.py", line 100, in
asyncio.run(main())
File "C:\Program Files\Python310\lib\asyncio\runners.py", line 44, in run
return loop.run_until_complete(main)
File "C:\Program Files\Python310\lib\asyncio\base_events.py", line 646, in run_until_complete
return future.result()
File "D:\Chess\deep-position-analysis\dpa.py", line 58, in main
fens = fens_from_file(filename)
File "D:\Chess\deep-position-analysis\files.py", line 33, in fens_from_file
board.push(move)
File "C:\Program Files\Python310\lib\site-packages\chess_init_.py", line 1906, in push
move = self.to_chess960(move)
File "C:\Program Files\Python310\lib\site-packages\chess_init.py", line 3252, in _to_chess960
if move.from_square == E1 and self.kings & BB_E1:
AttributeError: 'GameNode' object has no attribute 'from_square'
This is what I got when I tried to run the script.
Python 3.10.5
Python Chess 0.25.1
The new option --refutation
would include bad moves and their refutation in the final analysis instead of just excluding them. These moves would still not be explored further.
Maybe I should make this the default behavior and use a --no-refutation
parameter instead ?
Hi, cool program, I was wondering if as oppose to picking the top-PV moves, this could be set to choose moves based on a centipawn ranking. I was hoping to use this to calculate all the moves that lead to the shortest possible mate in a position.
Currently --threshold
require a floating point value of pawn whereas --cutoff
need centipawns.
I think all parameters should use the same unit.
Hi,
As promised, I would like to suggest some enhancements to this project:
a) Suppose both the engines agree on a move, then explore it deeper and keep it as top choice.
b) If there is a disagreement - go linearly and try to understand at what point the evals converge. If the eval is positive for the side that we want to do the analysis for (White/Black) then we keep the line, else we remove it.
c) This scenario also has this use-case - suppose there is a move by Leela, which is known for liking different ideas, that is not completely refuted by Stockfish, then explore that idea in further detail.
An extension of the 'chess voting classifier' that I proposed above - use multiple strong engines of today and order 3-4 moves based on individual votes. Do this for each level upto a certain depth in the search tree, then provide a final evaluation based on the top engine being used (Leela/Stockfish).
Right now your script is doing an exponential branching if I am not wrong - if depth is 2 then at the 1st level we have two nodes and then two children for each node correct? So what we can do is that we add another feature that does a linear search i.e. no branches - just give a single line up to a certain ply.
All the enhancements I am suggesting is based on different chess GUI I have explored like Aquarium IDeA, Chessbase DPA (which I currently use) and Extreme Chess Analysis of Banksia GUI. I don't know if we can do all this, but I thought that starting from something is better than starting from nothing.
Would love to know what you think of this. Please label this as an enhancement.
Hello,
When analyzing a pos in really higher depths (>30plies) writing final analysis from memory to a file can be extremely time consuming.
Case study
Some trivial rook ending: 3 connected pwns vs 3 isolated - long mating variations for Black
Starting FEN "8/8/5k2/2PR1ppp/8/2r1PK1P/8/8 b - - 0 56" (Best move f4)
dpa.py -p ./stockfish -d 24 -c ./sf.cfg --depth 30 --pv 10W3B -k 350W60B --threshold 25B g.pgn
(Using: 30 Threads & 16G mem)
......................................
Completed position analysis 1 of 1 from g.pgn in 2 hours 27 minutes 47 seconds.
Saving result.
Saving took ~5h (for ~26M output)!!!
Can this procedure be optimized?
Thank you
M.N.
Hi,
I am a strong CC player (2345 ICCF) who is looking at alternative approaches to analysis. I like your project and the idea behind it and had a few ideas to contribute. Is the project still active? I know a bit of coding as well so perhaps I can try to help there as well.
Thanks,
Tanmay Srinath.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.