Sunfish: A simple but strong chess engine written in Python
github.com
github.com
What is the smallest computer with superhuman cababilities?
I can't find any recent experiment, but here https://en.chessbase.com/post/komodo-8-the-smartphone-vs-des... is a test done in 2014 that shows that smartphones were already clearly superhuman then
In 2019 I estimate we would need less than half of the computing power of that 2014 smartphone to achieve the same playing strength
You can play against it at https://lichess.org/@/sunfish_rs and see its strengths and weaknesses
I think it could be very useful for didactic purposes, or for getting started. Not having all the extra complexities needed for efficient board representation, position evaluation, move generation etc... makes the big picture much clearer imvho
If you're not a top 5% player, it can absolutely give you a good game (especially on fast time controls)
For starters:
- A 12x10 Mailbox board representation.
- Killer move heuristic.
- QSearch.
- Null move pruning.
- Move sorting based on captures and positioning.
- MTD-bi search.
- Mate testing based on king capture.
- Transposition tables.
The Chess Programming Wiki is a great place to learn more about all of these though.
What does pypy bring to this situation?
Conventional chess programs use a similar algorithm and ones like AlphaZero are similar except they use machine learning and neural nets to judge how good positions are rather than a simple point score system.
I remember trying to write a similar one after seeing the algorithm explained on the TV show Tomorrow's World, around 1980. (Here they are explaining the cutting edge of mobile phones in the day https://www.youtube.com/watch?v=vix6TMnj9vY&feature=youtu.be...)
That's a strange statement. For one, because chess players are hardly judges of what is and what isn't AI.
Among chess programmers there may be such an opinion here and there, but originally chess was a classical AI topic and alpha/beta search a classical AI algorithm. As are neural networks and Monte Carlo tree search. So it's quite a strange opinion, IMO.
On the other hand, they happen to be great judges of human- vs engine- style of play. If you ask any of the top players who have spent time reviewing games by chess engines, I think you'll find a consensus around the belief that Alpha Zero and LCZero play far more human-like moves than do engines like Stockfish.
The traditional engine tends to be extremely conservative and materialistic, only playing a sacrifice when it has calculated a line which recovers the material with interest (or forces checkmate). The so-called AIs don't do this. You're far more likely to see them sacrifice material for a long-term positional advantage, like a great human player would.
From my experience looking at Alpha Zero and LCZero wins against Stockfish, one of the more common patterns I see is a sacrifice by the AI which gives such a dominant position that one or more of Stockfish's pieces become uselessly trapped behind their own pawns. It's this sort of position which seems perfectly tailored to exploit Stockfish's materialistic nature.
The original AlphaGo paper even mentioned that they tested the bare neural network predictions against the version with MCTS guided by the network and found that the MCTS version won 100% of the time, which strongly suggests that search is an indispensable part of strong AI performance in games.
Typically, chess engines are built on minimax, with optimizations like alpha beta pruning.