Skip to content

Four_In_A_Row problem has been solved using Python Language with the comprehensive implementation of Min-Max Alpha-Beta Pruning Algorithm. The Depth of the search for the algorithm has been customized for a quicker but less accurate response from an AI agent.

Notifications You must be signed in to change notification settings

akibzaman/Four_In_A_Row_AI

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 

Repository files navigation

Four_In_A_Row_AI

image

Introduction

The problem has been solved using Python Language with the comprehensive implementation of Min-Max Alpha-Beta Pruning Algorithm. The Depth of the search for the algorithm has been customized for a quicker but less accurate response from an AI agent.. Main Functions have been highlighted as below:

  1. Priority for Winning/ Blocking the Opponents
  2. Min Max Algorithm
  3. Winning Combinations

Winning Combinations

There are four winning (vertical, horizontal, positive sloped and negative sloped) combinations in this game which has been implemented correctly in this task using the winning_move () Function which has been shown in figure 1.

image

Figure 1: winning_move function

Priority for Winning/ Blocking the Opponents

Prioritization of moving the pieces according to the situation has been done by the following 3 cases Case 1: Own 3 pieces are in position. Next move will win it for myself. (Priority-1) Case 2: Opponents 3 pieces are in position. Block it. (Priority-2) Case 3: Own 2 Pieces are in position. Build it for Getting Case 1. (Priority-3) These 3 cases has been implemented using the combination of pick_best_move (), score_position () and evaluate_window () functions as shown respectively in figure 2, 3, 4.

image

Figure 2: pick_best_move function

image

Figure 3: score_position () function

image

Figure 4: evaluate_window function

Min-Max Algorithm (Alpha-Beta Pruning)

Classic Min-Max algorithm with Alpha Beta pruning has been implemented as minimax () function in this task. Depth has been set at maximum 5 called from main function which has caused the AI agent to react faster sacrificing a bit of accuracy which has been shown in figure 5.

image

Figure 5: minimax () function

Conclusion:

The Task has been clinically completed with the successful implementation of Min-Max algorithm with Alpha Beta pruning. Additionally the depth of the searching has been customized (Bonus-1). However, there are rooms of improvement in case of accuracy and UI development of this game can be a future prospect of this task.

About

Four_In_A_Row problem has been solved using Python Language with the comprehensive implementation of Min-Max Alpha-Beta Pruning Algorithm. The Depth of the search for the algorithm has been customized for a quicker but less accurate response from an AI agent.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages