Inspiration
When I was younger and to this day, I enjoyed playing Tic-Tac-Toe, so I decided to try making it myself. I thought it would be a fun project since I am still fairly new to programming and wanted to see if I could create a game I love.
What it does
This program allows the user to play the common household game Tic-Tac-Toe. The rules of Tic-Tac-Toe are simple: both players take turns placing their tokens on a 3x3 grid, and whoever is the first to have three of their tokens in a row (vertically, horizontally, or diagonally) wins. I also thought it would be fun to add an unbeatable bot and other capabilities, such as the ability to choose your token color and username, to make it a full-fledged game.
How we built it
I built it using Java and helper classes/libraries such as JOptionPane, JColorChooser, and DrawingPanel. To create the algorithm, I used the minimax game theory concept and tailored it to my program, allowing the computer to stop the user from winning, effectively ending the game in a tie or a computer win.
Challenges we ran into
An interesting and challenging part of the code was trying to create buttons, the ability to submit usernames, and the capability to change the color of the characters/tokens. I originally drew a rectangle on the screen and tried to use the mouse listener to detect whether the cursor click was in the correct rectangle to create a semi-functional button. However, this approach was neither functional nor aesthetic enough for the program. So instead, I used classes and libraries like JOptionPane, which was used for the dialogue boxes and buttons, and JColorChooser, which was the token color customizer, to create a better overall program, resulting in a now functional Tic-Tac-Toe game.
Accomplishments that we're proud of
I am proud of the work I did to implement the minimax (computer algorithm). I originally tried to create the unbeatable algorithm without any preexisting knowledge, and after many hours of trying and failing, I knew I had to try a different approach. So I decided to utilize components of the minimax concept to create my algorithm, which was a success. Working through this problem and the program as a whole was a great learning experience for me, and I am extremely proud of the work I put in.
What we learned
While working on this project, I learned a lot about coding in Java as well as problem-solving for myself. For the actual coding part, I learned a lot about utilizing JOptionPane, JColorChooser, and Minimax. I also improved at incorporating the mouse listener, drawing panel, and other components into my code. On a personal level, I learned a lot about problem-solving through difficult code, whether that involves taking breaks and debugging, or referencing and citing other sources like websites and friends who helped me troubleshoot. Overall, I think this project was a great learning experience, and I am proud of the work I put out.
What's next for Tic-Tac-Toe
One component I would love to add to my program is the ability to customize your token (like X or O) into something else. Figuring out a way for the user to upload a picture or file of what they want their token to be and allowing them to play with that would be a cool feature. In general, I would also like to polish the program so that it looks more professional and enhances user interaction.
Log in or sign up for Devpost to join the conversation.