Skip to content

varunmathur2005/Tic-Tac-Toe

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

21 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Tic-Tac-Toe

Overview

Tic-Tac-Toe is a classic and nostalgic game, often played on paper with friends. This project recreates the game using Python and SQL, allowing it to be played through the command line. The goal of the game is to get three of your marks (X or O) in a straight line, either vertically, horizontally, or diagonally.

Features

  • Command Line Interface: Play the game through a user-friendly command line interface.
  • Random Character Assignment: Players are assigned either X or O randomly using the random module.
  • Stylized Text: The fontstyle module enhances the game's appearance by changing text fonts and colors.
  • Game Records: The game stores summaries of past games in both text files and a MySQL database.
  • Multiple Game Modes: Play against another player or a computer (computer mode is under construction).

Getting Started

When you start the game, you are greeted with a welcome message and asked to make a choice from the menu:

  1. Start a New Game: Begins a new round of Tic-Tac-Toe.

    New Game

  2. View Game Rules: Displays the rules of the game from a text file (rules.txt).

    Game Rules

  3. View Last Game Summary: Shows the summary of the last game from a text file (RECORD.TXT).

    Last Game Summary

  4. Load Game Records from Database: Loads and displays all game records stored in the MySQL database.

    Load Records

  5. Exit Game: Exits the game, thanking the user for playing.

    Exit

Game Logic

The game logic varies depending on the mode selected:

Player vs. Player Mode

  1. Character Assignment: Players are randomly assigned X or O.

  2. Board Setup: A 3x3 grid is displayed, with positions numbered 1-9.

    Board Display

  3. Game Flow:

    • Players take turns placing their marks on the board.
    • The game checks for win conditions or ties using the check_win function.
    • If a player wins, the game ends; if the board fills up, the game is tied.

    Gameplay

  4. Play Again: After a game ends, players are asked if they want to play again. The game restarts if they choose "Y"; otherwise, it exits with a thank you message.

Player vs. Computer Mode

Currently under construction. When selected, the game exits with the message: "Player vs computer mode is currently under construction."

Modules Used

  • fontstyle: Adds style and color to the text, making the game more visually appealing.
  • random: Assigns characters randomly to players.
  • sys: Handles program exits.
  • mysql.connector: Connects to MySQL to store and retrieve game summaries.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages