Skip to content

gamalahmedd/TicToe-Game

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

TicToe-Game

This project is a basic Tic-Tac-Toe game developed in Java. It provides a graphical user interface for one player to play the game vs computer.

Features

  • Simple and intuitive GUI.
  • One-player mode.
  • Basic game logic for Tic-Tac-Toe.

Technologies

  • Java
  • MinMax Algorithm

Installation

  1. Clone the repository:
    git clone https://github.com/gamalahmedd/TicToe-Game.git
  2. Open the project in NetBeans 8.2 IDE

Working of MinMax Algorithm

  1. In the first step, the algorithm generates the entire game-tree and apply the utility function to get the utility values for the terminal states. In the below tree diagram, let's take A is the initial state of the tree. Suppose maximizer takes first turn which has worst-case initial value =- infinity, and minimizer will take next turn which has worst-case initial value = +infinity.

alt text

  1. Now, first we find the utilities value for the Maximizer, its initial value is -∞, so we will compare each value in terminal state with initial value of Maximizer and determines the higher nodes values. It will find the maximum among the all.
    • For node D max(-1,- -∞) => max(-1,4)= 4
    • For Node E max(2, -∞) => max(2, 6)= 6
    • For Node F max(-3, -∞) => max(-3,-5) = -3
    • For node G max(0, -∞) = max(0, 7) = 7

alt text

  1. In the next step, it's a turn for minimizer, so it will compare all nodes value with +∞, and will find the 3rd layer node values.
    • For node B= min(4,6) = 4
    • For node C= min (-3, 7) = -3

alt text

  1. Now it's a turn for Maximizer, and it will again choose the maximum of all nodes value and find the maximum value for the root node. In this game tree, there are only 4 layers, hence we reach immediately to the root node, but in real games, there will be more than 4 layers.
    • For node A max(4, -3)= 4

alt text

Screenshots

alt text

alt text

Usage

  1. Run the Main class located in the src directory.
  2. The game window will appear, and you can start playing.

License

This project is licensed under the Mozilla Public License 2.0. See the LICENSE file for details.

About

This is a simple Tic Toe Game

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages