Comment by Recursing
2 days ago
For people interested in making their own, I highly recommend reading through https://github.com/thomasahle/sunfish/blob/master/sunfish.py , a surprisingly readable and surprisingly strong chess engine in 111 lines of Python
https://www.chessprogramming.org/ is also really interesting, see e.g. https://www.chessprogramming.org/Sunfish and https://www.chessprogramming.org/Quiescence_Search
> surprisingly readable and surprisingly strong chess engine in 111 lines of Python
Link I get shows 500 lines and it starts with 50 lines of piece-square tables. Maybe it's obvious when you are into the domain but otherwise... that's pretty much of opposite of what I would call "readable".
It appears that the “111 lines” is a reference to the version as of 2014-02-11: https://github.com/thomasahle/sunfish/blob/e2b7fc29ce2a112be... (386 lines), about which the author says (https://www.reddit.com/r/programming/comments/1xmj1a/comment...):
> I got 111 by deleting the tables in the top, and the UI code in the bottom, and then running 'cloc' on the result. That gave 20 blanks, 56 comments and 111 lines of code. ;-)
Yes it's "surprisingly readable" only for being so strong and so concise, definitely not production code.
The file is 500 lines because of the piece square tables (as you mentioned), comments, and the CLI interface logic
Previous HN thread here: https://news.ycombinator.com/item?id=20068651