Skip to content

Commit

Permalink
Update eval_swing.py
Browse files Browse the repository at this point in the history
* Add --chessbase flag for pgn from chessbase.

Usage:
python eval_swing.py --input sample.pgn --chessbase
  • Loading branch information
fsmosca committed Apr 21, 2021
1 parent cfd34a4 commit 938af43
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion scripts/evalswing/eval_swing.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,12 @@

class EvalSwing:
def __init__(self, input_pgn, min_depth=1, tcec=False, lichess=False,
spov=True):
chessbase=False, spov=True):
self.input_pgn = input_pgn
self.min_depth = min_depth
self.tcec = tcec
self.lichess = lichess
self.chessbase=chessbase
self.spov = spov

self.num = []
Expand Down Expand Up @@ -131,6 +132,15 @@ def get_eval(
else:
move_eval = 0.0

elif self.chessbase:
# 15. exf6 {[%eval 8,38] [%emt 0:00:09]}
# 8 in cp, depth=38
# cp score is wpov, we need to convert it to spov.
if '[%eval ' in comment:
split_eval = comment.split('%eval ')[1].split()[0].split(']')[0].split(',')[0]
move_eval = float(int(split_eval)/100)
move_eval = spov_score(move_eval, turn)

# Cutechess, winboard, shredder
else:
if len(comment.split()) == 1:
Expand Down Expand Up @@ -365,6 +375,9 @@ def main():
parser.add_argument('--lichess',
action='store_true',
help='Use this flag if pgn is from lichess.')
parser.add_argument('--chessbase',
action='store_true',
help='Use this flag if pgn is from chessbase.')
parser.add_argument('--wpov',
action='store_true',
help='Use this flag if scores in the game are in wpov.')
Expand All @@ -379,6 +392,7 @@ def main():
min_depth = args.min_depth,
tcec=args.tcec,
lichess=args.lichess,
chessbase=args.chessbase,
spov=spov)

a.run()
Expand Down

0 comments on commit 938af43

Please sign in to comment.