rhgrant10 / berserk

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

Play against AI problem. #27

Closed 9acca9 closed 3 years ago

9acca9 commented 3 years ago

Hello. I'm trying to make a match against the lichess AI. like this:

reto = berserk.clients.Challenges(session) 
(...)
reto.create_ai(level=6, clock_limit=None, clock_increment=None, days=None, color="black", variant=None, position=None)

but I have a problem ... If I play with white against the AI everything works great. But, if the AI plays with white "my code" (actually is the code of "lichs") is broken ... this happens because the AI has neither "user" nor "id". if player_id != client.games.export(event['game']['id'])['players']['white']['user']['id']:

Therefore, I thought about eliminating those fields (just to test ...), the error is not generated there but the AI move does not reach me. The AI moves for example e2e4 ... and it never reaches me. In fact, the AI movement only comes when I enter the website and cancel the game.

Thanks for your time. I ask you if it occurs to you what could be happening. Maybe it's something related to Berserk ... maybe not. Thanks a lot.

9acca9 commented 3 years ago

The problem is that the AI send the move inmediatly. And i lost that move... Im lost here because just with


for event in board.stream_incoming_events():

            if event['type'] == 'gameStart':

Even there already are a move from the AI. {'id': 'xxxxxx', 'rated': False, 'variant': 'standard', 'speed': 'correspondence', 'perf': 'correspondence', 'createdAt': datetime.datetime(2021, 3, 20, 3, 26, 8, 293000, tzinfo=datetime.timezone.utc), 'lastMoveAt': datetime.datetime(2021, 3, 20, 3, 26, 10, 331000, tzinfo=datetime.timezone.utc), 'status': 'started', 'players': {'white': {'aiLevel': 6}, 'black': {'user': {'name': 'xxxxx', 'id': 'xxxxxxx'}, 'rating': 1404, 'provisional': True}}, 'opening': {'eco': 'B00', 'name': "King's Pawn", 'ply': 1}, 'moves': 'e4'}

9acca9 commented 3 years ago

for someone lost in this "problem". Look here https://github.com/Cqsi/lichs/issues/40