Skip to content

imwrdo/tic-tac-toe-java

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

20 Commits
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Tic-Tac-Toe in Java

A command-line implementation of the classic Tic-Tac-Toe game written in Java.

Features

  • Two game modes:
    • Human vs Human
    • Human vs Computer
  • Simple command-line interface
  • Computer player with strategic moves
  • Input validation
  • Interactive game board display

Requirements

  • Java 23 or higher

How to Play

  1. Start the game and choose a game mode:

    • 1 for Human vs Human
    • 2 for Human vs Computer
    • 3 to Exit
  2. The board is numbered from 1 to 9:

  1 | 2 | 3  
------------
  4 | 5 | 6  
------------
  7 | 8 | 9  
  1. Players take turns entering a number (1-9) to place their mark (X or O)
  2. First player to get three in a row (horizontally, vertically, or diagonally) wins!

Project Structure

src
└── org.example
    β”œβ”€β”€ enums
    β”‚    └── Character.java - Enum representing the characters used in the game
    β”œβ”€β”€ logic
    β”‚    β”œβ”€β”€ core
    β”‚    β”‚    β”œβ”€β”€ Game.java - Initializes a new game
    β”‚    β”‚    β”œβ”€β”€ GameProcessLogicHandler.java - Handles the game loop logic
    β”‚    β”‚    └── GameSession.java - Starts the game session by setting up players, and starting the game loop.
    β”‚    β”œβ”€β”€ gamemode
    β”‚    β”‚    β”œβ”€β”€ HumanVsComputerMode.java - Implements the Human vs. Computer game mode.
    β”‚    β”‚    └── HumanVsHumanMode.java - Implements the Human vs. Human game mode
    β”‚    └── menu
    β”‚         └── GameMenu.java - Manages the main menu and game mode selection
    β”œβ”€β”€ players
    β”‚    β”œβ”€β”€ types
    β”‚    β”‚    β”œβ”€β”€ Player.java - Represents a Human player
    β”‚    β”‚    └── ComputerPlayer.java - Represents a Computer player
    β”‚    └── creator
    β”‚         └── PlayerCreator.java - Handles the creation of a Player
    └── Main.java - You know what it is
   

Technical Details

  • Built with Java 23
  • Implements basic AI strategy for computer moves
  • Object-oriented design with clear separation of concerns

About

Java implementation of tic-tac-toe game

Topics

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages