how to probe egtb from console?

Discussion of chess software programming and technical issues.

Moderators: Harvey Williamson, bob, hgm

Forum rules
This textbox is used to restore diagrams posted with the [d] tag before the upgrade.
Post Reply
elcabesa
Posts: 837
Joined: Sun May 23, 2010 11:32 am
Contact:

how to probe egtb from console?

Post by elcabesa » Fri May 15, 2015 5:30 pm

are thre some egtb that could be probled from console? i'd like to probe them from a python script

bob
Posts: 20918
Joined: Mon Feb 27, 2006 6:30 pm
Location: Birmingham, AL

Re: how to probe egtb from console?

Post by bob » Fri May 15, 2015 6:23 pm

elcabesa wrote:are thre some egtb that could be probled from console? i'd like to probe them from a python script
One simple thing I have done in the past is to feed Crafty a FEN, then send the "egtb" command and it will return the PV if the game is won or lost, or just a draw score and drawing move otherwise.

elcabesa
Posts: 837
Joined: Sun May 23, 2010 11:32 am
Contact:

Re: how to probe egtb from console?

Post by elcabesa » Fri May 15, 2015 6:29 pm

I'll try.
I have just noticed that Python chess now has the access to egtb

syzygy
Posts: 4792
Joined: Tue Feb 28, 2012 10:56 pm

Re: how to probe egtb from console?

Post by syzygy » Fri May 15, 2015 7:22 pm

elcabesa wrote:I'll try.
I have just noticed that Python chess now has the access to egtb
https://github.com/niklasf/python-chess

Code: Select all

>>> import chess.syzygy

>>> tablebases = chess.syzygy.Tablebases("data/syzygy")

>>> # Black to move is losing in 53 half moves (distance to zero) in this
>>> # KNBvK endgame.
>>> board = chess.Board("8/2K5/4B3/3N4/8/8/4k3/8 b - - 0 1")
>>> tablebases.probe_dtz(board)
-53

>>> tablebases.close()
I'm impressed!

User avatar
sje
Posts: 4675
Joined: Mon Mar 13, 2006 6:43 pm

Re: how to probe egtb from console?

Post by sje » Fri May 15, 2015 9:09 pm

bob wrote:One simple thing I have done in the past is to feed Crafty a FEN, then send the "egtb" command and it will return the PV if the game is won or lost, or just a draw score and drawing move otherwise.
Symbolic spits out the candidate moves with scores. I should add the auto PV in a separate command.

Code: Select all

[] sf 8/2K5/4B3/3N4/8/8/4k3/8 b - - 0 1
[] dmtb
Kd1 LoseIn26
Kd2 LoseIn26
Kd3 LoseIn27
Ke1 LoseIn26
Kf1 LoseIn26
Kf2 LoseIn26
Kf3 LoseIn26
[] sf 7k/8/8/8/8/3R4/1P6/r5K1 w - - 0 1
[] dmtb
Kf2 MateIn74
Kg2 Even
Kh2 Even
Rd1 LoseIn19

Daniel Shawul
Posts: 4047
Joined: Tue Mar 14, 2006 10:34 am
Location: Ethiopia
Contact:

Re: how to probe egtb from console?

Post by Daniel Shawul » Sat May 16, 2015 1:07 pm

elcabesa wrote:are thre some egtb that could be probled from console? i'd like to probe them from a python script
Scorpio egbbs are usable from python right out of the box

Code: Select all

>>> from ctypes import * 
>>> egbb = cdll.LoadLibrary("egbbso.so") 
>>> egbb.load_egbb_xmen("./",4194304,1) 
EgbbProbe 4.1 by Daniel Shawul 
10 egbbs loaded !      
-2050454970 
>>> egbb.probe_egbb_fen("2R5/8/8/4k3/8/8/6K1/8 w - -") 
5609 

User avatar
sje
Posts: 4675
Joined: Mon Mar 13, 2006 6:43 pm

Display Auto PV command

Post by sje » Tue May 19, 2015 11:15 pm

bob wrote:One simple thing I have done in the past is to feed Crafty a FEN, then send the "egtb" command and it will return the PV if the game is won or lost, or just a draw score and drawing move otherwise.
The Display Auto PV command has been added to Symbolic:

Code: Select all

[] sf 8/2Q4K/8/1q6/8/3P4/8/7k w - - 0 1
[] dapv
1. Qc3 Qg5 2. Kh8 Qe7 3. Kg8 Qe8+ 4. Kg7 Qe7+ 5. Kg6 Qe6+ 6. Kg5 Qe3+ 7. Kf5 Kg2 8. Qc4 Qf3+ 9. Kg6 Qg3+ 10. Kf7 Qf2+ 11. Ke7 Qa7+ 12. Ke6 Qb6+ 13. Kf5 Qf2+ 14. Qf4 Qc5+ 15. Qe5 Qf8+ 16. Qf6 Qc5+ 17. Ke4 Qc2 18. Qd4 Kf1 19. Kd5 Qa2+ 20. Kd6 Qg8 21. Kc7 Qf7+ 22. Qd7 Qf4+ 23. Qd6 Qf7+ 24. Kc6 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