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.
- 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
randommodule. - Stylized Text: The
fontstylemodule 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).
When you start the game, you are greeted with a welcome message and asked to make a choice from the menu:
-
Start a New Game: Begins a new round of Tic-Tac-Toe.
-
View Game Rules: Displays the rules of the game from a text file (
rules.txt). -
View Last Game Summary: Shows the summary of the last game from a text file (
RECORD.TXT). -
Load Game Records from Database: Loads and displays all game records stored in the MySQL database.
-
Exit Game: Exits the game, thanking the user for playing.
The game logic varies depending on the mode selected:
-
Character Assignment: Players are randomly assigned X or O.
-
Board Setup: A 3x3 grid is displayed, with positions numbered 1-9.
-
Game Flow:
- Players take turns placing their marks on the board.
- The game checks for win conditions or ties using the
check_winfunction. - If a player wins, the game ends; if the board fills up, the game is tied.
-
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.
Currently under construction. When selected, the game exits with the message: "Player vs computer mode is currently under construction."
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.






