Skip to content

Fun game tic-tac-toe with artificial intelligence in Java.

Notifications You must be signed in to change notification settings

Rutzno/tic-tac-toe_with_ai

Repository files navigation

Tic-Tac-Toe with Artificial Intelligence

Tic-Tac-Toe game (also known Noughts and Crosses), is a paper-and-pencil game for two players, X and O, who take turns marking the spaces in a 3×3 grid. The player who succeeds in placing three of their marks in a horizontal, vertical, or diagonal row is the winner.

This project is an upgraded version of the project tic-tac-toe in java which allows a human being to play against a computer in implementing three level of difficulty by integrating artificial intelligence.

  • easy : Make a random move
  • medium : It uses this technique
    1. If it can win in one move (if it has two in a row), it places a third to get three in a row and win.
    2. If the opponent can win in one move, it plays the third itself to block the opponent to win.
    3. Otherwise, it makes a random move.
  • hard : We implement the Minimax algorithm. It's a brute force algorithm that maximizes the value of the own position and minimizes the value of the opponent's position. It's not only an algorithm for Tic-Tac-Toe, but for every game with two players with alternate move order, for example, chess. Thus, this level is an undefeated champion (so, it can come out with a win, or a tie score).

There is another feature in this app: if you're tired playing the game, you can even launch a match between two ai and watch them playing.

Since it's not yet in GUI, you might use these coordinates to play the game.


|1 3 2 3 3 3|
|1 2 2 2 3 2|
|1 1 2 1 3 1|

To start the game, after input command: type for instance start hard user which mean match between aiPlayer (computer) and human.

About

Fun game tic-tac-toe with artificial intelligence in Java.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages