check out the video I have made of playing chess on today’s one of the most popular chess sites. As you can see, I was able to outplay a chess computer at “IMPOSSIBLE” level as its name suggests.
On the web site it has been rated 2300 ELO that compares to a strong master level. So my achievement is quite impressive, considering I have never been studying playing chess professionally, and my rating is about average.
I’m not a professional chess player …but I’m a programmer.
And here is the catch. As you have probably guessed, it is my chess bot that is playing on the video. I was surprised how easy it is to actually build one. The bot opens a browser, logs in to the playing area, reads the moves from the moves list, detects game times and makes its own moves by actually clicking and dragging the pieces over the board. I used Selenium for browser automation and Stockfish – one of the world’ strongest, open sourced chess engine – for “thinking”. All in all, it took less than a hundred lines of Python code and a weekend of hacking around the web sites DOM tree.
I’m not going to publish the source code, not to encourage the usage of such piece of technology against the real players. I think it’s not fair and not fun.
That was a challenge for me as a programmer and it is successfully accomplished. I was able to create an automated player that is much stronger than myself and stronger than majority of human players. This brings me to an interesting point…
It does not matter what you are going to learn, learn Programming!
Plenty of explanations of asynchronous programming exist, but I think the best way to understand its benefits is to wait in line with an idle cashier. If the cashier were asynchronous, he or she would put the person in front of you on hold and conduct your transaction while waiting for the price check. Unfortunately, cashiers are seldom asynchronous. In the world of software, however, event-driven servers make the best use of available resources, because there are no threads holding up valuable memory waiting for traffic on a socket. Following the grocery store metaphor, a threaded server solves the problem of long lines by adding more cashiers, while an asynchronous model lets each cashier help more than one customer at a time.The APM basic flow is visualized below:
The module is waiting for the event. Once there is any, it reacts (thus the name reactor) by calling the appropriate callback:
Python has introduced a high performance asynchronous server framework already since 1995 called Medusa.