rhgrant10 / berserk

Python client for the lichess API
https://berserk.readthedocs.io
Other
141 stars 36 forks source link

Challenge result does not reflect color #46

Open rwst opened 2 years ago

rwst commented 2 years ago

Description

Challenge result does not indicate color correctly.

What I Did

In [5]: chall.create_ai(level=2, clock_limit=None, color=berserk.Color.WHITE)                                                      
Out[5]: 
{'id': 'UMpK5lST',
 'variant': {'key': 'standard', 'name': 'Standard', 'short': 'Std'},
 'speed': 'correspondence',
 'perf': 'correspondence',
 'rated': False,
 'fen': 'rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1',
 'player': 'white',
 'turns': 0,
 'startedAtTurn': 0,
 'source': 'ai',
 'status': {'id': 20, 'name': 'started'},
 'createdAt': 1639302816645}

In [6]: chall.create_ai(level=2, clock_limit=None, color=berserk.Color.BLACK)                                                      
Out[6]: 
{'id': '3VdaeZQb',
 'variant': {'key': 'standard', 'name': 'Standard', 'short': 'Std'},
 'speed': 'correspondence',
 'perf': 'correspondence',
 'rated': False,
 'fen': 'rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1',
 'player': 'white',
 'turns': 0,
 'startedAtTurn': 0,
 'source': 'ai',
 'status': {'id': 20, 'name': 'started'},
 'createdAt': 1639302860353}

Two AI games were challenged, one with white one with black. As you can see the returned "player" slot is always white.

rwst commented 2 years ago

The workaround would be to use the gameId to get the field by:

games = berserk.clients.Games(session)                                                                                     
[g.get('color') for g in games.get_ongoing() if g.get('gameId') == 'BC3zmVRw' ]