21
21
'Teams' ,
22
22
'Tournaments' ,
23
23
'Users' ,
24
+ 'Analysis'
24
25
]
25
26
26
27
@@ -74,6 +75,7 @@ class Client(BaseClient):
74
75
- :class:`tournaments <berserk.clients.Tournaments>` - getting and
75
76
creating tournaments
76
77
- :class:`users <berserk.clients.Users>` - getting information about users
78
+ - :class:`analysis <berserk.clients.Analysis>` - getting analysis of positions
77
79
78
80
:param session: request session, authenticated as needed
79
81
:type session: :class:`requests.Session`
@@ -100,6 +102,7 @@ def __init__(self, session=None, base_url=None, pgn_as_default=False):
100
102
self .broadcasts = Broadcasts (session , base_url )
101
103
self .simuls = Simuls (session , base_url )
102
104
self .studies = Studies (session , base_url )
105
+ self .analysis = Analysis (session , base_url = base_url )
103
106
104
107
105
108
class Account (BaseClient ):
@@ -1118,3 +1121,27 @@ def export(self, study_id):
1118
1121
"""
1119
1122
path = f'/study/{ study_id } .pgn'
1120
1123
return self ._r .get (path , fmt = PGN , stream = True )
1124
+
1125
+ class Analysis (BaseClient ):
1126
+ """Get analysis of chess positions."""
1127
+
1128
+ def evaluate_position (self , fen , multiPv = 1 , variant = 'standard' ):
1129
+ """Get evaluation of position, if stored in the lichess database.
1130
+ Up to 7 million positions stored.
1131
+
1132
+ :param str fen: the chess position to analyze
1133
+ :param multPv: number of variations in the future
1134
+ :param variant: the variant of the position
1135
+
1136
+ :return: the analysis of the queried position
1137
+ with the fen, knodes, depth, and future variations
1138
+ :rtype: dict"""
1139
+
1140
+ path = '/api/cloud-eval'
1141
+ params = {
1142
+ 'fen' : fen ,
1143
+ 'multiPv' : multiPv ,
1144
+ 'variant' : variant
1145
+ }
1146
+ return self ._r .get (path , params = params )
1147
+
0 commit comments