Click here to download the source of the Quarto applet. The zip file includes the sources for the Java applet, the Java standalone version and the C version.
The standalone Java version is the easiest to read. The kernel of the algorithm can be found in the file "Board.java". We use the classic minimax algorithm. The most important optimization we did is that we do not search for a winning move. From the moment we find a move that garantees a draw, we stop searching and just do the move. The reason is that we calculated the game completely and it is impossible to win with a perfect opponent. I.e. It is always possible to reach a draw. It is easy to adapt the algorithm to make it search for a winning move. The C version is a highly optimized version and is VERY difficult to read without further explanation. It does not contain a user interface and needs to be used by providing an input file describing the current board position and a parameter describing the depth you want to calculate. It was used to calculate Quarto completely based on the symmetries of positions to cut down on the calculation work. The main optimizations in this version are: