Skip to content

igokulganesh/Connect-Four

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

20 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Connect Four Game

Connect four is a two player connection board game, in which the players choose a color and then take turns dropping colored discs into a seven-column, six-row vertically suspended grid. The pieces fall straight down, occupying the lowest available space within the column. The objective of the game is to be the first to form a horizontal, vertical, or diagonal line of four of one's own discs.

Game modes

  • Play with Friends
  • Play with Computer (Using Minimax with Alpha-Beta Pruning)

Minimax Algorithm

  • Mini-max algorithm is a recursive or backtracking algorithm which is used in decision-making and game theory. It provides an optimal move for the player assuming that opponent is also playing optimally.
  • Mini-Max algorithm uses recursion to search through the game-tree.
  • Min-Max algorithm is mostly used for game playing in AI. Such as Chess, Checkers, tic-tac-toe, connect-four, and various two-players game. This Algorithm computes the minimax decision for the current state.
  • In this algorithm two players play the game, one is called MAX and other is called MIN.
  • Both the players fight it as the opponent player gets the minimum benefit while they get the maximum benefit.
  • Both Players of the game are opponent of each other, where MAX will select the maximized value and MIN will select the minimized value.
  • The minimax algorithm performs a depth-first search algorithm for the exploration of the complete game tree.
  • The minimax algorithm proceeds all the way down to the terminal node of the tree, then backtrack the tree as the recursion.

Alpha-Beta Pruning

  • Alpha-beta pruning is a modified version of the minimax algorithm. It is an optimization technique for the minimax algorithm.
  • As we have seen in the minimax search algorithm that the number of game states it has to examine are exponential in depth of the tree. Since we cannot eliminate the exponent, but we can cut it to half. Hence there is a technique by which without checking each node of the game tree we can compute the correct minimax decision, and this technique is called pruning. This involves two threshold parameter Alpha and beta for future expansion, so it is called alpha-beta pruning. It is also called as Alpha-Beta Algorithm.
  • Alpha-beta pruning can be applied at any depth of a tree, and sometimes it not only prune the tree leaves but also entire sub-tree.
  • The two-parameter can be defined as:
    1. Alpha: The best (highest-value) choice we have found so far at any point along the path of Maximizer. The initial value of alpha is -∞.
    2. Beta: The best (lowest-value) choice we have found so far at any point along the path of Minimizer. The initial value of beta is +∞.
  • The Alpha-beta pruning to a standard minimax algorithm returns the same move as the standard algorithm does, but it removes all the nodes which are not really affecting the final decision but making algorithm slow. Hence by pruning these nodes, it makes the algorithm fast.

Wanna Play?

Click here