Two – Player Tic-Tac-Toe Game
Yohann Ezekiel A. De Guia
May 13, 2026
CC-COMPROG12-70021, Ms. Alegado Laila
I. Introduction
Tic-Tac-Toe is a simple two-player game familiar to everyone, where players can
take turns marking spaces in a 3 x 3 grid. The very goal is to successfully place marks in
a horizontal, vertical, or diagonal line taking turns against your opponent.
This game is often used as an introductory programming project because of how it
involves logic, loops, and condition checking. This project involves creating a console-
based, two-player Tic-Tac-Toe game programmed with Java; demonstrating basic
programming concepts such as arrays, loops, conditionals, methods, and user input
handling.
This project is limited to two players only. It runs through the output console
without a graphical interface. This project aims to create a playable Tic-Tac-Toe game
using java as instructed, handling user input and validating moves, detecting winning
and draw conditions.
II. Requirements
This game runs smoothly through the output consoles, input errors are handled
properly and should be fairly easy to understand and use. This requires a Java
Development Kit (JDK 8 or higher), and any Java IDE (Integrated Development
Environment, such as IntelliJ, VS Code, or BlueJ) and a computer with keyboard input
support.
[Link]
This program initializes a 3x3 board filled with empty spaces, and sets the current
player to X. It'll ask the current player for an input as the program validates the move
and places a mark on the board. The program runs until it determines a winner or a draw.
The interface is console-based, the board should be displayed like this:
IV. Implementation
This game is programmed using Java Standard Edition through IntelliJ IDEA. It
uses a scanner class for user input.
Directory Structure is rather simple and can be run with the file alone
([Link]) for as long as you have any IDE that runs Java. The class TicTacToe
handles the entire game logic. It has methods such as:
• printBoard() – displays the game board
• isValidMove(int row, int col) – checks if a move is valid
• makeMove(int row, int col) – places the player’s symbol
• checkWinner(char player) – checks all win conditions
• isBoardFull() – checks for draw condition
• getPlayerMove() – gets input from the user
• play() – main game loop
1. Board Initialization
2. Win Checking Logic
V. Testing
This program is manually tested via the console input with a Java (JDK)
[Link] and Solutions
Some challenges faced was the handling of invalid user inputs without crashing
the program and hours of debugging checking all possible winning conditions, and
managing the turns correctly.
It is resolved by using try-catch blocks handling input errors, creating separate
logic for rows, columns, diagonals, and using a simple ternary operator to switch
players; learning the importance of input validation, structuring code using methods to
improve readability, and that game logic requires careful and precise condition checking.
VII. Conclusion
The project has successfully implemented a working two-player Tic-Tac-Toe
game in Java, allowing the players to input moves, validating and determining the
winner, or in the instances that it's a draw.
This project helped strengthen my understanding of Java's fundamentals,
especially arrays, loops, and conditionals. It also improved my problem-solving skills by
implementing game logic step-by-step.
VIII. References
[Link]
[Link]
[Link]