We had an equinoctial matchup at 18:00GMT on 21st December (midwinter in the Northern hemisphere and midsummer in Australia) between the neural-network based CrazyAra and the 2017 Crazyhouse World Champion JannLee. CrazyAra was created as part of a university project at the Technische Universität Darmstadt by Johannes Czech (IQ_QI), Moritz Willig (RiseOfLight) & Alena Beyer inspired by the methods of AlphaZero which they were being taught as part of a masters’ course "Deep Learning: Architectures & Methods" held by Prof. Kristian Kersting and Prof. Johannes Fürnkranz in summer 2018.
Since, in crazyhouse, you can drop any piece in hand (up to 5 choices) on any unoccupied square (at least 32 choices), the number of possible moves and move sequences is several orders of magnitude higher than in regular chess. Nevertheless, it is still several orders of magnitude less than the square of the number of squares on a chessboard, so it was not too difficult to encode all these possibilities. Still, most of these possible moves are clearly not even worth considering. But how to build a program that has this intuition so that it does not waste precious time and electricity on obviously futile moves? This is where the CrazyAra neural network comes in which attempts to predict most-likely moves based on a period of training on over half a million crazyhouse games played on Lichess over a two-and-a-half year period (January 2016 – June 2018) between players both rated over 2000 in the variant. This training data featured over 25 000 games by mathace, as well as over 10 000 games played by ciw, retardedplatypus123, xuanet, dovijanic, KyleLegion, JannLee, crosky, mariorton, opperwezen, saturos & mastertan, all well-known strong regulars in the crazyhouse community. But as well as this store of learned intuition, the program also needed to be able to follow through concrete lines. For this, it uses a Monte-Carlo tree search (MCTS in the jargon) to search through all possible moves evaluating likely outcomes. While at depth 1 (one half-move deep) all possible moves are considered, the deeper it analyses, the more it draws on the neural network of intuition built up from half a million games of training data.
To delve deeper into the technicalities, check out the github and wiki pages, but we hope to explain the basic idea here. For every board position, CrazyAra compares to the neural net built up from its training on the games data to assess firstly the probabilities or p-values of every possible move in this position. If a move is more likely, then CrazyAra will explore that branch of the tree to a greater depth. Secondly, the neural net will try to fit the given position to the neural net produced from all the positions on which it has trained to give it a q-value indicating the likelihood of a win or loss (ranging from -1 for a loss to +1 for a win) from the given start position. This network q-value will change of course as the Monte-Carlo search tree is run depending on the q-values of the children nodes reached by following the most likely lines of continuation.
The name CrazyAra is based on a genus of South-American parrot (ara), the etymology of which presumably derives from the sound they make “arara...”. Parrots are intelligent animals which are able to learn from and mimic human behaviour. In the case of CrazyAra, the neural network tries to replicate human play and predict the outcome of games. In fact, the name DeepLee was originally considered as a combination of DeepMind (the British company bought up by Google which created AlphaZero) and JannLee, the World Champion who was a major inspiration for starting the project and how the second author (IQ_QI) and his collaborators were introduced to the crazyhouse variant. Crazyhouse seemed like an interesting hybrid between chess and shogi (both of which AlphaZero had learned to play) which had not been tackled before by any neural network engine. But the name DeepLee was already taken, so CrazyAra it was. Nevertheless, it was a great privilege that JannLee was willing to play it.
To delve deeper into the technicalities, check out the github and wiki pages, but we hope to explain the basic idea here. For every board position, CrazyAra compares to the neural net built up from its training on the games data to assess firstly the probabilities or p-values of every possible move in this position. If a move is more likely, then CrazyAra will explore that branch of the tree to a greater depth. Secondly, the neural net will try to fit the given position to the neural net produced from all the positions on which it has trained to give it a q-value indicating the likelihood of a win or loss (ranging from -1 for a loss to +1 for a win) from the given start position. This network q-value will change of course as the Monte-Carlo search tree is run depending on the q-values of the children nodes reached by following the most likely lines of continuation.
The name CrazyAra is based on a genus of South-American parrot (ara), the etymology of which presumably derives from the sound they make “arara...”. Parrots are intelligent animals which are able to learn from and mimic human behaviour. In the case of CrazyAra, the neural network tries to replicate human play and predict the outcome of games. In fact, the name DeepLee was originally considered as a combination of DeepMind (the British company bought up by Google which created AlphaZero) and JannLee, the World Champion who was a major inspiration for starting the project and how the second author (IQ_QI) and his collaborators were introduced to the crazyhouse variant. Crazyhouse seemed like an interesting hybrid between chess and shogi (both of which AlphaZero had learned to play) which had not been tackled before by any neural network engine. But the name DeepLee was already taken, so CrazyAra it was. Nevertheless, it was a great privilege that JannLee was willing to play it.
CrazyAra first came online on Lichess three months ago to test its mettle against members of the crazyhouse community such as okei, Andrey2888, Flourish and gsvc. Version 0.1 impressed with its attacking flair and opening innovations, but it was still very beatable.
The first author (okei) was disappointed to win only one game out of ten, letting slip many promising positions. In one surprising game with gsvc, CrazyAra was doing very well against the Paraguayan IM who is in the top 5 in the world, but then CrazyAra help-mated herself in one and gsvc duly gave the smothered mate.
The first author (okei) was disappointed to win only one game out of ten, letting slip many promising positions. In one surprising game with gsvc, CrazyAra was doing very well against the Paraguayan IM who is in the top 5 in the world, but then CrazyAra help-mated herself in one and gsvc duly gave the smothered mate.
Version 0.3 came online for just 24 hours three weeks ago and was a much tougher proposition. TheFinnisher was beaten 10 times before finally being the first to beat it. The programmers had completely re-written the Monte-Carlo search tree algorithm in Version 0.2 as well as completely re-training the neural network using a new deeper architecture (19 layers instead of 7, as well as squeeze-and-excitation modules) which not only gave better predictions but also took less time to train. Originally, it hadn't been planned to continue the project further. But the developers were surprised by the interest shown as well as the supportive attitude from the main stockfish developers for crazyhouse, Fabian Fichter, Daniel Dugovic and well known chess-engine programmers such as gbtami. Version 0.3 included faster profiling, evaluating 250 nodes of the search tree per second (up from 70) and better time management thanks to feedback from gsvc, so that more obvious moves would be played more quickly.
Some further tweaks were made in Version 0.3.1 which was the version that played JannLee three days ago. For example, a position already analysed previously in the Monte-Carlo tree search would not be analysed afresh if it occurred again, and the speed was upped to 300 nodes per second.
Here is the live stream of the five games that CrazyAra played with JannLee. Following the video are annotated studies of each of the five games, looking from CrazyAra’s perspective.
JannLee came into game 1 thinking, “If I'm going to have any chance against the engine, it's going to be a strategic motif, not open tactical warfare.” And so he began to probe the engine’s positional understanding but CrazyAra proved herself no slouch at strategy, gradually improving her position and grinding the game out.
Both JannLee and CrazyAra missed 22. N@f6+ with a forced mate in 3! But the actual finish was much more spectacular. Game 2 will always be remembered for the stunning tactical motif with which JannLee unclasped CrazyAra’s defences: 30. N@g6!! followed by 32. Q@d6! (although as you can see in the study, 32. Q@f6!! with the further idea of attacking g7 was even stronger).
Game 3 was a masterclass from the engine.
In game 4, Jann spotted a mating idea with Q@f7 followed by Qxe7+ but not being able to see the full continuation he did not follow through on his plan, and let slip what would have been a good win.
In the given position in game 5, CrazyAra had a mate in 4! But she missed it and proceeded to let slip a dominant position as JannLee defended like only JannLee can. But just as JannLee was regaining command, he sacked a queen (which although objectively the best move it gave CrazyAra a lifeline) and then missed the critical 57. ... Q@g4+! mopping up CrazyAra’s attack. He instantly regretted it, and even more so when the discovered check on move 64 that he had calculated not to be dangerous came with a back rank threat that he had not foreseen. CrazyAra had won with a very human-like swindle.
Check out this CrazyAra study if you would like to explore these lines and variations further or for some of the other games CrazyAra has played in training or on its two other outings to Lichess (3 weeks and 3 months ago).
As we saw, CrazyAra 0.3.1 still misses mates (not delivering a mate in 4 on its turn in game 5 as well as hanging a mate in 3 in game 2). To try to alleviate this flaw, a “blunder check” will be incorporated in future versions, running the MCTS from the opposite perspective to CrazyAra so that having chosen a candidate move to play, the program checks (as a human would do) to make sure that there is not some forcing line that loses. Also, CrazyAra has yet to undergo any self-play training, or training by playing against Stockfish or watching Stockfish play, so we imagine this will be the next big step.
Some further ideas for improvement are (1) to adjust the probability distribution (the p-values) so as to expect the unexpected, paying a little more attention to seemingly less likely moves, (2) a test database of critical positions (where there is one clearly best move), so with each new improved version of CrazyAra, the developers can test if the time taken to solve the critical positions does indeed decrease on average, (3) a deeper analysis of forcing variations (especially checks & captures), to avoid the engine missing mates or winning lines, (4) in the Monte-Carlo tree search, stopping ideally at child nodes which are peaceful positions (positions with many possibly equally good moves) at which the network’s q-values assessing the position are likely to be more accurate and finally (5) the introduction of a free move counter. In a given position, if I do a null move, then does my opponent have forced mate? If so, I have 0 free moves as I must defend the mate in some way. If not, then can I do two null moves without being force-mated? In this case I would have 1 free move. Turning the board round, if I have more free moves than my opponent does after my move, then this gives me a license to attack. Informally speaking, if both players ignore and try to mate each other, then the player with the greater number of free moves in a given position is likely to win, especially if this number is small. This kind of counter might better hone CrazyAra’s strategic sense for when to defend and when to attack which would complement its tactical and positional strengths.
Wishing everyone in the crazyhouse community a very merry Christmas!
—okei & IQ_QI
No comments:
Post a Comment