Tic-Tac-Toe is a classic game implemented using Java Spring Boot for the backend and Thymeleaf, HTML, and CSS for the frontend. This is a part of my internship Task 5 for my Future Intern internship. The application allows users to play Tic-Tac-Toe against either another player or a computer. It includes functionalities such as making moves, checking for a winner, and restarting the game.
- Single Player Mode: Play against the computer 🤖
- Two Player Mode: Play against another player 🧑🤝🧑
- Restart Functionality: Restart the game anytime 🔄
- Responsive Design: The UI adapts to different screen sizes 📱💻
- Real-Time Updates: Moves and game status are updated in real-time ⚡
- Backend: Java, Spring Boot
- Frontend: Thymeleaf, HTML, CSS, JavaScript
- Database: In-memory storage (no database used)
- Dependencies: Spring Boot, Thymeleaf, jQuery
-
Clone the repository:
git clone https://github.com/your-username/tic-tac-toe.git
-
Navigate to the project directory:
cd tic-tac-toe
-
Build the project:
./mvnw clean install
-
Run the application:
./mvnw spring-boot:run
-
Open your browser and navigate to
http://localhost:8080/tic-tac-toe
to play the game.
- Start the Application: Run the Spring Boot application using the command provided in the installation section.
- Access the Game: Open a web browser and go to
http://localhost:8080/tic-tac-toe
. - Play the Game:
- Click on a cell to make a move.
- If playing against the computer, it will make a move automatically.
- Click "Restart Game" to reset the board.
-
Make a Move:
- URL:
/tic-tac-toe/makeMove/{index}
- Method:
POST
- Parameters:
index
(Path Variable): The index of the cell (0-8).mode
(Request Parameter): 'single' for single player mode.
- URL:
-
Restart Game:
- URL:
/tic-tac-toe/restart
- Method:
POST
- URL:
- HTML: Located in
src/main/resources/templates/index.html
- CSS: Located in
src/main/resources/static/css/styles.css
- JavaScript: Inline script in
index.html
for handling AJAX requests.
Contributions are welcome! Please open an issue or submit a pull request if you have suggestions or improvements.
For any questions or feedback, please contact me at
- Name: Deepak Singh
- Email: deepsinghkumar01@gmail.com