TicTacToe AI
Home OpenBubbles Chess AI Stoichiometry Solver TicTacToe AI Transportation Efficiency The Case for Semi-Free Software Navigation Menu

 As part of my larger effort to develop a successful Chess AI, begun in the fall of 2003, I devoted much of my energy during my Winter Break from school to programming the Java applets that you see below. Because I did not know how to write GUI applications for any platform in C++ at the time, the only way I could write a GUI program was through Java. Although it would have been possible to write a console application in C++ that could have displayed a 3 by 3 grid with O's and X's, there remained many reasons to choose Java. First off, using GUI made using the program much more intuitive. Second, I was eager to expand my capabilities outside of text-based programming and Java was an excellent way to do so, mostly because I had recently been given a wonderful Java textbook. I had been reading through this textbook and the TicTacToe AI presented an opportunity to employ what I had been reading about. A third good reason, which is one that is easier to see in hindsight than at the time, is that it would allow for the program to be quickly and easily presented on this website, without requiring the user to download it. If you would like to see an explanation of how the AI works, please look below the applets.

These applets are unbeatable, so don't waste your time for too long!

Note: While using these applets, you may experience problems with the computer taking two or even three turns in a row. This usually occurs if you click while the computer is calculating ("thinking"), but you can also cause problems by clicking outside of the applet area and then continuing to use it later. I am aware of this bug, but do not know how to fix it.

If you know how to fix the bug or have any suggestions on how to improve these applets, particularly the AI, please email me at lasindi@gmail.com.

All of the software on this website is released under the GNU General Public License.

Both downloads include the source.

TicTacToe v1.0 (Download)

TicTacToe v1.1 (Download)

 The AI does a recursive evaluation of each position. It examines the squares from left to right in each row in order. Each of these evaluations are displayed to the right of the grid (you can toggle it if you like). The computer assumes that its human opponent will recognize an opportunity to win in one move. Therefore, a move that gives the opponent such an opportunity will be given an evaluation of 0.0. Otherwise, the computer gives evaulates based on averages of the moves available to the human player and the assumption that the computer will make the best move that it finds. Therefore, a 1.0 evaluation means a certain win somewhere down the line. Here is where v1.0 and v1.1 differ. If v1.0 finds a move that will win immediately, it will not evaluate any remaining moves and will make that move. Otherwise, it will evaluate all possible moves and then take the first move that it is evaluated as 1.0. Version 1.1 will stop evaluating as soon as it finds a move that will win eventually. This strategy was not possible in v1.0, because of an inferior position evaluation mechanism. Because v1.1's evaluation code was improved, this new strategy has been implemented, but it makes it seem less intelligent. This is because v1.0 will take exploit any chance to win in one move. If v1.1, however, finds a move that will win in two or three moves before it finds a move that will in one, it will execute the former. So, while v1.1 will not win any less than v1.0 (I'm not sure if v1.1 wins more than v1.0), it may take a longer route to victory. The only reason why I did this was to fix the position evaluation in order to create something more applicable to the Chess AI. If you would like to learn more about how the AI works, please download either applet and read the source.

Valid HTML 4.01!    Valid CSS!

This website is hosted for free by Freewebs.com - free website. Get your own Free Website now!