Hi everyone,
I've just finished a new programming project and book about building a fully automated chess bot for PlayOK.
The interesting part isn't really the chess engine itself. The project is about reverse engineering the WebSocket communication between a browser and an online chess server, then reproducing the necessary behavior in Python.
Along the way, the project covers quite a few different programming topics:
Inspecting WebSocket traffic with browser developer tools
Reverse engineering an undocumented protocol
Identifying and decoding PlayOK message types
Building a WebSocket client in Python
Handling background threads and incoming messages
Maintaining application state
Integrating a UCI chess engine
Translating between different chess-square representations
Bit manipulation and compact move encoding
Working with SAN and UCI notation
Debugging against a real online service
Testing the complete system through actual games
The final bot was able to connect to PlayOK, find available tables, join games, play against real opponents, and continue looking for another game after the first one ended.
I also documented the entire process in a free book, starting from the raw WebSocket traffic and gradually turning it into a working automated chess client.
Book:
https://maksimkorzh.github.io/pcb/
Source code:
https://github.com/maksimKorzh/pcb
YouTube — earlier online testing of the bot:
The book is intended to be useful beyond this particular bot. If you're interested in Python, chess programming, WebSockets, reverse engineering, networking, UCI engines, or simply learning by building a real project, hopefully you'll find something useful in it.
PlayOK Chess Bot — Reverse Engineering a WebSocket
Moderator: Ras
-
maksimKorzh
- Posts: 785
- Joined: Sat Sep 08, 2018 5:37 pm
- Location: Ukraine
- Full name: Maksim Korzh
PlayOK Chess Bot — Reverse Engineering a WebSocket
Didactic chess engines:
https://www.chessprogramming.org/Maksim_Korzh
Chess programming YouTube channel:
https://www.youtube.com/channel/UCB9-pr ... KKqDgXhsMQ
https://www.chessprogramming.org/Maksim_Korzh
Chess programming YouTube channel:
https://www.youtube.com/channel/UCB9-pr ... KKqDgXhsMQ