There are many, here are sample output.
Code: Select all
1kr5/3n4/q3p2p/p2n2p1/PppB1P2/5BP1/1P2Q2P/3R2K1 w - - ce 169; acs 0; acd 11; AE "sf6"; c0 "Material equal or behind but with good search score";
1n5k/3q3p/pp1p2pB/5r2/1PP1Qp2/P6P/6P1/2R3K1 w - - ce 210; acs 0; acd 12; AE "sf6"; c0 "Material equal or behind but with good search score";
1n6/4bk1r/1p2rp2/pP2pN1p/K1P1N2P/8/P5R1/3R4 w - - ce 253; acs 0; acd 13; AE "sf6"; c0 "Material equal or behind but with good search score";
1nr5/1k5r/p3pqp1/3p4/1P1P1PP1/R4N2/3Q1PK1/R7 w - - ce 292; acs 0; acd 11; AE "sf6"; c0 "Material equal or behind but with good search score";
1q4k1/5p1p/p1rprnp1/3R4/N1P1P3/1P6/P5PP/3Q1R1K w - - ce 123; acs 0; acd 14; AE "sf6"; c0 "Material equal or behind but with good search score";
1qr1k2r/1p2bp2/pBn1p3/P2pPbpp/5P2/2P1QBPP/1P1N3R/R4K2 b k - ce 132; acs 0; acd 13; AE "sf6"; c0 "Material equal or behind but with good search score";
1r1b2k1/2r2ppp/p1qp4/3R1NPP/1pn1PQB1/8/PPP3R1/1K6 w - - ce 216; acs 0; acd 11; AE "sf6"; c0 "Material equal or behind but with good search score";
1r1qk1nr/p3ppbp/3p2p1/1pp5/2bPP3/4B1P1/2PQNPBP/R2R2K1 w k - ce 39; acs 0; acd 12; AE "sf6"; c0 "Material equal or behind but with good search score";
1r2n1rk/pP2q2p/P2p4/4pQ2/2P2p2/5B1P/3R1P1K/3R4 w - - ce 434; acs 0; acd 13; AE "sf6"; c0 "Material equal or behind but with good search score";
1r4k1/1rq2pp1/3b1nn1/pBpPp3/P1N4p/2PP1Q1P/6PB/2R2RK1 w - - ce 229; acs 0; acd 13; AE "sf6"; c0 "Material equal or behind but with good search score";
1r4k1/p1rqbp1p/b1p1p1p1/NpP1P3/3PB3/3Q2P1/P4P1P/3RR1K1 w - - ce 80; acs 0; acd 12; AE "sf6"; c0 "Material equal or behind but with good search score";
1r6/R1nk1p2/1p4pp/pP1p1P2/P2P3P/5PN1/5K2/8 w - - ce 145; acs 0; acd 15; AE "sf6"; c0 "Material equal or behind but with good search score";
1rr3k1/1q3pp1/pnbQp2p/1p2P3/3B1P2/2PB4/P1P2RPP/R5K1 w - - ce 42; acs 0; acd 14; AE "sf6"; c0 "Material equal or behind but with good search score";
2b1r1k1/1p6/pQ1p1q1p/P2P3P/2P1pPpN/6P1/4R1K1/8 w - - ce 170; acs 0; acd 12; AE "sf6"; c0 "Material equal or behind but with good search score";
2bq2k1/1pr3bp/1Qpr2p1/P2pNp2/3P1P1P/6P1/5PB1/1RR3K1 w - - ce 204; acs 0; acd 14; AE "sf6"; c0 "Material equal or behind but with good search score";
2kr4/ppqnbp1r/2n1p1p1/P2pP3/3P2P1/3BBN2/1P1Q1PP1/R4RK1 w - - ce 108; acs 0; acd 12; AE "sf6"; c0 "Material equal or behind but with good search score";
2r1kb1r/1bqn1pp1/p3p3/1p2P1P1/3Np3/P1N1B3/1PP1Q2P/R4RK1 w k - ce 34; acs 0; acd 12; AE "sf6"; c0 "Material equal or behind but with good search score";
[...]
Did not check if bestmove of engine here is a capture that gains material.
I Just rely to sts i.e this is strategic test suite.
Code: Select all
"""
get_interesting_pos_from_epd.py
developed on python 2.7.6
Good Score Position Extractor
v1
1. Read epd, find and save pos with compensation for material
Required:
1. inputfile.epd
2. sf6.exe
Output
out_inputfile.epd
"""
from __future__ import print_function
import sys
import os
import subprocess
# Const
INIT_SCORE = -1000000
INIT_DEPTH = 1000
APP_NAME = 'Good Score Position Extractor'
APP_VER = '1.0'
def side_is_equal_or_behind_in_material(s, epd):
""" input is epd or fen
s can be w or b
returns true if side to move is behind or equal in material
"""
Q = epd.count('Q')
q = epd.count('q')
R = epd.count('R')
r = epd.count('r')
B = epd.count('B')
b = epd.count('r')
N = epd.count('N')
n = epd.count('n')
P = epd.count('P')
p = epd.count('p')
wmat = Q * 10 + R * 5 + B * 3 + N * 3 + P * 1
bmat = q * 10 + r * 5 + b * 3 + n * 3 + p * 1
if s == 'w':
if wmat <= bmat:
return True;
else:
assert s == 'b'
if bmat <= wmat:
return True
return False
def delete_file(file_to_delete):
""" Delete existing file """
if os.path.isfile(file_to_delete):
os.remove(file_to_delete)
def analyze_fen(engine, fen_list, inputfilename):
"""
Save pos with good score even if material is equal or behind
fen_list: a list with 4 epd fields
"""
# Engine option
hashval = 64 # 64mb
threadsval = 1
movetime = 200 # Use millisec, 1 sec = 1000 millisec
pos_read_cnt = 0
pos_saved_cnt = 0
outputfilename = 'out_' + inputfilename
delete_file(outputfilename) # Delete existing file
AEngine = engine[0:-4]
# Start the engine
p = subprocess.Popen(engine, stdin=subprocess.PIPE, stdout=subprocess.PIPE)
# Send uci command
p.stdin.write('uci\n')
for eline in iter(p.stdout.readline, ''):
peline = eline.strip()
print(peline) # Print engine info at startup
if 'uciok' in peline:
break;
# Set option values
p.stdin.write('setoption name Hash value %d\n' %(hashval))
p.stdin.write('setoption name Threads value %d\n' %(threadsval))
# Read fen and analyze
for fens in fen_list:
# Init values for saving needed pos
score = INIT_SCORE
depth = INIT_DEPTH
pos_read_cnt += 1
# Console progress display
sys.stdout.write('pos %d \r' %(pos_read_cnt))
# Prepare the engine to execute
p.stdin.write("ucinewgame\n")
fen = fens + ' 0 1'
# We don't check if pos has legal moves or not
p.stdin.write('position fen ' + fen + ' 0 1\n')
p.stdin.write('go movetime %d\n' %(movetime))
# Parse engine output and get score and depth info
for eline in iter(p.stdout.readline, ''):
aa = eline.strip()
# print(aa) # Print engine output
bb = aa.split(' ')
if 'cp' in bb:
score = int(bb[bb.index('cp')+1])
elif 'mate' in bb:
score = 6000
if 'depth' in bb and 'score' in bb:
depth = int(bb[bb.index('depth')+1])
if 'bestmove' in aa:
s = fen.split(' ')
s = s[1] # Get side to move
assert s == 'w' or s == 'b'
if side_is_equal_or_behind_in_material(s, fen):
if score >= 20 and score != INIT_SCORE and depth != INIT_DEPTH:
with open(outputfilename, "a+") as fout:
fout.write('%s ce %d; acs %d; acd %d; AE \"%s\"; c0 \"%s\";\n' %(fens,
score,
movetime/1000,
depth,
AEngine,
'Material equal or behind but with good search score'))
pos_saved_cnt += 1
break
# Quit engine when all fen are analyzed
p.stdin.write('quit\n')
p.stdin.close()
p.communicate()
print('Done!!, read_pos %d, saved_pos %d\n' %(pos_read_cnt, pos_saved_cnt))
def main(argv):
""" Main """
input_fn = 'inputfile.epd'
aengine = 'sf6.exe'
# Check files
if not os.path.isfile(input_fn):
print('%s is missing!!' %(input_fn))
sys.exit(1)
if not os.path.isfile(aengine):
print('%s is missing!!' %(aengine))
sys.exit(1)
fenlist = []
with open(input_fn, 'r') as f:
for lines in f:
line = lines.strip()
# Get the first 4 fields on fen or epd file
s_epd = line.split(' ')
s_epd = s_epd[0:4]
s_epd = ' '.join(s_epd)
fenlist.append(s_epd) # Save to list
# Analyze the saved epd list
analyze_fen(aengine, fenlist, input_fn)
if __name__ == '__main__':
main(sys.argv[1:])