Skip to content

katoki-dev/tic-tac-game

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

9 Commits
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

Tic-Tac-Toe in C

๐Ÿ“Œ Overview

This is an enhanced Tic-Tac-Toe game implemented in C with improved visuals and user experience. It allows two players to play in the terminal with a beautiful colored interface, robust input validation, and ergonomic gameplay features.

๐ŸŽฏ Features

โœ… Two-player mode (Player 1: 'X', Player 2: 'O')
โœ… Beautiful colored interface with ANSI colors (Cyan X, Magenta O)
โœ… Enhanced board design using Unicode box-drawing characters
โœ… Robust input validation (invalid positions, occupied cells, non-numeric input)
โœ… Clear screen between moves for better visibility
โœ… Play again option - no need to restart the program
โœ… Checks for horizontal, vertical, and diagonal wins
โœ… Detects a draw if the board is full
โœ… User-friendly prompts and error messages with emoji indicators

๐Ÿ“‚ File Structure

  • tttgame.c โ†’ Main program file containing the game logic

๐Ÿ›  Installation & Usage

1๏ธโƒฃ Clone the Repository

git clone https://github.com/katoki-dev/tic-tac-game.git  
cd tic-tac-game  

2๏ธโƒฃ Compile the program

gcc tttgame.c -o tic_tac_toe  

3๏ธโƒฃ Run the game

./tic_tac_toe  

4๏ธโƒฃ How to Play

  • Players take turns entering a number (1-9) to place their mark on the board.
  • Position 1 is top-left, Position 9 is bottom-right.
  • The game validates your input and shows clear error messages for invalid moves.
  • After each game, you can choose to play again or exit.

๐ŸŽจ Visual Improvements

  • Colorful interface: X appears in cyan, O appears in magenta, available positions in yellow
  • Box-drawing characters: Professional-looking grid with Unicode borders
  • Clear screen: Fresh view after each move for better focus
  • Emoji indicators: Visual feedback for game states (๐ŸŽฎ game, ๐Ÿ game over, ๐ŸŽ‰ winner, โŒ errors)

๐Ÿ”ง Ergonomic Improvements

  • Input validation: Prevents invalid moves (out of range, occupied cells, non-numeric input)
  • Error messages: Clear feedback when something goes wrong
  • Play again: Continue playing without restarting the program
  • Fixed position bug: Corrected indexing for positions 1-9

๐Ÿ† Winning Conditions

The game checks for a win based on:

  • Horizontal Line โœ…
  • Vertical Line โœ…
  • Diagonal Line โœ…

๐Ÿ’ก Feel free to contribute or modify the code! Let me know if you have any suggestions. ๐Ÿš€

About

Practice program for building a simple tic-tac-toe game for two players to play on terminal.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •  

Languages