/Connect4-AI

My firts Pygame project, A Connect4 game where you can play against a friend or an AI.

Primary LanguagePython

logooo


My first pygame project, a connect4 game where you can either play against a friend or an AI with several difficulties to choose from.

Libraries needed:

  • Pygame.
  • Pymunk.
  • Numpy.

Game Features:

  • Play against an AI or a friend on the same computer.
    • May work on an online multiplayer feature.
  • Physics of both the pieces and board was implemnted using the Pymunk Library.

gameModes

2022-09-19.22-02-50.mp4

The AI:

  • Currently there are 5 difficulties to choose from.
    • Even easy difficulty is not that easy.
  • All difficulties use the Minimax algorithm in order for the AI to choose the best move.
  • Difficulties differ in how may moves the AI will foresee from the current Connect4 board.
  • Alpha-Beta pruning was also used to eliminate Unreasonable paths for the AI to look into, thus reducing its computation time by a huge factor.
  • Still the Very hard and Impossible difficulties take the AI a couple of seconds, as a matter of fact I am working on more optimizations for the minimax algorithm.

difficulties

AiWon

Tasks

  • Add more optimizations to the Minimax algorithm.
  • Online multiplayer.
  • Add more gameplay options [Choose colour of piece etc.. ].