Skip to content

A program that plays Tic-tac-toe optimally against an opponent.

Notifications You must be signed in to change notification settings

luntropy/tic-tac-toe

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Tic-tac-toe

Purpose

The objective is to create a game that plays Tic-tac-toe optimally against the player no matter if the player starts first or second.

Tic-tac-toe Wikipedia

Rules

  • The player can choose if he starts first or second.
  • The game should display the current state.
  • The game should display who is the winner.
  • The program should play optimally against the opponent.

About the program

The program uses the algorithm Min-Max with Alpha-Beta pruning to play the game. When the game is started the user chooses if he wants to play first or second. According to that the program adapts and chooses the best move.

To run the program

  • Build it using make
  • Run ./main

Output

  • Initially the program asks the user if he wants to start first.
  • Displays current state.
  • Displays who won the game or 'Draw' in case of draw.

Output - initial

Output-initial

Output - current state - part 1

Output-current-state-1

Output - current state - part 2

Output-current-state-2

Output when the AI won

Output-AI-won

Output - draw

Output-Draw

About

A program that plays Tic-tac-toe optimally against an opponent.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published