Inverse Tic-Tac-Toe

Project Details

Inverse Tic-Tac-Toe is the opposite of classic Tic-Tac-Toe. Basically, two players compete to fill in empty spots of the nine by nine Tic-Tac-Toe grid in such a way that they do not get three Xs or three Os in a row. My project involved implementing this game in Java. Specifically, I needed to create a version in which a user could play against the computer program. In addition, I had to use squares and diamonds instead of Xs and Os. The project spanned two weeks and required the use of graphics interface, mouse events, and everything I’d learned in my ICS 111 class.

My Process

For this project, I was the only programmer. I wrote the entire program in the Eclipse IDE as my last assignment for ICS 111. I began the project using the Java’s graphics interface to create a nine by nine tic-tac-toe grid, which would be displayed in another window. Then, I started using mouse events to identify when a user would click on an empty spot of the grid. In particular, I implemented a method called mouseClicked, which I found to work the best. In addition, I determined the specific moves the program would make in response to the user. These moves were not random but purposed so that the computer had a good chance of winning. Not to mention, I identified when and where squares and diamonds could be drawn on the grid in my code. Afterward, I learned how and when to stop to game and check whether the game ended in a tie, with the user winning, or with the computer winning. I finished my project after putting in place three response messages that would appear at the top of the game window to tell the user these results.

What I learned

From making this inverse Tic-Tac-Toe Game, I learned many things. First off, I learned how to use the graphics interface, paint component method, graphic objects, and mouse events in Java. In addition, I’ve learned that I need to be really careful with my code and test it effectively, especially in large programs. Just one bug can result in a huge waste of time, which I found out the hard way. Overall, this project taught me that programming requires a lot of time, planning, effort, thought, and problem-solving skills.

Here’s my Program in Action!

Image Source: Pixabay